Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
IDENTITY_ADDRESS=address
RPC_BASE_URL=url-without-/ext/bc/C
RPC_API_KEY="foo"
NOTIFICATION_DISCORD_WEBHOOK=https://discord.com/api/webhooks/secret/secret
NOTIFICATION_TELEGRAM_BOT_TOKEN=secret
NOTIFICATION_TELEGRAM_CHAT_ID=secret
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RPC_BASE_URL="https://flare-api.flare.network" \
| `METRICS_PORT` | no | `8000` | Prometheus metrics server port |
| `METRICS_ADDRESS` | no | `0.0.0.0` | Prometheus metrics server bind address |
| `LOG_LEVEL` | no | `INFO` | Logging level (`DEBUG`, `INFO`, `WARNING`, `ERROR`) |
| `RPC_API_KEY` | no | - | Use RPC API key where header is `x-apikey` |

## Prometheus metrics

Expand Down
4 changes: 2 additions & 2 deletions configuration/artifacts/FlareSystemsCalculator.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@
},
{
"indexed": true,
"internalType": "uint24",
"internalType": "uint32",
"name": "rewardEpochId",
"type": "uint24"
"type": "uint32"
},
{
"indexed": false,
Expand Down
59 changes: 59 additions & 0 deletions configuration/artifacts/FlareSystemsCalculator_stable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "voter",
"type": "address"
},
{
"indexed": true,
"internalType": "uint24",
"name": "rewardEpochId",
"type": "uint24"
},
{
"indexed": false,
"internalType": "address",
"name": "delegationAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "uint16",
"name": "delegationFeeBIPS",
"type": "uint16"
},
{
"indexed": false,
"internalType": "uint256",
"name": "wNatWeight",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "wNatCappedWeight",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bytes20[]",
"name": "nodeIds",
"type": "bytes20[]"
},
{
"indexed": false,
"internalType": "uint256[]",
"name": "nodeWeights",
"type": "uint256[]"
}
],
"name": "VoterRegistrationInfo",
"type": "event"
}
]
}
55 changes: 42 additions & 13 deletions configuration/artifacts/VoterRegistry.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@
},
{
"indexed": true,
"internalType": "uint24",
"internalType": "uint32",
"name": "rewardEpochId",
"type": "uint24"
"type": "uint32"
},
{
"indexed": true,
Expand All @@ -223,22 +223,51 @@
"type": "address"
},
{
"components": [
{
"internalType": "bytes32",
"name": "x",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "y",
"type": "bytes32"
}
],
"indexed": false,
"internalType": "bytes32",
"name": "publicKeyPart1",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "publicKeyPart2",
"type": "bytes32"
"internalType": "struct PublicKey",
"name": "publicKey",
"type": "tuple"
},
{
"indexed": false,
"internalType": "uint256",
"name": "registrationWeight",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint8",
"name": "v",
"type": "uint8"
},
{
"internalType": "bytes32",
"name": "r",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "s",
"type": "bytes32"
}
],
"indexed": false,
"internalType": "struct Signature",
"name": "signature",
"type": "tuple"
}
],
"name": "VoterRegistered",
Expand All @@ -255,9 +284,9 @@
},
{
"indexed": true,
"internalType": "uint256",
"internalType": "uint32",
"name": "rewardEpochId",
"type": "uint256"
"type": "uint32"
}
],
"name": "VoterRemoved",
Expand Down
78 changes: 78 additions & 0 deletions configuration/artifacts/VoterRegistry_stable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "voter",
"type": "address"
},
{
"indexed": true,
"internalType": "uint24",
"name": "rewardEpochId",
"type": "uint24"
},
{
"indexed": true,
"internalType": "address",
"name": "signingPolicyAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "submitAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "submitSignaturesAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "publicKeyPart1",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "publicKeyPart2",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "registrationWeight",
"type": "uint256"
}
],
"name": "VoterRegistered",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "voter",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "rewardEpochId",
"type": "uint256"
}
],
"name": "VoterRemoved",
"type": "event"
}
]
}
8 changes: 7 additions & 1 deletion configuration/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ def get_config() -> Configuration:
rpc_url = rpc_base_url + "/ext/bc/C/rpc"
p_chain_rpc_url = rpc_base_url + "/ext/bc/P"

w = Web3(Web3.HTTPProvider(rpc_url))
rpc_api_key = os.environ.get("RPC_API_KEY")
rpc_headers = {"Content-Type": "application/json"}
if rpc_api_key:
rpc_headers["x-apikey"] = rpc_api_key

w = Web3(Web3.HTTPProvider(rpc_url, request_kwargs={"headers": rpc_headers}))
if not w.is_connected():
raise ConfigError(f"Unable to connect to rpc with provided {rpc_url=}")

Expand Down Expand Up @@ -176,6 +181,7 @@ def get_config() -> Configuration:
fee_threshold=fee_threshold,
metrics=get_metrics_config(),
log_level=log_level,
rpc_api_key=rpc_api_key
)

return config
1 change: 1 addition & 0 deletions configuration/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,4 @@ class Configuration:
fee_threshold: int
metrics: MetricsConfig
log_level: str
rpc_api_key: str | None = None
Loading