Skip to content

Commit

Permalink
Implement Ecotone (#6820)
Browse files Browse the repository at this point in the history
  • Loading branch information
deffrian authored Mar 28, 2024
1 parent 7059b45 commit a72375f
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 21 deletions.
6 changes: 6 additions & 0 deletions src/Nethermind/Chains/base-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
"eip3529Transition": "0x0",
"eip3541Transition": "0x0",

"eip1153TransitionTimestamp": "0x65F23E01",
"eip4788TransitionTimestamp": "0x65F23E01",
"eip4844TransitionTimestamp": "0x65F23E01",
"eip5656TransitionTimestamp": "0x65F23E01",
"eip6780TransitionTimestamp": "0x65F23E01",

"terminalTotalDifficulty": "0"
},
"genesis": {
Expand Down
6 changes: 6 additions & 0 deletions src/Nethermind/Chains/base-sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
"eip3855TransitionTimestamp": "0x6553a790",
"eip3860TransitionTimestamp": "0x6553a790",

"eip1153TransitionTimestamp": "0x65D62C10",
"eip4788TransitionTimestamp": "0x65D62C10",
"eip4844TransitionTimestamp": "0x65D62C10",
"eip5656TransitionTimestamp": "0x65D62C10",
"eip6780TransitionTimestamp": "0x65D62C10",

"terminalTotalDifficulty": "0"
},
"genesis": {
Expand Down
14 changes: 14 additions & 0 deletions src/Nethermind/Chains/op-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
"eip3529Transition": "0x645C277",
"eip3541Transition": "0x645C277",

"eip1153TransitionTimestamp": "0x65F23E01",
"eip4788TransitionTimestamp": "0x65F23E01",
"eip4844TransitionTimestamp": "0x65F23E01",
"eip5656TransitionTimestamp": "0x65F23E01",
"eip6780TransitionTimestamp": "0x65F23E01",

"terminalTotalDifficulty": "0"
},
"genesis": {
Expand All @@ -72,6 +78,14 @@
"stateRoot": "0xeddb4c1786789419153a27c4c80ff44a2226b6eda04f7e22ce5bae892ea568eb"
},
"nodes": [
"enode://ca2774c3c401325850b2477fd7d0f27911efbf79b1e8b335066516e2bd8c4c9e0ba9696a94b1cb030a88eac582305ff55e905e64fb77fe0edcd70a4e5296d3ec@34.65.175.185:30305",
"enode://dd751a9ef8912be1bfa7a5e34e2c3785cc5253110bd929f385e07ba7ac19929fb0e0c5d93f77827291f4da02b2232240fbc47ea7ce04c46e333e452f8656b667@34.65.107.0:30305",
"enode://c5d289b56a77b6a2342ca29956dfd07aadf45364dde8ab20d1dc4efd4d1bc6b4655d902501daea308f4d8950737a4e93a4dfedd17b49cd5760ffd127837ca965@34.65.202.239:30305",
"enode://87a32fd13bd596b2ffca97020e31aef4ddcc1bbd4b95bb633d16c1329f654f34049ed240a36b449fda5e5225d70fe40bc667f53c304b71f8e68fc9d448690b51@3.231.138.188:30301",
"enode://ca21ea8f176adb2e229ce2d700830c844af0ea941a1d8152a9513b966fe525e809c3a6c73a2c18a12b74ed6ec4380edf91662778fe0b79f6a591236e49e176f9@184.72.129.189:30301",
"enode://acf4507a211ba7c1e52cdf4eef62cdc3c32e7c9c47998954f7ba024026f9a6b2150cd3f0b734d9c78e507ab70d59ba61dfe5c45e1078c7ad0775fb251d7735a2@3.220.145.177:30301",
"enode://8a5a5006159bf079d06a04e5eceab2a1ce6e0f721875b2a9c96905336219dbe14203d38f70f3754686a6324f786c2f9852d8c0dd3adac2d080f4db35efc678c5@3.231.11.52:30301",
"enode://cdadbe835308ad3557f9a1de8db411da1a260a98f8421d62da90e71da66e55e98aaa8e90aa7ce01b408a54e4bd2253d701218081ded3dbe5efbbc7b41d7cef79@54.198.153.150:30301"
],
"accounts": {
"0x0000000000000000000000000000000000000001": {
Expand Down
13 changes: 13 additions & 0 deletions src/Nethermind/Chains/op-sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
"eip3855TransitionTimestamp": "0x6553a790",
"eip3860TransitionTimestamp": "0x6553a790",

"eip1153TransitionTimestamp": "0x65D62C10",
"eip4788TransitionTimestamp": "0x65D62C10",
"eip4844TransitionTimestamp": "0x65D62C10",
"eip5656TransitionTimestamp": "0x65D62C10",
"eip6780TransitionTimestamp": "0x65D62C10",

"terminalTotalDifficulty": "0"
},
"genesis": {
Expand All @@ -74,6 +80,13 @@
"baseFeePerGas": "0x3b9aca00",
"gasLimit": "0x1c9c380"
},
"nodes": [
"enode://2bd2e657bb3c8efffb8ff6db9071d9eb7be70d7c6d7d980ff80fc93b2629675c5f750bc0a5ef27cd788c2e491b8795a7e9a4a6e72178c14acc6753c0e5d77ae4@34.65.205.244:30305",
"enode://db8e1cab24624cc62fc35dbb9e481b88a9ef0116114cd6e41034c55b5b4f18755983819252333509bd8e25f6b12aadd6465710cd2e956558faf17672cce7551f@34.65.173.88:30305",
"enode://bfda2e0110cfd0f4c9f7aa5bf5ec66e6bd18f71a2db028d36b8bf8b0d6fdb03125c1606a6017b31311d96a36f5ef7e1ad11604d7a166745e6075a715dfa67f8a@34.65.229.245:30305",
"enode://548f715f3fc388a7c917ba644a2f16270f1ede48a5d88a4d14ea287cc916068363f3092e39936f1a3e7885198bef0e5af951f1d7b1041ce8ba4010917777e71f@18.210.176.114:30301",
"enode://6f10052847a966a725c9f4adf6716f9141155b99a0fb487fea3f51498f4c2a2cb8d534e680ee678f9447db85b93ff7c74562762c3714783a7233ac448603b25f@107.21.251.55:30301"
],
"accounts": {
"0000000000000000000000000000000000000001": {
"builtin": {
Expand Down
23 changes: 22 additions & 1 deletion src/Nethermind/Nethermind.Optimism/IOptimismEngineRpcModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System.Threading.Tasks;
using Nethermind.Core.Crypto;
using Nethermind.JsonRpc;
using Nethermind.JsonRpc.Modules;
using Nethermind.Merge.Plugin;
using Nethermind.Merge.Plugin.Data;

namespace Nethermind.Optimism;
Expand Down Expand Up @@ -48,4 +48,25 @@ public interface IOptimismEngineRpcModule : IRpcModule
IsSharable = true,
IsImplemented = true)]
Task<ResultWrapper<PayloadStatusV1>> engine_newPayloadV2(ExecutionPayload executionPayload);

[JsonRpcMethod(
Description =
"Verifies the payload according to the execution environment rules and returns the verification status and hash of the last valid block.",
IsSharable = true,
IsImplemented = true)]
Task<ResultWrapper<ForkchoiceUpdatedV1Result>> engine_forkchoiceUpdatedV3(
ForkchoiceStateV1 forkchoiceState, OptimismPayloadAttributes? payloadAttributes = null);

[JsonRpcMethod(
Description = "Returns the most recent version of an execution payload with respect to the transaction set contained by the mempool.",
IsSharable = true,
IsImplemented = true)]
Task<ResultWrapper<GetPayloadV3Result?>> engine_getPayloadV3(byte[] payloadId);

[JsonRpcMethod(
Description = "Verifies the payload according to the execution environment rules and returns the verification status and hash of the last valid block.",
IsSharable = true,
IsImplemented = true)]
Task<ResultWrapper<PayloadStatusV1>> engine_newPayloadV3(ExecutionPayloadV3 executionPayload,
byte[]?[] blobVersionedHashes, Hash256? parentBeaconBlockRoot);
}
17 changes: 16 additions & 1 deletion src/Nethermind/Nethermind.Optimism/OptimismEngineRpcModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System.Threading.Tasks;
using Nethermind.Core.Crypto;
using Nethermind.JsonRpc;
using Nethermind.Merge.Plugin;
using Nethermind.Merge.Plugin.Data;
using Nethermind.Serialization.Rlp;

namespace Nethermind.Optimism;

Expand Down Expand Up @@ -43,6 +43,21 @@ public Task<ResultWrapper<PayloadStatusV1>> engine_newPayloadV2(ExecutionPayload
return _engineRpcModule.engine_newPayloadV2(executionPayload);
}

public async Task<ResultWrapper<ForkchoiceUpdatedV1Result>> engine_forkchoiceUpdatedV3(ForkchoiceStateV1 forkchoiceState, OptimismPayloadAttributes? payloadAttributes = null)
{
return await _engineRpcModule.engine_forkchoiceUpdatedV3(forkchoiceState, payloadAttributes);
}

public Task<ResultWrapper<GetPayloadV3Result?>> engine_getPayloadV3(byte[] payloadId)
{
return _engineRpcModule.engine_getPayloadV3(payloadId);
}

public Task<ResultWrapper<PayloadStatusV1>> engine_newPayloadV3(ExecutionPayloadV3 executionPayload, byte[]?[] blobVersionedHashes, Hash256? parentBeaconBlockRoot)
{
return _engineRpcModule.engine_newPayloadV3(executionPayload, blobVersionedHashes, parentBeaconBlockRoot);
}

public OptimismEngineRpcModule(IEngineRpcModule engineRpcModule)
{
_engineRpcModule = engineRpcModule;
Expand Down
42 changes: 24 additions & 18 deletions src/Nethermind/Nethermind.Optimism/OptimismTransactionProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using Nethermind.Core;
using Nethermind.Core.Specs;
using Nethermind.Evm;
Expand Down Expand Up @@ -33,25 +34,27 @@ public OptimismTransactionProcessor(

protected override TransactionResult Execute(Transaction tx, in BlockExecutionContext blCtx, ITxTracer tracer, ExecutionOptions opts)
{
if (tx.SupportsBlobs)
{
// No blob txs in optimism
return TransactionResult.MalformedTransaction;
}

IReleaseSpec spec = SpecProvider.GetSpec(blCtx.Header);
_currentTxL1Cost = null;
if (tx.IsDeposit())
{
WorldState.AddToBalanceAndCreateIfNotExists(tx.SenderAddress!, tx.Mint, spec);

if (opts.HasFlag(ExecutionOptions.Commit) || !spec.IsEip658Enabled)
WorldState.Commit(spec);
}

return base.Execute(tx, in blCtx, tracer, opts);
}
Snapshot snapshot = WorldState.TakeSnapshot();

protected override TransactionResult ValidateStatic(Transaction tx, BlockHeader header, IReleaseSpec spec, ITxTracer tracer, ExecutionOptions opts,
out long intrinsicGas)
{
TransactionResult result = base.ValidateStatic(tx, header, spec, tracer, opts, out intrinsicGas);
if (tx.IsDeposit() && !tx.IsOPSystemTransaction && !result)
TransactionResult result = base.Execute(tx, blCtx, tracer, opts);

if (!result && tx.IsDeposit() && result.Error != "block gas limit exceeded")
{
// deposit tx should be included
WorldState.Restore(snapshot);
if (!WorldState.AccountExists(tx.SenderAddress!))
{
WorldState.CreateAccount(tx.SenderAddress!, 0, 1);
Expand All @@ -60,11 +63,22 @@ protected override TransactionResult ValidateStatic(Transaction tx, BlockHeader
{
WorldState.IncrementNonce(tx.SenderAddress!);
}
blCtx.Header.GasUsed += tx.GasLimit;
tracer.MarkAsFailed(tx.To!, tx.GasLimit, Array.Empty<byte>(), $"failed deposit: {result.Error}");
result = TransactionResult.Ok;
}

return result;
}

protected override TransactionResult ValidateStatic(Transaction tx, BlockHeader header, IReleaseSpec spec, ITxTracer tracer, ExecutionOptions opts,
out long intrinsicGas)
{
TransactionResult result = base.ValidateStatic(tx, header, spec, tracer, opts, out intrinsicGas);

return result;
}

protected override TransactionResult BuyGas(Transaction tx, BlockHeader header, IReleaseSpec spec, ITxTracer tracer, ExecutionOptions opts,
in UInt256 effectiveGasPrice, out UInt256 premiumPerGas, out UInt256 senderReservedGasPayment)
{
Expand All @@ -77,14 +91,6 @@ protected override TransactionResult BuyGas(Transaction tx, BlockHeader header,

if (tx.IsDeposit() && !tx.IsOPSystemTransaction && senderBalance < tx.Value)
{
if (!WorldState.AccountExists(tx.SenderAddress!))
{
WorldState.CreateAccount(tx.SenderAddress!, 0, 1);
}
else
{
WorldState.IncrementNonce(tx.SenderAddress!);
}
return "insufficient sender balance";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"BlobsSupport": "Disabled"
},
"Sync": {
"NetworkingEnabled": false
"NetworkingEnabled": false,
"AncientBodiesBarrier": 105235063,
"AncientReceiptsBarrier": 105235063
},
"Pruning": {
"Mode": "None"
Expand Down

0 comments on commit a72375f

Please sign in to comment.