Skip to content

Commit

Permalink
Merge branch 'master' into keccak-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams authored Sep 19, 2024
2 parents ce44b4c + 15ded8a commit a2a0155
Show file tree
Hide file tree
Showing 64 changed files with 716 additions and 416 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-solutions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,14 @@ jobs:
submodules: ${{ matrix.solution == 'EthereumTests' }}
- name: Set up .NET
uses: actions/setup-dotnet@v4
- name: Cache dotnet packages
id: cache-dotnet
uses: actions/cache@v4
with:
# nuget cache files are stored in `~/.nuget/packages/` on Linux/macOS
path: ~/.nuget/packages/
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
restore-keys: |
${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
- name: Build ${{ matrix.solution }}.sln
run: dotnet build src/Nethermind/${{ matrix.solution }}.sln -c ${{ matrix.config }}
6 changes: 6 additions & 0 deletions .github/workflows/nethermind-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ jobs:
uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
- name: Cache dotnet packages
id: cache-dotnet
uses: actions/cache/restore@v4
with:
path: ~/.nuget/packages/
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}
- name: ${{ matrix.project }}
id: test
run: |
Expand Down
69 changes: 22 additions & 47 deletions .github/workflows/update-config-files.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: "[UPDATE] Config files (fast sync settings)"
name: Update fast sync settings

on:
schedule:
- cron: "0 0 * * 0"
- cron: '0 0 * * 0'
workflow_dispatch:

permissions:
Expand All @@ -11,58 +11,33 @@ permissions:

jobs:
update-configs:
if: github.repository_owner == 'NethermindEth'
name: Update fast sync settings in config files
name: Update fast sync settings
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Authenticate App
id: gh-app
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
uses: actions/checkout@v4
- name: Install dependencies
run: |
pip3 install setuptools
pip3 install emoji
- name: Update config files
run: |
python3 scripts/syncSettings.py ${{ secrets.ETHERSCAN_API_KEY }}
- name: Create pull request
uses: peter-evans/create-pull-request@v6.0.2
run: python3 scripts/syncSettings.py ${{ secrets.ETHERSCAN_API_KEY }}
- name: Create GitHub app token
id: gh-app
uses: actions/create-github-app-token@v1
with:
token: ${{ steps.gh-app.outputs.token }}
commit-message: Updating Fast Sync config files
body: |
Config files included:
- mainnet.cfg
- gnosis.cfg
- chiado.cfg
- sepolia.cfg
- energyweb.cfg
- volta.cfg
- exosama.cfg
- joc-mainnet.cfg
- joc-testnet.cfg
Properties refreshed:
- PivotNumber
- PivotHash
- PivotTotalDifficulty
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
title: "Update Fast Sync configuration in Nethermind repository"
labels: configs
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
committer: GitHub <noreply@github.com>
branch: configs-update
branch-suffix: short-commit-hash
base: master
- name: Check outputs
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create a pull request
env:
GH_TOKEN: ${{ steps.gh-app.outputs.token }}
run: |
echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}"
head_branch=feature/fast-sync-config-${{ github.run_number }}-${{ github.run_attempt }}
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git checkout -b $head_branch
git add -A
git commit -am "Auto-update fast sync settings"
git push origin $head_branch
gh pr create -B master -H $head_branch -t "Auto-update fast sync settings" \
-b "Updated fast sync settings in the configuration files" -l configuration -l sync
43 changes: 43 additions & 0 deletions .github/workflows/update-fast-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update fast sync settings

on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update-configs:
name: Update fast sync settings
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
pip3 install setuptools
pip3 install emoji
- name: Update config files
run: python3 scripts/syncSettings.py ${{ secrets.ETHERSCAN_API_KEY }}
- name: Create GitHub app token
id: gh-app
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create a pull request
env:
GH_TOKEN: ${{ steps.gh-app.outputs.token }}
run: |
head_branch=feature/fast-sync-config-${{ github.run_number }}-${{ github.run_attempt }}
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git checkout -b $head_branch
git add -A
git commit -am "Auto-update fast sync settings"
git push origin $head_branch
gh pr create -B master -H $head_branch -t "Auto-update fast sync settings" \
-b "Updated fast sync settings in config files" -l configuration -l sync
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Nethermind documentation is available at [docs.nethermind.io](https://docs.nethe

### Supported networks

**`Mainnet`** **`Goerli`** **`Sepolia`** **`Holesky`** **`Gnosis (xDai)`** **`Chiado`** **`OP Mainnet`** **`OP Sepolia`** **`Base Mainnet`** **`Base Sepolia`** **`Energy Web`** **`Volta`**
**`Mainnet`** **`Sepolia`** **`Holesky`** **`Gnosis`** **`Chiado`** **`OP Mainnet`** **`OP Sepolia`** **`Base Mainnet`** **`Base Sepolia`** **`Energy Web`** **`Volta`**

## Download and run

Expand Down
20 changes: 20 additions & 0 deletions scripts/syncSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@
"url": "https://rpc-1.testnet.japanopenchain.org:8545",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"base-mainnet": {
"url": "https://mainnet.base.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"base-sepolia": {
"url": "https://sepolia.base.org",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"op-mainnet": {
"url": "https://mainnet.optimism.io",
"blockReduced": 8192,
"multiplierRequirement": 10000
},
"op-sepolia": {
"url": "https://sepolia.optimism.io",
"blockReduced": 8192,
"multiplierRequirement": 10000
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Copyright>Demerzel Solutions Limited</Copyright>
<Product>Nethermind</Product>
<SourceRevisionId Condition="'$(Commit)' != ''">$(Commit)</SourceRevisionId>
<VersionPrefix>1.28.0</VersionPrefix>
<VersionPrefix>1.29.0</VersionPrefix>
<VersionSuffix>unstable</VersionSuffix>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,49 @@ public class BeaconBlockRootHandler(ITransactionProcessor processor) : IBeaconBl
{
private const long GasLimit = 30_000_000L;

public void StoreBeaconRoot(Block block, IReleaseSpec spec)
public (Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, bool includeStorageCells = true)
{
BlockHeader? header = block.Header;
var canInsertBeaconRoot = spec.IsBeaconBlockRootAvailable
bool canInsertBeaconRoot = spec.IsBeaconBlockRootAvailable
&& !header.IsGenesis
&& header.ParentBeaconBlockRoot is not null;

if (canInsertBeaconRoot)
Address? eip4788ContractAddress = canInsertBeaconRoot ?
spec.Eip4788ContractAddress ?? Eip4788Constants.BeaconRootsAddress :
null;

if (eip4788ContractAddress is null)
{
return (null, null);
}

var builder = new AccessList.Builder()
.AddAddress(eip4788ContractAddress);

if (includeStorageCells)
{
builder.AddStorage(block.Timestamp % 8191);
}

return (eip4788ContractAddress, builder.Build());
}

public void StoreBeaconRoot(Block block, IReleaseSpec spec)
{
(Address? toAddress, AccessList? accessList) = BeaconRootsAccessList(block, spec, includeStorageCells: false);

if (toAddress is not null)
{
Address beaconRootsAddress = spec.Eip4788ContractAddress ?? Eip4788Constants.BeaconRootsAddress;
BlockHeader? header = block.Header;
Transaction transaction = new()
{
Value = UInt256.Zero,
Data = header.ParentBeaconBlockRoot.Bytes.ToArray(),
To = beaconRootsAddress,
To = toAddress,
SenderAddress = Address.SystemUser,
GasLimit = GasLimit,
GasPrice = UInt256.Zero,
AccessList = new AccessList.Builder().AddAddress(beaconRootsAddress).Build()
AccessList = accessList
};

transaction.Hash = transaction.CalculateHash();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Core;
using Nethermind.Core.Eip2930;
using Nethermind.Core.Specs;

namespace Nethermind.Blockchain.BeaconBlockRoot;
public interface IBeaconBlockRootHandler
{
(Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, bool includeStorageCells = true);
void StoreBeaconRoot(Block block, IReleaseSpec spec);
}
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Blockchain/Blocks/BlockStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class BlockStore : IBlockStore
private readonly BlockDecoder _blockDecoder = new();
public const int CacheSize = 128 + 32;

private readonly LruCache<ValueHash256, Block>
_blockCache = new(CacheSize, CacheSize, "blocks");
private readonly ClockCache<ValueHash256, Block>
_blockCache = new(CacheSize);
private readonly long? _maxSize;

public BlockStore(IDb blockDb, long? maxSize = null)
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Blockchain/Headers/HeaderStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class HeaderStore : IHeaderStore
private readonly IDb _headerDb;
private readonly IDb _blockNumberDb;
private readonly HeaderDecoder _headerDecoder = new();
private readonly LruCache<ValueHash256, BlockHeader> _headerCache =
new(CacheSize, CacheSize, "headers");
private readonly ClockCache<ValueHash256, BlockHeader> _headerCache =
new(CacheSize);

public HeaderStore(IDb headerDb, IDb blockNumberDb)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public long MigratedBlockNumber
set
{
_migratedBlockNumber = value;
_defaultColumn.Set(MigrationBlockNumberKey, MigratedBlockNumber.ToBigEndianByteArrayWithoutLeadingZeros());
_defaultColumn.PutSpan(MigrationBlockNumberKey.Bytes, value.ToBigEndianSpanWithoutLeadingZeros(out _));
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/Nethermind/Nethermind.Config/BlocksConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public class BlocksConfig : IBlocksConfig

public bool PreWarmStateOnBlockProcessing { get; set; } = true;

public int BlockProductionTimeoutMs { get; set; } = 4000;
public int BlockProductionTimeoutMs { get; set; } = 4_000;

public int GenesisTimeoutMs { get; set; } = 40_000;

public string ExtraData
{
Expand Down
3 changes: 3 additions & 0 deletions src/Nethermind/Nethermind.Config/IBlocksConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ public interface IBlocksConfig : IConfig
[ConfigItem(Description = "Block Production timeout, in milliseconds.", DefaultValue = "4000")]
int BlockProductionTimeoutMs { get; set; }

[ConfigItem(Description = "Genesis block load timeout, in milliseconds.", DefaultValue = "40000")]
int GenesisTimeoutMs { get; set; }

byte[] GetExtraDataBytes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void SetValidators(long finalizingBlockNumber, Address[] validators)
var validatorInfo = new ValidatorInfo(finalizingBlockNumber, _latestFinalizedValidatorsBlockNumber, validators);
var rlp = Rlp.Encode(validatorInfo);
_db.Set(GetKey(finalizingBlockNumber), rlp.Bytes);
_db.Set(LatestFinalizedValidatorsBlockNumberKey, finalizingBlockNumber.ToBigEndianByteArrayWithoutLeadingZeros());
_db.PutSpan(LatestFinalizedValidatorsBlockNumberKey.Bytes, finalizingBlockNumber.ToBigEndianSpanWithoutLeadingZeros(out _));
_latestFinalizedValidatorsBlockNumber = finalizingBlockNumber;
_latestValidatorInfo = validatorInfo;
Metrics.ValidatorsCount = validators.Length;
Expand Down
Loading

0 comments on commit a2a0155

Please sign in to comment.