diff --git a/.github/workflows/run-a-single-node-from-branch.yml b/.github/workflows/run-a-single-node-from-branch.yml index 594d0587de2..b1dd7c4e629 100644 --- a/.github/workflows/run-a-single-node-from-branch.yml +++ b/.github/workflows/run-a-single-node-from-branch.yml @@ -12,14 +12,11 @@ on: - mainnet - gnosis - sepolia - - goerli - chiado - holesky - op-mainnet - - op-goerli - op-sepolia - base-mainnet - - base-goerli - base-sepolia - energyweb - volta diff --git a/.github/workflows/update-config-files.yml b/.github/workflows/update-config-files.yml index da62bcbe67e..50d548f4b2d 100644 --- a/.github/workflows/update-config-files.yml +++ b/.github/workflows/update-config-files.yml @@ -27,14 +27,13 @@ jobs: run: | python3 scripts/syncSettings.py ${{ secrets.ETHERSCAN_API_KEY }} - name: Create pull request - uses: peter-evans/create-pull-request@v5.0.2 + uses: peter-evans/create-pull-request@v6.0.2 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.REPOSITORY_DISPATCH_TOKEN }} commit-message: Updating Fast Sync config files body: | Config files included: - mainnet.cfg - - goerli.cfg - gnosis.cfg - chiado.cfg - sepolia.cfg diff --git a/scripts/syncSettings.py b/scripts/syncSettings.py index 1c6d856d999..6c29ccd2eb8 100644 --- a/scripts/syncSettings.py +++ b/scripts/syncSettings.py @@ -24,11 +24,6 @@ "blockReduced": 1000, "multiplierRequirement": 1000 }, - "goerli": { - "url": "api-goerli.etherscan.io", - "blockReduced": 8192, - "multiplierRequirement": 30000 - }, "gnosis": { "url": "https://rpc.gnosischain.com", "blockReduced": 8192, diff --git a/scripts/wait-for-workflow-completed.sh b/scripts/wait-for-workflow-completed.sh index a724801b3c1..25c4453c302 100644 --- a/scripts/wait-for-workflow-completed.sh +++ b/scripts/wait-for-workflow-completed.sh @@ -43,7 +43,7 @@ else fi run_id=$(echo "$response" | \ jq -r --arg ref "$(echo "$REF" | sed 's/refs\/heads\///')" --arg current_time "$current_time" \ - '.workflow_runs[] | select(.head_branch == $ref and .created_at >= $current_time) | .id' | sort -r | head -n 1) + '.workflow_runs[] | select(.head_branch == $ref and .status == "in_progress") | .id' | sort -r | head -n 1) if [ -n "$run_id" ]; then echo "🎉 Workflow triggered! Run ID: $run_id" break diff --git a/src/Nethermind/Nethermind.Runner/configs/chiado.cfg b/src/Nethermind/Nethermind.Runner/configs/chiado.cfg index 014fab5ab0e..128bcd29ea1 100644 --- a/src/Nethermind/Nethermind.Runner/configs/chiado.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/chiado.cfg @@ -15,8 +15,8 @@ }, "Sync": { "FastSync": true, - "PivotNumber": 8260000, - "PivotHash": "0x980fc3d226c606ca126e06a34c3cbb4ff01be055309a7d4e9f29396096d6ef76", + "PivotNumber": 8980000, + "PivotHash": "0x28041f2136cdc117161183867fca0ba11cdd8161326c058f85110d68426c0591", "PivotTotalDifficulty": "231708131825107706987652208063906496124457284", "FastSyncCatchUpHeightDelta": "10000000000", "UseGethLimitsInFastBlocks": false @@ -42,4 +42,4 @@ 16 ] } -} +} \ No newline at end of file diff --git a/src/Nethermind/Nethermind.Runner/configs/energyweb.cfg b/src/Nethermind/Nethermind.Runner/configs/energyweb.cfg index 60549130106..bba3457e42e 100644 --- a/src/Nethermind/Nethermind.Runner/configs/energyweb.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/energyweb.cfg @@ -11,9 +11,9 @@ }, "Sync": { "FastSync": true, - "PivotNumber": 28480000, - "PivotHash": "0xa943b2caae19d30cd042825d85706c218d2ad2f48929651203d014cbb681e109", - "PivotTotalDifficulty": "9691241809908327439436908819656758661896925036", + "PivotNumber": 29170000, + "PivotHash": "0x55ccd80d4da56258c3f0a1520ae1d5d8b4702216aaf1666c15f4818eb0274cd8", + "PivotTotalDifficulty": "9926036643083774979226637298784678727800151617", "FastBlocks": true, "UseGethLimitsInFastBlocks": false, "FastSyncCatchUpHeightDelta": 10000000000 diff --git a/src/Nethermind/Nethermind.Runner/configs/exosama.cfg b/src/Nethermind/Nethermind.Runner/configs/exosama.cfg index 15355130f46..253754e3ad6 100644 --- a/src/Nethermind/Nethermind.Runner/configs/exosama.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/exosama.cfg @@ -11,9 +11,9 @@ }, "Sync": { "FastSync": true, - "PivotNumber": 8330000, - "PivotHash": "0x91e43722407af7296437a056c1d0f793e0650a535ef26dc88810767658f081fb", - "PivotTotalDifficulty": "2834552116451417400649910479906629201078673288", + "PivotNumber": 9050000, + "PivotHash": "0xe487072c3aaec2324b7864752f72e6d45b2340e4b9834db24ffca5787f9e09fc", + "PivotTotalDifficulty": "3079555420634493094343540197257502313325553287", "FastBlocks": true, "UseGethLimitsInFastBlocks": false, "FastSyncCatchUpHeightDelta": 10000000000 diff --git a/src/Nethermind/Nethermind.Runner/configs/gnosis.cfg b/src/Nethermind/Nethermind.Runner/configs/gnosis.cfg index 1b2f3e3d401..08b7c7d66e7 100644 --- a/src/Nethermind/Nethermind.Runner/configs/gnosis.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/gnosis.cfg @@ -12,8 +12,8 @@ }, "Sync": { "FastSync": true, - "PivotNumber": 32470000, - "PivotHash": "0x1a3039baa60728c734dfeea39c4e0d56c147121cff59271759892ffe1281981f", + "PivotNumber": 33160000, + "PivotHash": "0x8f5d84b15c370d5df88e8db271f8a29ea750c88faa1c8b45ddf24e36d165ec5b", "PivotTotalDifficulty": "8626000110427538733349499292577475819600160930", "FastBlocks": true, "UseGethLimitsInFastBlocks": false, diff --git a/src/Nethermind/Nethermind.Runner/configs/joc-mainnet.cfg b/src/Nethermind/Nethermind.Runner/configs/joc-mainnet.cfg index 5c1e7156614..238fea77ede 100644 --- a/src/Nethermind/Nethermind.Runner/configs/joc-mainnet.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/joc-mainnet.cfg @@ -12,9 +12,9 @@ "FastSync": true, "SnapSync": true, "FastBlocks": true, - "PivotNumber": 9690000, - "PivotHash": "0x6ce963fa2563a876edd1da9976ab1cbeb2fedcc1d8f6e1df8e2172e5a408f5b5", - "PivotTotalDifficulty": "19370447" + "PivotNumber": 10410000, + "PivotHash": "0x325aa1427f9cd25725ea7badc884e402643b0072e6b01552e5c38a0dedba52fa", + "PivotTotalDifficulty": "20799590" }, "Metrics": { "NodeName": "JOC-Mainnet" diff --git a/src/Nethermind/Nethermind.Runner/configs/joc-testnet.cfg b/src/Nethermind/Nethermind.Runner/configs/joc-testnet.cfg index 4a423737f5a..26e0200c24e 100644 --- a/src/Nethermind/Nethermind.Runner/configs/joc-testnet.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/joc-testnet.cfg @@ -11,9 +11,9 @@ "Sync": { "FastSync": true, "SnapSync": true, - "PivotNumber": 3300000, - "PivotHash": "0x58fbbcd0d0e8e5856c205385c922dd9e2b0b711060b001a960f327cf7b6608dc", - "PivotTotalDifficulty": "6599797" + "PivotNumber": 4020000, + "PivotHash": "0xa4c4afdc50e13bf34b8d04267fd84a403224ad26c716b63b5f1217438941bcce", + "PivotTotalDifficulty": "8039763" }, "Metrics": { "NodeName": "JOC-Testnet" @@ -27,4 +27,4 @@ "Merge": { "Enabled": false } -} +} \ No newline at end of file diff --git a/src/Nethermind/Nethermind.Runner/configs/mainnet.cfg b/src/Nethermind/Nethermind.Runner/configs/mainnet.cfg index ebc65a4ba38..1fffaed72c7 100644 --- a/src/Nethermind/Nethermind.Runner/configs/mainnet.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/mainnet.cfg @@ -9,8 +9,8 @@ "Sync": { "FastSync": true, "SnapSync": true, - "PivotNumber": 19240000, - "PivotHash": "0x2e9f726901799ce6f3f2aa69bc5eae6a439d89bf6e7966c9c4a37c895b6bfb07", + "PivotNumber": 19538000, + "PivotHash": "0x28247948adf97089cd7b5b56f4542983ac3d7887f56e77d39dd481468c9f3300", "PivotTotalDifficulty": "58750003716598352816469", "FastBlocks": true, "FastSyncCatchUpHeightDelta": "10000000000" diff --git a/src/Nethermind/Nethermind.Runner/configs/sepolia.cfg b/src/Nethermind/Nethermind.Runner/configs/sepolia.cfg index cbbdda97c63..aa5d195292e 100644 --- a/src/Nethermind/Nethermind.Runner/configs/sepolia.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/sepolia.cfg @@ -17,8 +17,8 @@ "FastSync": true, "SnapSync": true, "UseGethLimitsInFastBlocks": true, - "PivotNumber": 5300000, - "PivotHash": "0x92e5cd02dc0d6c878230d7dd38bae5064fa8e4caf8dfe8e7aef56be878cff2fa", + "PivotNumber": 5583000, + "PivotHash": "0xbc8cc7bdeb31087d0560948aecd14a4bd27bd32aaece666a2a192a011535ccca", "PivotTotalDifficulty": "17000018015853232", "FastSyncCatchUpHeightDelta": "10000000000" }, @@ -37,4 +37,4 @@ "Merge": { "Enabled": true } -} +} \ No newline at end of file diff --git a/src/Nethermind/Nethermind.Runner/configs/volta.cfg b/src/Nethermind/Nethermind.Runner/configs/volta.cfg index 732d011c6c1..6cdf1a50c27 100644 --- a/src/Nethermind/Nethermind.Runner/configs/volta.cfg +++ b/src/Nethermind/Nethermind.Runner/configs/volta.cfg @@ -15,9 +15,9 @@ }, "Sync": { "FastSync": true, - "PivotNumber": 26680000, - "PivotHash": "0x038403ed7351bf180066ea7b6396daec13e6bb13163334ac9fab8ee3de19d471", - "PivotTotalDifficulty": "9078733549450638205202834526279575881277928465", + "PivotNumber": 27190000, + "PivotHash": "0xcdc01b49c2bd25004fbb44d5cc484ee31ba9a15ec7030d6c4c0aeb3dae4824a4", + "PivotTotalDifficulty": "9252277556580316821569155576069777669119250823", "UseGethLimitsInFastBlocks": false, "FastSyncCatchUpHeightDelta": 10000000000 }, @@ -33,4 +33,4 @@ "Merge": { "Enabled": false } -} +} \ No newline at end of file diff --git a/src/Nethermind/Nethermind.Trie/Pruning/TinyTreePath.cs b/src/Nethermind/Nethermind.Trie/Pruning/TinyTreePath.cs index b0aa85ff870..bfe75943d3d 100644 --- a/src/Nethermind/Nethermind.Trie/Pruning/TinyTreePath.cs +++ b/src/Nethermind/Nethermind.Trie/Pruning/TinyTreePath.cs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LGPL-3.0-only using System; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Nethermind.Core.Crypto; @@ -11,20 +10,19 @@ namespace Nethermind.Trie; /// /// Like TreePath, but tiny. Fit in 8 byte, like a long. Can only represent 14 nibble. /// -public struct TinyTreePath +public readonly struct TinyTreePath : IEquatable { public const int MaxNibbleLength = 14; - long _data; + private readonly long _data; - // Eh.. readonly? - private Span AsSpan => MemoryMarshal.AsBytes(MemoryMarshal.CreateSpan(ref _data, 1)); + private ReadOnlySpan AsSpan => MemoryMarshal.AsBytes(MemoryMarshal.CreateReadOnlySpan(in _data, 1)); public TinyTreePath(in TreePath path) { if (path.Length > MaxNibbleLength) throw new InvalidOperationException("Unable to represent more than 14 nibble"); Span pathSpan = path.Path.BytesAsSpan; - Span selfSpan = AsSpan; + Span selfSpan = MemoryMarshal.AsBytes(MemoryMarshal.CreateSpan(ref _data, 1)); pathSpan[..7].CopyTo(selfSpan); selfSpan[7] = (byte)path.Length; } @@ -35,9 +33,13 @@ public TreePath ToTreePath() { ValueHash256 rawPath = Keccak.Zero; Span pathSpan = rawPath.BytesAsSpan; - Span selfSpan = AsSpan; + ReadOnlySpan selfSpan = AsSpan; selfSpan[..7].CopyTo(pathSpan); return new TreePath(rawPath, selfSpan[7]); } + + public bool Equals(TinyTreePath other) => _data == other._data; + public override bool Equals(object? obj) => obj is TinyTreePath other && Equals(other); + public override int GetHashCode() => _data.GetHashCode(); } diff --git a/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs b/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs index 896e7d193b3..fac765d85ba 100644 --- a/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs +++ b/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs @@ -254,11 +254,11 @@ public readonly void Dispose() // Track some of the persisted path hash. Used to be able to remove keys when it is replaced. // If null, disable removing key. - private LruCache<(Hash256?, TinyTreePath), ValueHash256>? _pastPathHash; + private LruCache? _pastPathHash; // Track ALL of the recently re-committed persisted nodes. This is so that we don't accidentally remove // recommitted persisted nodes (which will not get re-persisted). - private ConcurrentDictionary<(Hash256?, TinyTreePath, ValueHash256), long> _persistedLastSeens = new(); + private ConcurrentDictionary _persistedLastSeens = new(); private bool _lastPersistedReachedReorgBoundary; private Task _pruningTask = Task.CompletedTask; @@ -653,9 +653,9 @@ private bool SaveSnapshot() // If more than one candidate set, its a reorg, we can't remove node as persisted node may not be canonical candidateSets.Count == 1; - Dictionary<(Hash256?, TinyTreePath), Hash256?>? persistedHashes = + Dictionary? persistedHashes = shouldDeletePersistedNode - ? new Dictionary<(Hash256?, TinyTreePath), Hash256?>() + ? new Dictionary() : null; INodeStorage.WriteBatch writeBatch = _nodeStorage.StartWriteBatch(); @@ -672,7 +672,7 @@ private bool SaveSnapshot() writeBatch.Dispose(); deleteTask.Wait(); - foreach (KeyValuePair<(Hash256, TinyTreePath, ValueHash256), long> keyValuePair in _persistedLastSeens) + foreach (KeyValuePair keyValuePair in _persistedLastSeens) { if (IsNoLongerNeeded(keyValuePair.Value)) { @@ -692,7 +692,7 @@ private bool SaveSnapshot() return false; } - private void RemovePastKeys(Dictionary<(Hash256, TinyTreePath), Hash256?>? persistedHashes) + private void RemovePastKeys(Dictionary? persistedHashes) { if (persistedHashes == null) return; @@ -717,9 +717,9 @@ bool CanRemove(Hash256? address, TinyTreePath path, in TreePath fullPath, ValueH using INodeStorage.WriteBatch writeBatch = _nodeStorage.StartWriteBatch(); - void DoAct(KeyValuePair<(Hash256?, TinyTreePath), Hash256> keyValuePair) + void DoAct(KeyValuePair keyValuePair) { - (Hash256? addr, TinyTreePath path) key = keyValuePair.Key; + HashAndTinyPath key = keyValuePair.Key; if (_pastPathHash.TryGet((key.addr, key.path), out ValueHash256 prevHash)) { TreePath fullPath = key.path.ToTreePath(); // Micro op to reduce double convert @@ -731,10 +731,10 @@ void DoAct(KeyValuePair<(Hash256?, TinyTreePath), Hash256> keyValuePair) } } - ActionBlock> actionBlock = - new ActionBlock>(DoAct); + ActionBlock> actionBlock = + new ActionBlock>(DoAct); - foreach (KeyValuePair<(Hash256?, TinyTreePath), Hash256> keyValuePair in persistedHashes) + foreach (KeyValuePair keyValuePair in persistedHashes) { actionBlock.Post(keyValuePair); } @@ -938,7 +938,7 @@ private void PersistBlockCommitSet( Hash256? address, BlockCommitSet commitSet, INodeStorage.WriteBatch writeBatch, - Dictionary<(Hash256?, TinyTreePath), Hash256?>? persistedHashes = null, + Dictionary? persistedHashes = null, WriteFlags writeFlags = WriteFlags.None ) { @@ -1245,5 +1245,38 @@ public bool HasRoot(Hash256 stateRoot) return true; } + + private readonly struct HashAndTinyPath(Hash256? hash, TinyTreePath path) : IEquatable + { + public readonly Hash256? addr = hash; + public readonly TinyTreePath path = path; + + public static implicit operator HashAndTinyPath((Hash256? hash, TinyTreePath path) value) => new HashAndTinyPath(value.hash, value.path); + + public bool Equals(HashAndTinyPath other) => addr == other.addr && path.Equals(other.path); + public override bool Equals(object? obj) => obj is HashAndTinyPath other && Equals(other); + public override int GetHashCode() => (int)BitOperations.Crc32C((uint)path.GetHashCode(), (uint)(addr?.GetHashCode() ?? 0)); + } + + private readonly struct HashAndTinyPathAndHash(Hash256? hash, TinyTreePath path, ValueHash256 valueHash) : IEquatable + { + public readonly Hash256? hash = hash; + public readonly TinyTreePath path = path; + public readonly ValueHash256 valueHash = valueHash; + + public static implicit operator HashAndTinyPathAndHash((Hash256? hash, TinyTreePath path, ValueHash256 valueHash) value) => new HashAndTinyPathAndHash(value.hash, value.path, value.valueHash); + + public bool Equals(HashAndTinyPathAndHash other) => hash == other.hash && path.Equals(other.path) && valueHash.Equals(in other.valueHash); + public override bool Equals(object? obj) => obj is HashAndTinyPath other && Equals(other); + public override int GetHashCode() + { + uint hashCode = BitOperations.Crc32C((uint)valueHash.GetHashCode(), (uint)path.GetHashCode()); + if (hash is not null) + { + hashCode = BitOperations.Crc32C(hashCode, (uint)hash.GetHashCode()); + } + return (int)hashCode; + } + } } }