-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: do not proceed with init script if snapshotter is not active * feat: snapshotter active status check at runtime * build image for testnet_pretask * chore: ping reporting service every 30 secs * feat+chore: won't process further epochs is snapshotters is disabled, reduce default rpc polling interval to 10 seconds * chore: made PROTOCOL_STATE_CONTRACT and PROST_RPC URL mandatory, remove default values --------- Co-authored-by: Akshay Dahiya <[email protected]> Co-authored-by: Swaroop Hegde <[email protected]>
- Loading branch information
1 parent
20b4604
commit 0e65170
Showing
10 changed files
with
124 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import asyncio | ||
import sys | ||
from web3 import Web3 | ||
from snapshotter.auth.helpers.redis_conn import RedisPoolCache | ||
from snapshotter.settings.config import settings | ||
from snapshotter.utils.file_utils import read_json_file | ||
from snapshotter.utils.redis.redis_keys import active_status_key | ||
from snapshotter.utils.rpc import RpcHelper | ||
|
||
|
||
async def main(): | ||
aioredis_pool = RedisPoolCache(pool_size=1000) | ||
await aioredis_pool.populate() | ||
redis_conn = aioredis_pool._aioredis_pool | ||
anchor_rpc = RpcHelper(settings.anchor_chain_rpc) | ||
protocol_abi = read_json_file(settings.protocol_state.abi) | ||
protocol_state_contract = anchor_rpc.get_current_node()['web3_client'].eth.contract( | ||
address=Web3.toChecksumAddress( | ||
settings.protocol_state.address, | ||
), | ||
abi=protocol_abi, | ||
) | ||
snapshotters_arr_query = await anchor_rpc.web3_call( | ||
[ | ||
protocol_state_contract.functions.getAllSnapshotters(), | ||
], | ||
redis_conn | ||
) | ||
allowed_snapshotters = snapshotters_arr_query[0] | ||
if settings.instance_id in allowed_snapshotters: | ||
print('Snapshotting allowed...') | ||
await redis_conn.set( | ||
active_status_key, | ||
int(True) | ||
) | ||
sys.exit(0) | ||
else: | ||
print('Snapshotting not allowed...') | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == '__main__': | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters