Skip to content

Commit

Permalink
Optimism plugin (#6146)
Browse files Browse the repository at this point in the history
* Add OP Deposit TxType and Tx fields

* Add Optimism plugin

* Add deposit tx rlp decoding and encoding

* Start adding chainspec style for optimism

* Start l1 tx cost implementation

* Refactors and setting up optimism plugin

* Some custom state transition logic

* state transition logic

* Commit

* Fix build

* Fix Aura & add config

* Add plugin to Runner

* Make it run

* No state in genesis

* sync state & old headers

* Bodies & receipts

* Finalized fix

* Move to chainspec based OP config

* Enable OptimismEngineModule

* OP Specific way of building empty blocks

* Op post merge block producer empty block refactor

* Revert "Enable OptimismEngineModule"

This reverts commit 0c8c091.

* use OptimismEngineModule

* plugin order

* OptimismTxValidator

* Ignore gas limit

* Optimism plugin no longer inherits from MergePlugin

* Add txProcessorFactory

* Work on OptimismBlockProducerEnvFactory

* Don't touch account on substracting zero from balance

* Update transaction ToString for better debugging

* skip refunds and fees in deposit txs

* Fix DepositTx signature encoding

* Log OP payload attrs fields

* Throw if asks for l1 gas cost

* fix parenthesis in OP payload attrs toString

* Fix Extradata and Nonce

* Fix Gas refunds for Depost Txs

* Implement L1Cost function

* Fix RecoverSignature preprocessing step

* Fix nonce incrementing twice

* Make Rpc Transaction work with Depost Type

* Fix tx picker when producing blocks in optimism

* skip block improvement for deposit-only payloads

* invert noTxPool checks

* Remove unnecessary evm call override in op tx processor

* Regolith timestamp & td validation

* IsOpSystemTransaction

* Fix 1559 fee collector

* BlockTree load ForkChoice info

* simplify config and chainspec for op-goerli

* Add some logging to LoadForkChoice info

* Fix rpc tx

* some logging (commented out for now)

* fix logging in OP payload attrs

* Increment nonce on invalid deposit

* reenable networking

* Add base goerli config

* add author to base goerli genesis

* fix activated at in builtins

* fix chainspec for base-goerli.json

* Update submodules to master version

* change payload id computation

* Add base mainnet

* Op mainnet

* Op-mainnet config change

* Remove todos

* Fix formatting

* Fix build

* Change encoding

* Add root

* Revert "Add root"

This reverts commit 1127960.

* Revert "Remove todos"

This reverts commit c23b09d.

* Fix build

* Remove todos

* Fix overflow

* Fix payload ids in tests

* Fix init tests

* Fix null api

* Fix proof test

* Fix aura payloadId

* Cleanup

* Fix goerli ttd

* Enable GC on newPayload

* Fix build

* Fix formatting

* Change to task delay

* Fix RecoverAddress

* Fix minor issues

* Fix build

* feeRecipient & blockAddress in chainspec

* Optimism ecdsa

* Fix AlwaysPos

* Filter transactions

* Cash l1datacost

* Small fixes

* Remove AllowUnsafeBlocks

* Remove TxProcessorFactory

* Move SetupBlockchainProcessorInterceptor

* NeverProduceTrigger

* InitializeBlockProducerOptimism

* Validate payload attributes

* Init SpecHelper & L1CostHelper

---------

Co-authored-by: Jorge Mederos <jmederosalvarado@gmail.com>
Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com>
Co-authored-by: Nikita Mescheryakov <deffriann@protonmail.com>
  • Loading branch information
4 people authored Oct 27, 2023
1 parent 218ed62 commit ffcbf90
Show file tree
Hide file tree
Showing 119 changed files with 32,629 additions and 335 deletions.
15,352 changes: 15,352 additions & 0 deletions src/Nethermind/Chains/base-goerli.json

Large diffs are not rendered by default.

14,587 changes: 14,587 additions & 0 deletions src/Nethermind/Chains/base-mainnet.json

Large diffs are not rendered by default.

169 changes: 169 additions & 0 deletions src/Nethermind/Chains/op-goerli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"name": "Optimism goerli",
"dataDir": "op-goerli",
"engine": {
"Optimism": {
"params": {
"regolithTimestamp": "0x6414B8B0",
"bedrockBlockNumber": "0x0",
"l1FeeRecipient": "0x420000000000000000000000000000000000001A",
"l1BlockAddress": "0x4200000000000000000000000000000000000015"
}
}
},
"params": {
"chainId": "0x1a4",
"gasLimitBoundDivisor": "0x400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"forkBlock": "0x0",
"maxCodeSize": "0x6000",
"maxCodeSizeTransition": "0x0",
"eip150Transition": "0x0",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0",
"eip155Transition": "0x0",
"eip140Transition": "0x0",
"eip211Transition": "0x0",
"eip214Transition": "0x0",
"eip658Transition": "0x0",
"eip145Transition": "0x0",
"eip1014Transition": "0x0",
"eip1052Transition": "0x0",
"eip1283Transition": "0x0",
"eip1283DisableTransition": "0x0",
"eip152Transition": "0x0",
"eip1108Transition": "0x0",
"eip1344Transition": "0x0",
"eip1884Transition": "0x0",
"eip2028Transition": "0x0",
"eip2200Transition": "0x0",
"eip2565Transition": "0x0",
"eip2929Transition": "0x0",
"eip2930Transition": "0x0",
"eip1559Transition": "0x3df828",
"eip1559FeeCollectorTransition": "0x3df828",
"eip1559FeeCollector": "0x4200000000000000000000000000000000000019",
"eip1559ElasticityMultiplier": "0xa",
"eip1559BaseFeeMaxChangeDenominator": "0x32",
"eip3198Transition": "0x3df828",
"eip3529Transition": "0x3df828",
"eip3541Transition": "0x3df828",

"terminalTotalDifficulty": "0"
},
"genesis": {
"seal": {
"ethereum": {
"nonce": "0x0000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"difficulty": "0x1",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x000000000000000000000000000000000000000000000000000000000000000027770a9694e4b4b1e130ab91bc327c36855f612e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xe4e1c0",
"stateUnavailable": true,
"stateRoot": "0x9e6b478a1cd331a979c39e4bddf42c676bcf5a63382f898dc441fe3fe5eb0837"
},
"nodes": [
],
"accounts": {
"0x0000000000000000000000000000000000000001": {
"builtin": {
"name": "ecrecover",
"pricing": {
"linear": {
"base": 3000,
"word": 0
}
}
}
},
"0x0000000000000000000000000000000000000002": {
"builtin": {
"name": "sha256",
"pricing": {
"linear": {
"base": 60,
"word": 12
}
}
}
},
"0x0000000000000000000000000000000000000003": {
"builtin": {
"name": "ripemd160",
"pricing": {
"linear": {
"base": 600,
"word": 120
}
}
}
},
"0x0000000000000000000000000000000000000004": {
"builtin": {
"name": "identity",
"pricing": {
"linear": {
"base": 15,
"word": 3
}
}
}
},
"0x0000000000000000000000000000000000000005": {
"builtin": {
"name": "modexp",
"activate_at": "0x42ae50",
"pricing": {
"modexp": {
"divisor": 20
}
}
}
},
"0x0000000000000000000000000000000000000006": {
"builtin": {
"name": "alt_bn128_add",
"activate_at": "0x42ae50",
"pricing": {
"linear": {
"base": 500,
"word": 0
}
}
}
},
"0x0000000000000000000000000000000000000007": {
"builtin": {
"name": "alt_bn128_mul",
"activate_at": "0x42ae50",
"pricing": {
"linear": {
"base": 40000,
"word": 0
}
}
}
},
"0x0000000000000000000000000000000000000008": {
"builtin": {
"name": "alt_bn128_pairing",
"activate_at": "0x42ae50",
"pricing": {
"alt_bn128_pairing": {
"base": 100000,
"pair": 80000
}
}
}
}
}
}
169 changes: 169 additions & 0 deletions src/Nethermind/Chains/op-mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"name": "Optimism Mainnet",
"dataDir": "op-mainnet",
"engine": {
"Optimism": {
"params": {
"regolithTimestamp": "0x0",
"bedrockBlockNumber": "0x645C277",
"l1FeeRecipient": "0x420000000000000000000000000000000000001A",
"l1BlockAddress": "0x4200000000000000000000000000000000000015"
}
}
},
"params": {
"chainId": "0xa",
"gasLimitBoundDivisor": "0x400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"forkBlock": "0x0",
"maxCodeSize": "0x6000",
"maxCodeSizeTransition": "0x0",
"eip150Transition": "0x0",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0",
"eip155Transition": "0x0",
"eip140Transition": "0x0",
"eip211Transition": "0x0",
"eip214Transition": "0x0",
"eip658Transition": "0x0",
"eip145Transition": "0x0",
"eip1014Transition": "0x0",
"eip1052Transition": "0x0",
"eip1283Transition": "0x0",
"eip1283DisableTransition": "0x0",
"eip152Transition": "0x0",
"eip1108Transition": "0x0",
"eip1344Transition": "0x0",
"eip1884Transition": "0x0",
"eip2028Transition": "0x0",
"eip2200Transition": "0x0",
"eip2565Transition": "0x3C45B0",
"eip2929Transition": "0x3C45B0",
"eip2930Transition": "0x3C45B0",
"eip1559Transition": "0x645C277",
"eip1559FeeCollectorTransition": "0x645C277",
"eip1559FeeCollector": "0x4200000000000000000000000000000000000019",
"eip1559ElasticityMultiplier": "0x6",
"eip1559BaseFeeMaxChangeDenominator": "0x32",
"eip3198Transition": "0x645C277",
"eip3529Transition": "0x645C277",
"eip3541Transition": "0x645C277",

"terminalTotalDifficulty": "0"
},
"genesis": {
"seal": {
"ethereum": {
"nonce": "0x0000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"difficulty": "0x1",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x000000000000000000000000000000000000000000000000000000000000000000000398232e2064f896018496b4b44b3d62751f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0xe4e1c0",
"stateUnavailable": true,
"stateRoot": "0xeddb4c1786789419153a27c4c80ff44a2226b6eda04f7e22ce5bae892ea568eb"
},
"nodes": [
],
"accounts": {
"0x0000000000000000000000000000000000000001": {
"builtin": {
"name": "ecrecover",
"pricing": {
"linear": {
"base": 3000,
"word": 0
}
}
}
},
"0x0000000000000000000000000000000000000002": {
"builtin": {
"name": "sha256",
"pricing": {
"linear": {
"base": 60,
"word": 12
}
}
}
},
"0x0000000000000000000000000000000000000003": {
"builtin": {
"name": "ripemd160",
"pricing": {
"linear": {
"base": 600,
"word": 120
}
}
}
},
"0x0000000000000000000000000000000000000004": {
"builtin": {
"name": "identity",
"pricing": {
"linear": {
"base": 15,
"word": 3
}
}
}
},
"0x0000000000000000000000000000000000000005": {
"builtin": {
"name": "modexp",
"activate_at": "0x42ae50",
"pricing": {
"modexp": {
"divisor": 20
}
}
}
},
"0x0000000000000000000000000000000000000006": {
"builtin": {
"name": "alt_bn128_add",
"activate_at": "0x42ae50",
"pricing": {
"linear": {
"base": 500,
"word": 0
}
}
}
},
"0x0000000000000000000000000000000000000007": {
"builtin": {
"name": "alt_bn128_mul",
"activate_at": "0x42ae50",
"pricing": {
"linear": {
"base": 40000,
"word": 0
}
}
}
},
"0x0000000000000000000000000000000000000008": {
"builtin": {
"name": "alt_bn128_pairing",
"activate_at": "0x42ae50",
"pricing": {
"alt_bn128_pairing": {
"base": 100000,
"pair": 80000
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Nethermind.AccountAbstraction.Data;
using Nethermind.AccountAbstraction.Executor;
using Nethermind.Consensus;
using Nethermind.Consensus.Producers;
using Nethermind.Consensus.Transactions;
using Nethermind.Core;
using Nethermind.Core.Crypto;
Expand Down Expand Up @@ -54,7 +55,7 @@ public UserOperationTxSource(
_logger = logger;
}

public IEnumerable<Transaction> GetTransactions(BlockHeader parent, long gasLimit)
public IEnumerable<Transaction> GetTransactions(BlockHeader parent, long gasLimit, PayloadAttributes? payloadAttributes)
{
IDictionary<Address, HashSet<UInt256>> usedAccessList = new Dictionary<Address, HashSet<UInt256>>();
// IList<UserOperation> userOperationsToInclude = new List<UserOperation>();
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Api/Extensions/IPluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace Nethermind.Api.Extensions;

public interface IPluginConfig : IConfig
{
[ConfigItem(Description = "Order of plugin initialization", DefaultValue = "[Clique, Aura, Ethash, AuRaMerge, Merge, MEV, HealthChecks, Hive]")]
[ConfigItem(Description = "Order of plugin initialization", DefaultValue = "[Clique, Aura, Ethash, Optimism, AuRaMerge, Merge, MEV, HealthChecks, Hive]")]
string[] PluginOrder { get; set; }
}
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Api/Extensions/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace Nethermind.Api.Extensions;

public class PluginConfig : IPluginConfig
{
public string[] PluginOrder { get; set; } = { "Clique", "Aura", "Ethash", "AuRaMerge", "Merge", "MEV", "HealthChecks", "Hive" };
public string[] PluginOrder { get; set; } = { "Clique", "Aura", "Ethash", "Optimism", "AuRaMerge", "Merge", "MEV", "HealthChecks", "Hive" };
}
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Api/IApiWithBlockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public interface IApiWithBlockchain : IApiWithStores, IBlockchainBridgeFactory
IHealthHintService? HealthHintService { get; set; }
IRpcCapabilitiesProvider? RpcCapabilitiesProvider { get; set; }
ITransactionComparerProvider? TransactionComparerProvider { get; set; }
TxValidator? TxValidator { get; set; }
ITxValidator? TxValidator { get; set; }

/// <summary>
/// Manager of block finalization
Expand Down
3 changes: 3 additions & 0 deletions src/Nethermind/Nethermind.Api/IInitConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public interface IInitConfig : IConfig
[ConfigItem(Description = "A hint for the max memory that will allow us to configure the DB and Netty memory allocations.", DefaultValue = "null")]
long? MemoryHint { get; set; }

[ConfigItem(Description = "[TECHNICAL] Disable garbage collector on newPayload", DefaultValue = "true", HiddenFromDocs = true)]
bool DisableGcOnNewPayload { get; set; }

[ConfigItem(Description = "[TECHNICAL] Disable setting malloc options. Set to true if using different memory allocator or manually setting malloc opts.", DefaultValue = "false", HiddenFromDocs = true)]
bool DisableMallocOpts { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions src/Nethermind/Nethermind.Api/InitConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class InitConfig : IInitConfig

public string RpcDbUrl { get; set; } = String.Empty;
public long? MemoryHint { get; set; }
public bool DisableGcOnNewPayload { get; set; } = true;
public bool DisableMallocOpts { get; set; } = false;

[Obsolete("Use DiagnosticMode with MemDb instead")]
Expand Down
Loading

0 comments on commit ffcbf90

Please sign in to comment.