-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* - Added Eip4788 to ReleaseSpecs - Added Eip4788 wiring to ChainSpecs * - Added passing state to Precompiles - Added Eip4788 stateful precompile * - Adds consensus logic of Eip4788 * - Tests update * - Minor fixes, Missing migration code * - Test improvements * - Test progress, Cleanup * - More tests fixes * - Whitespace fixes * - Attempt fix failing JsonRpc.Tests * - Fix whistespace check failure * - move setup precompile 4788 to instance method - make Instance field in Precompile static generic to match class type * - fix some build issue * - fixed failing tests * - Apply changes * - Fix failing tests * - ws fixes * - Introduce IBeaconBlockRootHandler * - Removed unnecessary "null" default value * - Fixed some naming inconsistensies * - Fix ws problems * - Fix default behavior of beaconBlockRootHandler argument in BlockProcessor.ctor * - fix * - Fix ws * small improvements * Add EngineApiVersions * - refactor PayloadAttributes.Validate * - ws fix * Init beacon root precompile state for genesis (#5982) * - Applied suggested changes * Fix merge * Fix name, whitespaces * Fix expected code * Remove balance set * genesis.json beacon root. * jsonrpc: fix parentBeaconBlockRoot naming, add isEip4788. * Catch args issue * - ignore 0x0b from precompile checks * Ignore for genesis * Don't count RLP wrapper, when calc tx size for pooled txs msg * Revert "Trie recovery (#5861)" This reverts commit a099f0f. * Use main EIP to detect fork * Adding some workarounds * Add system acc * Another workaround * What if zero bloc * Another idea * Another idea * + * + * Another attempt * 1) What * No genesis * 2) H * Revert "Revert "Trie recovery (#5861)"" This reverts commit 1425d3c. * Adhere a formal rule of encoding * Decline payloads with v3 fields * 2) The * Fix 2) The * clarification comment * fix typo in file name * Add RLP testing scenarios * FIx tracer type * - 4788 cleanup * - Make Eip4788 settabe from chainspec * Fix merge * - other tests fixes * Working on review comments * fix build * remove BeaconBlock from precompile list * - moved ParentBeaconBlockRoot type from byte[] to Keccak - removed commented precompile line from VirtualMachine * - fixed some tests - removed deprectated tests * - more cleanup * - adjusted expected size in blob tx size tests * - ws fix * Default addr * more cosmetic stuff * Remove worldState parameter * Revert "more cosmetic stuff" This reverts commit 872bce8. --------- Co-authored-by: Demuirgos <[email protected]> Co-authored-by: lukasz.rozmej <[email protected]> Co-authored-by: Alexey <[email protected]> Co-authored-by: spencer-tb <[email protected]> Co-authored-by: smartprogrammer <[email protected]>
- Loading branch information
1 parent
84bbb25
commit 055c64b
Showing
96 changed files
with
625 additions
and
187 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
1 change: 0 additions & 1 deletion
1
src/Nethermind/Nethermind.AuRa.Test/AuRaContractGasLimitOverrideTests.cs
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
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
35 changes: 35 additions & 0 deletions
35
src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs
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,35 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using Nethermind.Core.Specs; | ||
using Nethermind.Core; | ||
using Nethermind.Int256; | ||
using Nethermind.State; | ||
using Nethermind.Core.Crypto; | ||
using Nethermind.Core.Extensions; | ||
|
||
namespace Nethermind.Consensus.BeaconBlockRoot; | ||
public class BeaconBlockRootHandler : IBeaconBlockRootHandler | ||
{ | ||
public static UInt256 HISTORICAL_ROOTS_LENGTH = 98304; | ||
private static readonly Address DefaultPbbrContractAddress = Address.FromNumber(0x0b); | ||
|
||
public void ApplyContractStateChanges(Block block, IReleaseSpec spec, IWorldState stateProvider) | ||
{ | ||
if (!spec.IsBeaconBlockRootAvailable || | ||
block.IsGenesis || | ||
block.Header.ParentBeaconBlockRoot is null) return; | ||
|
||
UInt256 timestamp = (UInt256)block.Timestamp; | ||
Keccak parentBeaconBlockRoot = block.ParentBeaconBlockRoot; | ||
|
||
UInt256.Mod(timestamp, HISTORICAL_ROOTS_LENGTH, out UInt256 timestampReduced); | ||
UInt256 rootIndex = timestampReduced + HISTORICAL_ROOTS_LENGTH; | ||
|
||
StorageCell tsStorageCell = new(spec.Eip4788ContractAddress ?? DefaultPbbrContractAddress, timestampReduced); | ||
StorageCell brStorageCell = new(spec.Eip4788ContractAddress ?? DefaultPbbrContractAddress, rootIndex); | ||
|
||
stateProvider.Set(tsStorageCell, Bytes.WithoutLeadingZeros(timestamp.ToBigEndian()).ToArray()); | ||
stateProvider.Set(brStorageCell, Bytes.WithoutLeadingZeros(parentBeaconBlockRoot.Bytes).ToArray()); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/IBeaconBlockRootHandler.cs
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,17 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.Core; | ||
using Nethermind.State; | ||
|
||
namespace Nethermind.Consensus.BeaconBlockRoot; | ||
public interface IBeaconBlockRootHandler | ||
{ | ||
void ApplyContractStateChanges(Block block, IReleaseSpec spec, IWorldState state); | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/Nethermind/Nethermind.Consensus.AuRa/BeaconBlockRoot/NullBeaconBlockRootHandler.cs
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,22 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Nethermind.Consensus.BeaconBlockRoot; | ||
using Nethermind.Core; | ||
using Nethermind.Core.Specs; | ||
using Nethermind.State; | ||
|
||
namespace Nethermind.Consensus.AuRa.BeaconBlockRoot; | ||
internal class NullBeaconBlockRootHandler : IBeaconBlockRootHandler | ||
{ | ||
public void ApplyContractStateChanges(Block block, IReleaseSpec spec, IWorldState state) | ||
{ | ||
} | ||
|
||
public static IBeaconBlockRootHandler Instance { get; } = new NullBeaconBlockRootHandler(); | ||
} |
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,11 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
namespace Nethermind.Consensus; | ||
|
||
public static class EngineApiVersions | ||
{ | ||
public const int Paris = 1; | ||
public const int Shanghai = 2; | ||
public const int Cancun = 3; | ||
} |
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
Oops, something went wrong.