Skip to content

Commit

Permalink
Merge branch 'master' into release/1.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilchodola committed Mar 29, 2024
2 parents 65befbd + b3234f9 commit e8896e5
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 58 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/run-a-single-node-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/update-config-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions scripts/syncSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion scripts/wait-for-workflow-completed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/chiado.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"Sync": {
"FastSync": true,
"PivotNumber": 8260000,
"PivotHash": "0x980fc3d226c606ca126e06a34c3cbb4ff01be055309a7d4e9f29396096d6ef76",
"PivotNumber": 8980000,
"PivotHash": "0x28041f2136cdc117161183867fca0ba11cdd8161326c058f85110d68426c0591",
"PivotTotalDifficulty": "231708131825107706987652208063906496124457284",
"FastSyncCatchUpHeightDelta": "10000000000",
"UseGethLimitsInFastBlocks": false
Expand All @@ -42,4 +42,4 @@
16
]
}
}
}
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/energyweb.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/exosama.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Runner/configs/gnosis.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
},
"Sync": {
"FastSync": true,
"PivotNumber": 32470000,
"PivotHash": "0x1a3039baa60728c734dfeea39c4e0d56c147121cff59271759892ffe1281981f",
"PivotNumber": 33160000,
"PivotHash": "0x8f5d84b15c370d5df88e8db271f8a29ea750c88faa1c8b45ddf24e36d165ec5b",
"PivotTotalDifficulty": "8626000110427538733349499292577475819600160930",
"FastBlocks": true,
"UseGethLimitsInFastBlocks": false,
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/joc-mainnet.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions src/Nethermind/Nethermind.Runner/configs/joc-testnet.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -27,4 +27,4 @@
"Merge": {
"Enabled": false
}
}
}
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Runner/configs/mainnet.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"Sync": {
"FastSync": true,
"SnapSync": true,
"PivotNumber": 19240000,
"PivotHash": "0x2e9f726901799ce6f3f2aa69bc5eae6a439d89bf6e7966c9c4a37c895b6bfb07",
"PivotNumber": 19538000,
"PivotHash": "0x28247948adf97089cd7b5b56f4542983ac3d7887f56e77d39dd481468c9f3300",
"PivotTotalDifficulty": "58750003716598352816469",
"FastBlocks": true,
"FastSyncCatchUpHeightDelta": "10000000000"
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Runner/configs/sepolia.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"FastSync": true,
"SnapSync": true,
"UseGethLimitsInFastBlocks": true,
"PivotNumber": 5300000,
"PivotHash": "0x92e5cd02dc0d6c878230d7dd38bae5064fa8e4caf8dfe8e7aef56be878cff2fa",
"PivotNumber": 5583000,
"PivotHash": "0xbc8cc7bdeb31087d0560948aecd14a4bd27bd32aaece666a2a192a011535ccca",
"PivotTotalDifficulty": "17000018015853232",
"FastSyncCatchUpHeightDelta": "10000000000"
},
Expand All @@ -37,4 +37,4 @@
"Merge": {
"Enabled": true
}
}
}
8 changes: 4 additions & 4 deletions src/Nethermind/Nethermind.Runner/configs/volta.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
},
"Sync": {
"FastSync": true,
"PivotNumber": 26680000,
"PivotHash": "0x038403ed7351bf180066ea7b6396daec13e6bb13163334ac9fab8ee3de19d471",
"PivotTotalDifficulty": "9078733549450638205202834526279575881277928465",
"PivotNumber": 27190000,
"PivotHash": "0xcdc01b49c2bd25004fbb44d5cc484ee31ba9a15ec7030d6c4c0aeb3dae4824a4",
"PivotTotalDifficulty": "9252277556580316821569155576069777669119250823",
"UseGethLimitsInFastBlocks": false,
"FastSyncCatchUpHeightDelta": 10000000000
},
Expand All @@ -33,4 +33,4 @@
"Merge": {
"Enabled": false
}
}
}
16 changes: 9 additions & 7 deletions src/Nethermind/Nethermind.Trie/Pruning/TinyTreePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -11,20 +10,19 @@ namespace Nethermind.Trie;
/// <summary>
/// Like TreePath, but tiny. Fit in 8 byte, like a long. Can only represent 14 nibble.
/// </summary>
public struct TinyTreePath
public readonly struct TinyTreePath : IEquatable<TinyTreePath>
{
public const int MaxNibbleLength = 14;

long _data;
private readonly long _data;

// Eh.. readonly?
private Span<byte> AsSpan => MemoryMarshal.AsBytes(MemoryMarshal.CreateSpan(ref _data, 1));
private ReadOnlySpan<byte> 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<byte> pathSpan = path.Path.BytesAsSpan;
Span<byte> selfSpan = AsSpan;
Span<byte> selfSpan = MemoryMarshal.AsBytes(MemoryMarshal.CreateSpan(ref _data, 1));
pathSpan[..7].CopyTo(selfSpan);
selfSpan[7] = (byte)path.Length;
}
Expand All @@ -35,9 +33,13 @@ public TreePath ToTreePath()
{
ValueHash256 rawPath = Keccak.Zero;
Span<byte> pathSpan = rawPath.BytesAsSpan;
Span<byte> selfSpan = AsSpan;
ReadOnlySpan<byte> 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();
}
57 changes: 45 additions & 12 deletions src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HashAndTinyPath, ValueHash256>? _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<HashAndTinyPathAndHash, long> _persistedLastSeens = new();

private bool _lastPersistedReachedReorgBoundary;
private Task _pruningTask = Task.CompletedTask;
Expand Down Expand Up @@ -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<HashAndTinyPath, Hash256?>? persistedHashes =
shouldDeletePersistedNode
? new Dictionary<(Hash256?, TinyTreePath), Hash256?>()
? new Dictionary<HashAndTinyPath, Hash256?>()
: null;

INodeStorage.WriteBatch writeBatch = _nodeStorage.StartWriteBatch();
Expand All @@ -672,7 +672,7 @@ private bool SaveSnapshot()
writeBatch.Dispose();
deleteTask.Wait();

foreach (KeyValuePair<(Hash256, TinyTreePath, ValueHash256), long> keyValuePair in _persistedLastSeens)
foreach (KeyValuePair<HashAndTinyPathAndHash, long> keyValuePair in _persistedLastSeens)
{
if (IsNoLongerNeeded(keyValuePair.Value))
{
Expand All @@ -692,7 +692,7 @@ private bool SaveSnapshot()
return false;
}

private void RemovePastKeys(Dictionary<(Hash256, TinyTreePath), Hash256?>? persistedHashes)
private void RemovePastKeys(Dictionary<HashAndTinyPath, Hash256?>? persistedHashes)
{
if (persistedHashes == null) return;

Expand All @@ -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<HashAndTinyPath, Hash256> 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
Expand All @@ -731,10 +731,10 @@ void DoAct(KeyValuePair<(Hash256?, TinyTreePath), Hash256> keyValuePair)
}
}

ActionBlock<KeyValuePair<(Hash256?, TinyTreePath), Hash256>> actionBlock =
new ActionBlock<KeyValuePair<(Hash256?, TinyTreePath), Hash256>>(DoAct);
ActionBlock<KeyValuePair<HashAndTinyPath, Hash256>> actionBlock =
new ActionBlock<KeyValuePair<HashAndTinyPath, Hash256>>(DoAct);

foreach (KeyValuePair<(Hash256?, TinyTreePath), Hash256> keyValuePair in persistedHashes)
foreach (KeyValuePair<HashAndTinyPath, Hash256> keyValuePair in persistedHashes)
{
actionBlock.Post(keyValuePair);
}
Expand Down Expand Up @@ -938,7 +938,7 @@ private void PersistBlockCommitSet(
Hash256? address,
BlockCommitSet commitSet,
INodeStorage.WriteBatch writeBatch,
Dictionary<(Hash256?, TinyTreePath), Hash256?>? persistedHashes = null,
Dictionary<HashAndTinyPath, Hash256?>? persistedHashes = null,
WriteFlags writeFlags = WriteFlags.None
)
{
Expand Down Expand Up @@ -1245,5 +1245,38 @@ public bool HasRoot(Hash256 stateRoot)

return true;
}

private readonly struct HashAndTinyPath(Hash256? hash, TinyTreePath path) : IEquatable<HashAndTinyPath>
{
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<HashAndTinyPathAndHash>
{
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;
}
}
}
}

0 comments on commit e8896e5

Please sign in to comment.