Skip to content

Commit

Permalink
Fix PivotTotalDifficulty in update configs action (#8161)
Browse files Browse the repository at this point in the history
Co-authored-by: core-repository-dispatch-app[bot] <173070810+core-repository-dispatch-app[bot]@users.noreply.github.com>
Co-authored-by: kamilchodola <[email protected]>
  • Loading branch information
3 people authored Feb 4, 2025
1 parent 5506f83 commit ae13ee2
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 72 deletions.
88 changes: 55 additions & 33 deletions scripts/syncSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,113 +22,135 @@
"mainnet": {
"url": "api.etherscan.io",
"blockReduced": 1000,
"multiplierRequirement": 1000
"multiplierRequirement": 1000,
"isPoS": True
},
"gnosis": {
"url": "https://rpc.gnosischain.com",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": True
},
"chiado": {
"url": "https://rpc.chiadochain.net",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": True
},
"sepolia": {
"url": "api-sepolia.etherscan.io",
"blockReduced": 1000,
"multiplierRequirement": 1000
"multiplierRequirement": 1000,
"isPoS": True
},
"energyweb": {
"url": "https://rpc.energyweb.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": False
},
"volta": {
"url": "https://volta-rpc.energyweb.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": False
},
"exosama": {
"url": "https://rpc.exosama.com",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": False
},
"joc-mainnet": {
"url": "https://rpc-1.japanopenchain.org:8545",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": False
},
"joc-testnet": {
"url": "https://rpc-1.testnet.japanopenchain.org:8545",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": False
},
"base-mainnet": {
"url": "https://mainnet.base.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": True
},
"base-sepolia": {
"url": "https://sepolia.base.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": True
},
"op-mainnet": {
"url": "https://mainnet.optimism.io",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": True
},
"op-sepolia": {
"url": "https://sepolia.optimism.io",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": True
},
"linea-mainnet": {
"url": "https://rpc.linea.build",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": False
},
"linea-sepolia": {
"url": "https://rpc.sepolia.linea.build",
"blockReduced": 8192,
"multiplierRequirement": 10000
"multiplierRequirement": 10000,
"isPoS": False
}
}

def fastBlocksSettings(configuration, apiUrl, blockReduced, multiplierRequirement):
def fastBlocksSettings(configuration, apiUrl, blockReduced, multiplierRequirement, isPoS):
if "etherscan" in apiUrl:
latestBlock = int(json.loads(subprocess.getoutput(f'curl --silent "https://{apiUrl}/api?module=proxy&action=eth_blockNumber&apikey={key}"'))['result'],16)
latestBlock = int(json.loads(subprocess.getoutput(
f'curl --silent "https://{apiUrl}/api?module=proxy&action=eth_blockNumber&apikey={key}"'))['result'], 16)
else:
data = '{"id":0,"jsonrpc":"2.0","method": "eth_blockNumber","params": []}'

response = requests.post(apiUrl, headers=headers, data=data).text
data_req = '{"id":0,"jsonrpc":"2.0","method": "eth_blockNumber","params": []}'
response = requests.post(apiUrl, headers=headers, data=data_req).text
latestBlock = int(json.loads(response)['result'], 16)

baseBlock = latestBlock - blockReduced
baseBlock = baseBlock - baseBlock % multiplierRequirement

if "etherscan" in apiUrl:
pivot = json.loads(subprocess.getoutput(f'curl --silent "https://{apiUrl}/api?module=proxy&action=eth_getBlockByNumber&tag={hex(baseBlock)}&boolean=true&apikey={key}"'))
pivot = json.loads(subprocess.getoutput(
f'curl --silent "https://{apiUrl}/api?module=proxy&action=eth_getBlockByNumber&tag={hex(baseBlock)}&boolean=true&apikey={key}"'))
else:
data = '{"id":0,"jsonrpc":"2.0","method": "eth_getBlockByNumber","params": ["' +str(hex(baseBlock))+ '", false]}'
pivot = json.loads(requests.post(apiUrl, headers=headers, data=data).text)
data_req = '{"id":0,"jsonrpc":"2.0","method": "eth_getBlockByNumber","params": ["' + str(hex(baseBlock)) + '", false]}'
pivot = json.loads(requests.post(apiUrl, headers=headers, data=data_req).text)

pivotHash = pivot['result']['hash']
pivotTotalDifficulty = int(pivot['result'].get('totalDifficulty', '0x0'), 16)
print(configuration + 'LatestBlock: ' + str(latestBlock))
print(configuration + 'PivotNumber: ' + str(baseBlock))
print(configuration + 'PivotHash: ' + str(pivotHash))
print(configuration + 'PivotTotalDifficulty: ' + str(pivotTotalDifficulty))
data = {}

print(configuration + ' LatestBlock: ' + str(latestBlock))
print(configuration + ' PivotNumber: ' + str(baseBlock))
print(configuration + ' PivotHash: ' + str(pivotHash))
if not isPoS:
print(configuration + ' PivotTotalDifficulty: ' + str(pivotTotalDifficulty))

with open(f'{configsPath}/{configuration}.json', 'r') as mainnetCfg:
data = json.load(mainnetCfg)
data['Sync']['PivotNumber'] = baseBlock
data['Sync']['PivotHash'] = pivotHash

data['Sync']['PivotNumber'] = baseBlock
data['Sync']['PivotHash'] = pivotHash

if not isPoS:
data['Sync']['PivotTotalDifficulty'] = str(pivotTotalDifficulty)
with open(f'{configsPath}/{configuration}.json', 'w') as mainnetCfgChanged:
json.dump(data, mainnetCfgChanged, indent=2)

with open(f'{configsPath}/{configuration}.json', 'w') as mainnetCfgChanged:
json.dump(data, mainnetCfgChanged, indent=2)

for config, value in configs.items():
print(emoji.emojize(f"{config.capitalize()} section :white_check_mark: "))
fastBlocksSettings(config, value['url'], value['blockReduced'], value['multiplierRequirement'])
fastBlocksSettings(config, value['url'], value['blockReduced'], value['multiplierRequirement'], value['isPoS'])
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Runner/configs/base-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"FastSync": true,
"SnapSync": true,
"FastSyncCatchUpHeightDelta": "10000000000",
"PivotNumber": 25820000,
"PivotHash": "0x7bbd5a8d39cda65ea8cd13bb1500d6517f129c6f36e5b7ebee358016be5c2dce",
"PivotNumber": 25920000,
"PivotHash": "0xc9af0380140a427773777db30a81b13071ea19a97a51a225748fc83c29175f36",
"PivotTotalDifficulty": "0"
},
"Discovery": {
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Runner/configs/base-sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"FastSync": true,
"SnapSync": true,
"FastSyncCatchUpHeightDelta": "10000000000",
"PivotNumber": 21330000,
"PivotHash": "0x7182a28f54c5fce1fd63f7920abc7a601f076929e07a4b586253fc72742ae626",
"PivotNumber": 21430000,
"PivotHash": "0x98dc8ae633b61b50c8a231c82d656fd311b20bb4996fbe4a41fef2d7608e0b28",
"PivotTotalDifficulty": "0"
},
"Discovery": {
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Runner/configs/chiado.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"Sync": {
"FastSync": true,
"SnapSync": true,
"PivotNumber": 14100000,
"PivotHash": "0xbc0239dea9620d092bed303abd8bc4289c1b7c0e25c21f58d4937210dc2a08bc",
"PivotNumber": 14140000,
"PivotHash": "0x8ee85169467fc490b4e0b04c7055fad189989a1661ddd9dd69e1b40da9119f37",
"PivotTotalDifficulty": "231708131825107706987652208063906496124457284",
"FastSyncCatchUpHeightDelta": 10000000000,
"UseGethLimitsInFastBlocks": false
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/energyweb.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
},
"Sync": {
"FastSync": true,
"PivotNumber": 34060000,
"PivotHash": "0x4ec412c8d021872d4f4243fa1ceaab3147126fc0d91aec69ee7f5c1e9283bbde",
"PivotTotalDifficulty": "11590017417327164065562539129126025281809750292",
"PivotNumber": 34100000,
"PivotHash": "0x036b9f959c1351220657ff0ed998fd30b41f26d92aa7fc3bb719a6d31cc03619",
"PivotTotalDifficulty": "11603628712004001604101074113423296010267907705",
"UseGethLimitsInFastBlocks": false,
"FastSyncCatchUpHeightDelta": 10000000000
},
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/exosama.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
},
"Sync": {
"FastSync": true,
"PivotNumber": 14400000,
"PivotHash": "0x79608c789ff3762c095cd53b85848b7af09b57570e7c6df2c92ac6a08374de78",
"PivotTotalDifficulty": "4900066083661513873872594347017462244604453280",
"PivotNumber": 14440000,
"PivotHash": "0xa4ab83f6308ebf7155599af65860762b26afe833cea818a338568e8cf2a53b4c",
"PivotTotalDifficulty": "4913677378338351412411129331314732973062613280",
"UseGethLimitsInFastBlocks": false,
"FastSyncCatchUpHeightDelta": 10000000000
},
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Runner/configs/gnosis.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"Sync": {
"FastSync": true,
"SnapSync": true,
"PivotNumber": 38330000,
"PivotHash": "0xef075c481b7b57906f7c13a95c8dc618be35a630acebded16a61f7a700510f7e",
"PivotNumber": 38370000,
"PivotHash": "0x2e37d29585fd733d5d335ace839b6df93f2ce32795bf3c12afba129f1fc78039",
"PivotTotalDifficulty": "8626000110427538733349499292577475819600160930",
"UseGethLimitsInFastBlocks": false,
"FastSyncCatchUpHeightDelta": 10000000000
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/joc-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"Sync": {
"FastSync": true,
"SnapSync": true,
"PivotNumber": 15760000,
"PivotHash": "0xa5459a4ae3ba3f22424e314dfae6f663e3754fc05963cf9289925c4cce20d43c",
"PivotTotalDifficulty": "30227347"
"PivotNumber": 15800000,
"PivotHash": "0xe1f2afd5a5716abb470fbef392df67d860507b0acc3d0a0e213df8abe7509174",
"PivotTotalDifficulty": "30283859"
},
"Metrics": {
"NodeName": "JOC-Mainnet"
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/joc-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"Sync": {
"FastSync": true,
"SnapSync": true,
"PivotNumber": 9370000,
"PivotHash": "0xa40e0ea4d7f122482482c40b6e21217079a48842fa1ee8db7e7473e2e2cd15f6",
"PivotTotalDifficulty": "16424626"
"PivotNumber": 9410000,
"PivotHash": "0xdef625ce0a0824e31aa9916b447a0b377232c3126667fa86eb06e0fec0362858",
"PivotTotalDifficulty": "16481806"
},
"Metrics": {
"NodeName": "JOC-Testnet"
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/linea-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
},
"Sync": {
"SnapSync": true,
"PivotNumber": 15310000,
"PivotHash": "0x62fce5d84905fb16f765faa02e56eb4958470e7886d167ad6387114037d1b273",
"PivotTotalDifficulty": "30620001",
"PivotNumber": 15400000,
"PivotHash": "0x9e9cd49aeffd2bea5eebc6a6223622c4cdb807d7db4b63c1b0a499834cad65b4",
"PivotTotalDifficulty": "30800001",
"HeaderStateDistance": 6
},
"JsonRpc": {
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/linea-sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
},
"Sync": {
"SnapSync": true,
"PivotNumber": 8830000,
"PivotHash": "0x180913f65e9f87652e99eb51532493e7123f09851f9dd780c0ebc0a55907b7af",
"PivotTotalDifficulty": "17660001",
"PivotNumber": 8920000,
"PivotHash": "0xef92efd0de551a8af42bfcd65cde13df3cf85ef402d98ba157310625c0f4e79a",
"PivotTotalDifficulty": "17840001",
"HeaderStateDistance": 6
},
"JsonRpc": {
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"Sync": {
"FastSync": true,
"SnapSync": true,
"PivotNumber": 21754000,
"PivotHash": "0x577f14de2c939ad282a669e778913336f7844e270cc517c662dabc1f255cb74d",
"PivotTotalDifficulty": "0",
"PivotNumber": 21771000,
"PivotHash": "0x067bda300e15ed3b8893ee0f4f0ab3e23f9bb64fa794978eebf8d9a58e4ee158",
"PivotTotalDifficulty": "58750003716598352816469",
"FastSyncCatchUpHeightDelta": "10000000000"
},
"EthStats": {
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Runner/configs/op-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"AncientBodiesBarrier": 105235063,
"AncientReceiptsBarrier": 105235063,
"FastSyncCatchUpHeightDelta": "10000000000",
"PivotNumber": 131420000,
"PivotHash": "0xad1198d38d4be46e74ede9aecd5cb889cf5fa766965d9127eb59a2b27625caa3",
"PivotNumber": 131520000,
"PivotHash": "0xc4704584d788dbd0b38bda3cdfa48949469342fe6b4b580360d0f3bce1b13d85",
"PivotTotalDifficulty": "0"
},
"Discovery": {
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Runner/configs/op-sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"FastSync": true,
"SnapSync": true,
"FastSyncCatchUpHeightDelta": "10000000000",
"PivotNumber": 23310000,
"PivotHash": "0xed68209e592e1732bb99ea27c8c7662d26e2fdefbc6e407b0a4a87ab7f167e89",
"PivotNumber": 23420000,
"PivotHash": "0xf5ee3aca9df5a6b4dc2fb14bdee4d8eca62437f041527c379e8efaa599a6b8ae",
"PivotTotalDifficulty": "0"
},
"Discovery": {
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"FastSync": true,
"SnapSync": true,
"UseGethLimitsInFastBlocks": true,
"PivotNumber": 7619000,
"PivotHash": "0x43c0b3b136993dfe294fe48e8a5e0ad23425d27f64f5284ec097246fb43e3b56",
"PivotTotalDifficulty": "0",
"PivotNumber": 7636000,
"PivotHash": "0x2e4ef53d4e81b6de5efa151db18bf7598d686d7e152695a2325c26bcdb3e47e4",
"PivotTotalDifficulty": "17000018015853232",
"FastSyncCatchUpHeightDelta": 10000000000
},
"Blocks": {
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/volta.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"Sync": {
"FastSync": true,
"PivotNumber": 30910000,
"PivotHash": "0x8ec676ad47292b64aa053f5475b2d4a0b3f2e3599d8a82965837171d9fe667a4",
"PivotTotalDifficulty": "10518127961526207905652909115715955415726510895",
"PivotNumber": 30940000,
"PivotHash": "0xdb8026f4f80d74024be8f5f22f8f9afa8d130829f857d041f1e8c3d640f226eb",
"PivotTotalDifficulty": "10528336432533836059556810353938908462070119854",
"UseGethLimitsInFastBlocks": false,
"FastSyncCatchUpHeightDelta": 10000000000
},
Expand Down

0 comments on commit ae13ee2

Please sign in to comment.