From e40f8ebf1ebc7215e9fdeebe789bd8369376dcc1 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 23 May 2024 13:24:20 +0200 Subject: [PATCH 1/9] chore: clippy happy (#8362) fix some conflicts Co-authored-by: Alexey Shekhirin --- Cargo.toml | 2 +- Makefile | 6 +++--- bin/reth/src/commands/db/stats.rs | 2 +- crates/blockchain-tree/src/blockchain_tree.rs | 7 ++++++- .../consensus/beacon/src/engine/hooks/prune.rs | 8 ++++---- .../beacon/src/engine/hooks/static_file.rs | 14 +++++++------- crates/consensus/beacon/src/engine/mod.rs | 10 +++++----- crates/exex/src/manager.rs | 2 +- crates/interfaces/src/blockchain_tree/mod.rs | 1 + crates/net/ecies/src/algorithm.rs | 4 ++-- crates/net/eth-wire-types/src/message.rs | 2 +- crates/node-core/src/args/utils.rs | 2 +- crates/node-core/src/dirs.rs | 1 + crates/payload/validator/src/lib.rs | 4 ++-- crates/primitives/src/prune/target.rs | 4 ++-- crates/primitives/src/revm/env.rs | 4 ++-- crates/stages/src/stages/execution.rs | 3 +-- crates/stages/src/stages/hashing_account.rs | 9 ++++----- crates/stages/src/stages/sender_recovery.rs | 5 ++--- crates/stages/src/stages/tx_lookup.rs | 5 ++--- .../db/src/implementation/mdbx/cursor.rs | 3 +-- .../src/providers/database/provider.rs | 18 +++++++++--------- crates/transaction-pool/src/pool/mod.rs | 16 ++++++++-------- crates/transaction-pool/src/pool/pending.rs | 6 +++--- crates/transaction-pool/src/pool/txpool.rs | 1 + examples/node-event-hooks/src/main.rs | 8 ++------ 26 files changed, 73 insertions(+), 74 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d3ecd23c70..d7a12835ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,7 +103,7 @@ rust.missing_debug_implementations = "warn" rust.missing_docs = "warn" rust.unreachable_pub = "warn" rust.unused_must_use = "deny" -rust.rust_2018_idioms = "deny" +rust.rust_2018_idioms = { level = "deny", priority = -1 } rustdoc.all = "warn" [workspace.lints.clippy] diff --git a/Makefile b/Makefile index 2b19bb5814..cf58615855 100644 --- a/Makefile +++ b/Makefile @@ -414,9 +414,9 @@ fix-lint-other-targets: -- -D warnings fix-lint: - make lint-reth && \ - make lint-op-reth && \ - make lint-other-targets && \ + make fix-lint-reth && \ + make fix-lint-op-reth && \ + make fix-lint-other-targets && \ make fmt .PHONY: rustdocs diff --git a/bin/reth/src/commands/db/stats.rs b/bin/reth/src/commands/db/stats.rs index b47e7980b0..7d9020fc7f 100644 --- a/bin/reth/src/commands/db/stats.rs +++ b/bin/reth/src/commands/db/stats.rs @@ -376,7 +376,7 @@ impl Command { let max_widths = table.column_max_content_widths(); let mut separator = Row::new(); for width in max_widths { - separator.add_cell(Cell::new(&"-".repeat(width as usize))); + separator.add_cell(Cell::new("-".repeat(width as usize))); } table.add_row(separator); diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index 6899944712..5eb35b499a 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -297,7 +297,12 @@ where // get parent hashes let mut parent_block_hashes = self.all_chain_hashes(chain_id); let first_pending_block_number = - *parent_block_hashes.first_key_value().expect("There is at least one block hash").0; + if let Some(key_value) = parent_block_hashes.first_key_value() { + *key_value.0 + } else { + debug!(target: "blockchain_tree", ?chain_id, "No blockhashes stored"); + return None + }; let canonical_chain = canonical_chain .iter() .filter(|&(key, _)| key < first_pending_block_number) diff --git a/crates/consensus/beacon/src/engine/hooks/prune.rs b/crates/consensus/beacon/src/engine/hooks/prune.rs index a9bb4f05bd..d2c2e2d33a 100644 --- a/crates/consensus/beacon/src/engine/hooks/prune.rs +++ b/crates/consensus/beacon/src/engine/hooks/prune.rs @@ -78,10 +78,10 @@ impl PruneHook { /// This will try to spawn the pruner if it is idle: /// 1. Check if pruning is needed through [Pruner::is_pruning_needed]. - /// 2. - /// 1. If pruning is needed, pass tip block number to the [Pruner::run] and spawn it in a - /// separate task. Set pruner state to [PrunerState::Running]. - /// 2. If pruning is not needed, set pruner state back to [PrunerState::Idle]. + /// + /// 2.1. If pruning is needed, pass tip block number to the [Pruner::run] and spawn it in a + /// separate task. Set pruner state to [PrunerState::Running]. + /// 2.2. If pruning is not needed, set pruner state back to [PrunerState::Idle]. /// /// If pruner is already running, do nothing. fn try_spawn_pruner(&mut self, tip_block_number: BlockNumber) -> Option { diff --git a/crates/consensus/beacon/src/engine/hooks/static_file.rs b/crates/consensus/beacon/src/engine/hooks/static_file.rs index 2cff68e1d2..29ad2aba2b 100644 --- a/crates/consensus/beacon/src/engine/hooks/static_file.rs +++ b/crates/consensus/beacon/src/engine/hooks/static_file.rs @@ -71,13 +71,13 @@ impl StaticFileHook { /// 1. Check if producing static files is needed through /// [StaticFileProducer::get_static_file_targets](reth_static_file::StaticFileProducerInner::get_static_file_targets) /// and then [StaticFileTargets::any](reth_static_file::StaticFileTargets::any). - /// 2. - /// 1. If producing static files is needed, pass static file request to the - /// [StaticFileProducer::run](reth_static_file::StaticFileProducerInner::run) and spawn - /// it in a separate task. Set static file producer state to - /// [StaticFileProducerState::Running]. - /// 2. If producing static files is not needed, set static file producer state back to - /// [StaticFileProducerState::Idle]. + /// + /// 2.1. If producing static files is needed, pass static file request to the + /// [StaticFileProducer::run](reth_static_file::StaticFileProducerInner::run) and + /// spawn it in a separate task. Set static file producer state to + /// [StaticFileProducerState::Running]. + /// 2.2. If producing static files is not needed, set static file producer state back to + /// [StaticFileProducerState::Idle]. /// /// If static_file_producer is already running, do nothing. fn try_spawn_static_file_producer( diff --git a/crates/consensus/beacon/src/engine/mod.rs b/crates/consensus/beacon/src/engine/mod.rs index 1057457c77..47a311f4d3 100644 --- a/crates/consensus/beacon/src/engine/mod.rs +++ b/crates/consensus/beacon/src/engine/mod.rs @@ -710,13 +710,13 @@ where /// If validation fails, the response MUST contain the latest valid hash: /// /// - The block hash of the ancestor of the invalid payload satisfying the following two - /// conditions: + /// conditions: /// - It is fully validated and deemed VALID /// - Any other ancestor of the invalid payload with a higher blockNumber is INVALID /// - 0x0000000000000000000000000000000000000000000000000000000000000000 if the above - /// conditions are satisfied by a PoW block. + /// conditions are satisfied by a PoW block. /// - null if client software cannot determine the ancestor of the invalid payload satisfying - /// the above conditions. + /// the above conditions. fn latest_valid_hash_for_invalid_payload( &mut self, parent_hash: B256, @@ -1110,8 +1110,8 @@ where /// - invalid extra data /// - invalid transactions /// - incorrect hash - /// - the versioned hashes passed with the payload do not exactly match transaction - /// versioned hashes + /// - the versioned hashes passed with the payload do not exactly match transaction versioned + /// hashes /// - the block does not contain blob transactions if it is pre-cancun /// /// This validates the following engine API rule: diff --git a/crates/exex/src/manager.rs b/crates/exex/src/manager.rs index 1de8c102e3..088328c860 100644 --- a/crates/exex/src/manager.rs +++ b/crates/exex/src/manager.rs @@ -160,7 +160,7 @@ pub struct ExExManagerMetrics { /// The manager is responsible for: /// /// - Receiving relevant events from the rest of the node, and sending these to the execution -/// extensions +/// extensions /// - Backpressure /// - Error handling /// - Monitoring diff --git a/crates/interfaces/src/blockchain_tree/mod.rs b/crates/interfaces/src/blockchain_tree/mod.rs index 7d2b50e418..0c1a9553dc 100644 --- a/crates/interfaces/src/blockchain_tree/mod.rs +++ b/crates/interfaces/src/blockchain_tree/mod.rs @@ -210,6 +210,7 @@ pub enum BlockStatus { /// This is required to: /// - differentiate whether trie state updates should be cached. /// - inform other +/// /// This is required because the state root check can only be performed if the targeted block can be /// traced back to the canonical __head__. #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/crates/net/ecies/src/algorithm.rs b/crates/net/ecies/src/algorithm.rs index 52398de4fe..65d74627e2 100644 --- a/crates/net/ecies/src/algorithm.rs +++ b/crates/net/ecies/src/algorithm.rs @@ -45,8 +45,8 @@ fn ecdh_x(public_key: &PublicKey, secret_key: &SecretKey) -> B256 { /// # Panics /// * If the `dest` is empty /// * If the `dest` len is greater than or equal to the hash output len * the max counter value. In -/// this case, the hash output len is 32 bytes, and the max counter value is 2^32 - 1. So the dest -/// cannot have a len greater than 32 * 2^32 - 1. +/// this case, the hash output len is 32 bytes, and the max counter value is 2^32 - 1. So the dest +/// cannot have a len greater than 32 * 2^32 - 1. fn kdf(secret: B256, s1: &[u8], dest: &mut [u8]) { concat_kdf::derive_key_into::(secret.as_slice(), s1, dest).unwrap(); } diff --git a/crates/net/eth-wire-types/src/message.rs b/crates/net/eth-wire-types/src/message.rs index dc8011879b..c4101e852d 100644 --- a/crates/net/eth-wire-types/src/message.rs +++ b/crates/net/eth-wire-types/src/message.rs @@ -169,7 +169,7 @@ impl From for ProtocolBroadcastMessage { /// The ethereum wire protocol is a set of messages that are broadcast to the network in two /// styles: /// * A request message sent by a peer (such as [`GetPooledTransactions`]), and an associated -/// response message (such as [`PooledTransactions`]). +/// response message (such as [`PooledTransactions`]). /// * A message that is broadcast to the network, without a corresponding request. /// /// The newer `eth/66` is an efficiency upgrade on top of `eth/65`, introducing a request id to diff --git a/crates/node-core/src/args/utils.rs b/crates/node-core/src/args/utils.rs index 6abc9a33d2..c340a40390 100644 --- a/crates/node-core/src/args/utils.rs +++ b/crates/node-core/src/args/utils.rs @@ -152,7 +152,7 @@ pub enum SocketAddressParsingError { /// The following formats are checked: /// /// - If the value can be parsed as a `u16` or starts with `:` it is considered a port, and the -/// hostname is set to `localhost`. +/// hostname is set to `localhost`. /// - If the value contains `:` it is assumed to be the format `:` /// - Otherwise it is assumed to be a hostname /// diff --git a/crates/node-core/src/dirs.rs b/crates/node-core/src/dirs.rs index 75919f6f0f..b33df18f26 100644 --- a/crates/node-core/src/dirs.rs +++ b/crates/node-core/src/dirs.rs @@ -257,6 +257,7 @@ impl From for MaybePlatformPath { /// * mainnet: `/mainnet` /// * goerli: `/goerli` /// * sepolia: `/sepolia` +/// /// Otherwise, the path will be dependent on the chain ID: /// * `/` #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/crates/payload/validator/src/lib.rs b/crates/payload/validator/src/lib.rs index 6b95b04257..3faa24e772 100644 --- a/crates/payload/validator/src/lib.rs +++ b/crates/payload/validator/src/lib.rs @@ -84,8 +84,8 @@ impl ExecutionPayloadValidator { /// - invalid extra data /// - invalid transactions /// - incorrect hash - /// - the versioned hashes passed with the payload do not exactly match transaction - /// versioned hashes + /// - the versioned hashes passed with the payload do not exactly match transaction versioned + /// hashes /// - the block does not contain blob transactions if it is pre-cancun /// /// The checks are done in the order that conforms with the engine-API specification. diff --git a/crates/primitives/src/prune/target.rs b/crates/primitives/src/prune/target.rs index 1300b9b0b9..7f39c8d74c 100644 --- a/crates/primitives/src/prune/target.rs +++ b/crates/primitives/src/prune/target.rs @@ -70,8 +70,8 @@ impl PruneModes { /// /// 1. For [PruneMode::Full], it fails if `MIN_BLOCKS > 0`. /// 2. For [PruneMode::Distance(distance)], it fails if `distance < MIN_BLOCKS + 1`. `+ 1` is needed -/// because `PruneMode::Distance(0)` means that we leave zero blocks from the latest, meaning we -/// have one block in the database. +/// because `PruneMode::Distance(0)` means that we leave zero blocks from the latest, meaning we +/// have one block in the database. fn deserialize_opt_prune_mode_with_min_blocks<'de, const MIN_BLOCKS: u64, D: Deserializer<'de>>( deserializer: D, ) -> Result, D::Error> { diff --git a/crates/primitives/src/revm/env.rs b/crates/primitives/src/revm/env.rs index b13a7018f7..e217ad3545 100644 --- a/crates/primitives/src/revm/env.rs +++ b/crates/primitives/src/revm/env.rs @@ -138,8 +138,8 @@ pub fn tx_env_with_recovered(transaction: &TransactionSignedEcRecovered) -> TxEn /// and therefore: /// * the call must execute to completion /// * the call does not count against the block’s gas limit -/// * the call does not follow the EIP-1559 burn semantics - no value should be transferred as -/// part of the call +/// * the call does not follow the EIP-1559 burn semantics - no value should be transferred as part +/// of the call /// * if no code exists at `BEACON_ROOTS_ADDRESS`, the call must fail silently pub fn fill_tx_env_with_beacon_root_contract_call(env: &mut Env, parent_beacon_block_root: B256) { env.tx = TxEnv { diff --git a/crates/stages/src/stages/execution.rs b/crates/stages/src/stages/execution.rs index 9d8cf6ac66..0713763fcc 100644 --- a/crates/stages/src/stages/execution.rs +++ b/crates/stages/src/stages/execution.rs @@ -58,8 +58,7 @@ use tracing::*; /// - [tables::BlockBodyIndices] get tx index to know what needs to be unwinded /// - [tables::AccountsHistory] to remove change set and apply old values to /// - [tables::PlainAccountState] [tables::StoragesHistory] to remove change set and apply old -/// values -/// to [tables::PlainStorageState] +/// values to [tables::PlainStorageState] // false positive, we cannot derive it if !DB: Debug. #[allow(missing_debug_implementations)] pub struct ExecutionStage { diff --git a/crates/stages/src/stages/hashing_account.rs b/crates/stages/src/stages/hashing_account.rs index 051b6a85f9..5489811cd4 100644 --- a/crates/stages/src/stages/hashing_account.rs +++ b/crates/stages/src/stages/hashing_account.rs @@ -72,11 +72,10 @@ impl Default for AccountHashingStage { /// /// In order to check the "full hashing" mode of the stage you want to generate more /// transitions than `AccountHashingStage.clean_threshold`. This requires: -/// 1. Creating enough blocks so there's enough transactions to generate -/// the required transition keys in the `BlockTransitionIndex` (which depends on the -/// `TxTransitionIndex` internally) -/// 2. Setting `blocks.len() > clean_threshold` so that there's enough diffs to actually -/// take the 2nd codepath +/// 1. Creating enough blocks so there's enough transactions to generate the required transition +/// keys in the `BlockTransitionIndex` (which depends on the `TxTransitionIndex` internally) +/// 2. Setting `blocks.len() > clean_threshold` so that there's enough diffs to actually take the +/// 2nd codepath #[derive(Clone, Debug)] pub struct SeedOpts { /// The range of blocks to be generated diff --git a/crates/stages/src/stages/sender_recovery.rs b/crates/stages/src/stages/sender_recovery.rs index e078fd9542..977e143367 100644 --- a/crates/stages/src/stages/sender_recovery.rs +++ b/crates/stages/src/stages/sender_recovery.rs @@ -506,10 +506,9 @@ mod tests { /// # Panics /// /// 1. If there are any entries in the [tables::TransactionSenders] table above a given - /// block number. - /// + /// block number. /// 2. If the is no requested block entry in the bodies table, but - /// [tables::TransactionSenders] is not empty. + /// [tables::TransactionSenders] is not empty. fn ensure_no_senders_by_block(&self, block: BlockNumber) -> Result<(), TestRunnerError> { let body_result = self .db diff --git a/crates/stages/src/stages/tx_lookup.rs b/crates/stages/src/stages/tx_lookup.rs index 342183905b..a41339b1f5 100644 --- a/crates/stages/src/stages/tx_lookup.rs +++ b/crates/stages/src/stages/tx_lookup.rs @@ -430,10 +430,9 @@ mod tests { /// # Panics /// /// 1. If there are any entries in the [tables::TransactionHashNumbers] table above a given - /// block number. - /// + /// block number. /// 2. If the is no requested block entry in the bodies table, but - /// [tables::TransactionHashNumbers] is not empty. + /// [tables::TransactionHashNumbers] is not empty. fn ensure_no_hash_by_block(&self, number: BlockNumber) -> Result<(), TestRunnerError> { let body_result = self .db diff --git a/crates/storage/db/src/implementation/mdbx/cursor.rs b/crates/storage/db/src/implementation/mdbx/cursor.rs index 43adc24927..3d1a881529 100644 --- a/crates/storage/db/src/implementation/mdbx/cursor.rs +++ b/crates/storage/db/src/implementation/mdbx/cursor.rs @@ -191,8 +191,7 @@ impl DbDupCursorRO for Cursor { /// - Some(key), Some(subkey): a `key` item whose data is >= than `subkey` /// - Some(key), None: first item of a specified `key` /// - None, Some(subkey): like first case, but in the first key - /// - None, None: first item in the table - /// of a DUPSORT table. + /// - None, None: first item in the table of a DUPSORT table. fn walk_dup( &mut self, key: Option, diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index 6e07b7c46a..643bc23e65 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -375,20 +375,20 @@ impl DatabaseProvider { /// /// If UNWIND is false we will just read the state/blocks and return them. /// - /// 1. Iterate over the [BlockBodyIndices][tables::BlockBodyIndices] table to get all - /// the transaction ids. - /// 2. Iterate over the [StorageChangeSets][tables::StorageChangeSets] table - /// and the [AccountChangeSets][tables::AccountChangeSets] tables in reverse order to - /// reconstruct the changesets. - /// - In order to have both the old and new values in the changesets, we also access the - /// plain state tables. + /// 1. Iterate over the [BlockBodyIndices][tables::BlockBodyIndices] table to get all the + /// transaction ids. + /// 2. Iterate over the [StorageChangeSets][tables::StorageChangeSets] table and the + /// [AccountChangeSets][tables::AccountChangeSets] tables in reverse order to reconstruct + /// the changesets. + /// - In order to have both the old and new values in the changesets, we also access the + /// plain state tables. /// 3. While iterating over the changeset tables, if we encounter a new account or storage slot, - /// we: + /// we: /// 1. Take the old value from the changeset /// 2. Take the new value from the plain state /// 3. Save the old value to the local state /// 4. While iterating over the changeset tables, if we encounter an account/storage slot we - /// have seen before we: + /// have seen before we: /// 1. Take the old value from the changeset /// 2. Take the new value from the local state /// 3. Set the local state to the value in the changeset diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index a27b9d0216..163f30ea6b 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -34,16 +34,16 @@ //! //! In essence the transaction pool is made of three separate sub-pools: //! -//! - Pending Pool: Contains all transactions that are valid on the current state and satisfy -//! (3. a)(1): _No_ nonce gaps. A _pending_ transaction is considered _ready_ when it has the lowest -//! nonce of all transactions from the same sender. Once a _ready_ transaction with nonce `n` has -//! been executed, the next highest transaction from the same sender `n + 1` becomes ready. +//! - Pending Pool: Contains all transactions that are valid on the current state and satisfy (3. +//! a)(1): _No_ nonce gaps. A _pending_ transaction is considered _ready_ when it has the lowest +//! nonce of all transactions from the same sender. Once a _ready_ transaction with nonce `n` has +//! been executed, the next highest transaction from the same sender `n + 1` becomes ready. //! -//! - Queued Pool: Contains all transactions that are currently blocked by missing -//! transactions: (3. a)(2): _With_ nonce gaps or due to lack of funds. +//! - Queued Pool: Contains all transactions that are currently blocked by missing transactions: +//! (3. a)(2): _With_ nonce gaps or due to lack of funds. //! -//! - Basefee Pool: To account for the dynamic base fee requirement (3. b) which could render -//! an EIP-1559 and all subsequent transactions of the sender currently invalid. +//! - Basefee Pool: To account for the dynamic base fee requirement (3. b) which could render an +//! EIP-1559 and all subsequent transactions of the sender currently invalid. //! //! The classification of transactions is always dependent on the current state that is changed as //! soon as a new block is mined. Once a new block is mined, the account changeset must be applied diff --git a/crates/transaction-pool/src/pool/pending.rs b/crates/transaction-pool/src/pool/pending.rs index 7e733a6593..d78af79085 100644 --- a/crates/transaction-pool/src/pool/pending.rs +++ b/crates/transaction-pool/src/pool/pending.rs @@ -90,9 +90,9 @@ impl PendingPool { /// Returns an iterator over all transactions that are _currently_ ready. /// /// 1. The iterator _always_ returns transaction in order: It never returns a transaction with - /// an unsatisfied dependency and only returns them if dependency transaction were yielded - /// previously. In other words: The nonces of transactions with the same sender will _always_ - /// increase by exactly 1. + /// an unsatisfied dependency and only returns them if dependency transaction were yielded + /// previously. In other words: The nonces of transactions with the same sender will _always_ + /// increase by exactly 1. /// /// The order of transactions which satisfy (1.) is determent by their computed priority: A /// transaction with a higher priority is returned before a transaction with a lower priority. diff --git a/crates/transaction-pool/src/pool/txpool.rs b/crates/transaction-pool/src/pool/txpool.rs index bcad71edbd..4e35733d4b 100644 --- a/crates/transaction-pool/src/pool/txpool.rs +++ b/crates/transaction-pool/src/pool/txpool.rs @@ -1002,6 +1002,7 @@ impl AllTransactions { /// For all transactions: /// - decreased basefee: promotes from `basefee` to `pending` sub-pool. /// - increased basefee: demotes from `pending` to `basefee` sub-pool. + /// /// Individually: /// - decreased sender allowance: demote from (`basefee`|`pending`) to `queued`. /// - increased sender allowance: promote from `queued` to diff --git a/examples/node-event-hooks/src/main.rs b/examples/node-event-hooks/src/main.rs index b9cd53298b..e8a751840e 100644 --- a/examples/node-event-hooks/src/main.rs +++ b/examples/node-event-hooks/src/main.rs @@ -8,12 +8,8 @@ //! ``` //! //! This launch the regular reth node and also print: -//! -//! > "All components initialized" -//! once all components have been initialized and -//! -//! > "Node started" -//! once the node has been started. +//! > "All components initialized" – once all components have been initialized +//! > "Node started" – once the node has been started. use reth::cli::Cli; use reth_node_ethereum::EthereumNode; From bcd409b46bad9b34d8fb5fa0c57f4dc98d7c494d Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Tue, 28 May 2024 16:33:19 +0800 Subject: [PATCH 2/9] fix format issue --- crates/optimism/evm/src/execute.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index abd8b1ce2f..fe0c507f09 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -369,22 +369,22 @@ where U256::from_str( "0x0000000000000000000000000000000000000000000000000000000000000000", ) - .unwrap(), + .unwrap(), U256::from_str( "0x5772617070656420424e42000000000000000000000000000000000000000016", ) - .unwrap(), + .unwrap(), ); // symbolSlot { Symbol: "wBNB" } w_bnb_storage.insert( U256::from_str( "0x0000000000000000000000000000000000000000000000000000000000000001", ) - .unwrap(), + .unwrap(), U256::from_str( "0x57424e4200000000000000000000000000000000000000000000000000000008", ) - .unwrap(), + .unwrap(), ); // insert wBNB contract with storage self.db_mut().insert_account_with_storage( From 90a0d6c239f13055192f60a05a2b8c5f34ad7b9f Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Wed, 29 May 2024 13:36:50 -0600 Subject: [PATCH 3/9] fix feature issue --- crates/optimism/evm/Cargo.toml | 2 +- crates/optimism/evm/src/execute.rs | 85 +++++++++++++++--------------- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/crates/optimism/evm/Cargo.toml b/crates/optimism/evm/Cargo.toml index a1c3a168bd..7f1a392dba 100644 --- a/crates/optimism/evm/Cargo.toml +++ b/crates/optimism/evm/Cargo.toml @@ -35,4 +35,4 @@ optimism = [ "reth-provider/optimism", "reth-interfaces/optimism", "revm-primitives/optimism", -] +] \ No newline at end of file diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index fe0c507f09..47045f3780 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -357,48 +357,49 @@ where block.withdrawals.as_ref().map(Withdrawals::as_ref), ); - #[cfg(all(feature = "optimism", feature = "opbnb"))] - if self.chain_spec.fork(Hardfork::PreContractForkBlock).transitions_at_block(block.number) { - // WBNBContract WBNB preDeploy contract address - let w_bnb_contract_address = - Address::from_str("0x4200000000000000000000000000000000000006").unwrap(); - let mut w_bnb_storage = PlainStorage::new(); - // insert storage for wBNB contract - // nameSlot { Name: "Wrapped BNB" } - w_bnb_storage.insert( - U256::from_str( - "0x0000000000000000000000000000000000000000000000000000000000000000", - ) - .unwrap(), - U256::from_str( - "0x5772617070656420424e42000000000000000000000000000000000000000016", - ) - .unwrap(), - ); - // symbolSlot { Symbol: "wBNB" } - w_bnb_storage.insert( - U256::from_str( - "0x0000000000000000000000000000000000000000000000000000000000000001", - ) - .unwrap(), - U256::from_str( - "0x57424e4200000000000000000000000000000000000000000000000000000008", - ) - .unwrap(), - ); - // insert wBNB contract with storage - self.db_mut().insert_account_with_storage( - w_bnb_contract_address, - AccountInfo::default(), - w_bnb_storage, - ); - // GovernanceToken contract address - let governance_token_contract_address = - Address::from_str("0x4200000000000000000000000000000000000042").unwrap(); - // destruct the governance token contract - self.evm - .selfdestruct(governance_token_contract_address, governance_token_contract_address); - } + // TODO: rebase with the fix + // #[cfg(all(feature = "optimism", feature = "opbnb"))] + // if self.chain_spec.fork(Hardfork::PreContractForkBlock).transitions_at_block(block. + // number) { // WBNBContract WBNB preDeploy contract address + // let w_bnb_contract_address = + // Address::from_str("0x4200000000000000000000000000000000000006").unwrap(); + // let mut w_bnb_storage = PlainStorage::new(); + // // insert storage for wBNB contract + // // nameSlot { Name: "Wrapped BNB" } + // w_bnb_storage.insert( + // U256::from_str( + // "0x0000000000000000000000000000000000000000000000000000000000000000", + // ) + // .unwrap(), + // U256::from_str( + // "0x5772617070656420424e42000000000000000000000000000000000000000016", + // ) + // .unwrap(), + // ); + // // symbolSlot { Symbol: "wBNB" } + // w_bnb_storage.insert( + // U256::from_str( + // "0x0000000000000000000000000000000000000000000000000000000000000001", + // ) + // .unwrap(), + // U256::from_str( + // "0x57424e4200000000000000000000000000000000000000000000000000000008", + // ) + // .unwrap(), + // ); + // // insert wBNB contract with storage + // self.db_mut().insert_account_with_storage( + // w_bnb_contract_address, + // AccountInfo::default(), + // w_bnb_storage, + // ); + // // GovernanceToken contract address + // let governance_token_contract_address = + // Address::from_str("0x4200000000000000000000000000000000000042").unwrap(); + // // destruct the governance token contract + // self.evm + // .selfdestruct(governance_token_contract_address, + // governance_token_contract_address); } // increment balances self.state From 1089d0c46adbc04fd4c1f68076fec5e299cee2a9 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Wed, 29 May 2024 13:54:21 +0800 Subject: [PATCH 4/9] fix ci workflow --- .github/workflows/integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 1eea7d1f86..e7f886e33e 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -6,7 +6,7 @@ on: pull_request: merge_group: push: - branches: [main] + branches: [ main ] env: CARGO_TERM_COLOR: always @@ -28,7 +28,7 @@ jobs: - network: ethereum extra-features: "" - network: optimism - extra-features: "opbnb" + extra-features: "" timeout-minutes: 60 steps: - uses: actions/checkout@v4 @@ -84,7 +84,7 @@ jobs: name: integration success runs-on: ubuntu-latest if: always() - needs: [test] + needs: [ test ] timeout-minutes: 30 steps: - name: Decide whether the needed jobs succeeded or failed From 5367a14cd77cf026392b84db00d426ca2d090620 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Wed, 29 May 2024 15:17:58 -0600 Subject: [PATCH 5/9] udpate revm --- .github/workflows/integration.yml | 2 +- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++-- crates/optimism/node/Cargo.toml | 5 +++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index e7f886e33e..67b553965e 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -28,7 +28,7 @@ jobs: - network: ethereum extra-features: "" - network: optimism - extra-features: "" + extra-features: "opbnb" timeout-minutes: 60 steps: - uses: actions/checkout@v4 diff --git a/Cargo.lock b/Cargo.lock index e42d0a91f1..4393fd364f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8383,7 +8383,7 @@ dependencies = [ [[package]] name = "revm" version = "8.0.0" -source = "git+https://github.com/bnb-chain/revm.git?rev=f5cc71d#f5cc71d443a1957285ee4230562b2a59c2457552" +source = "git+https://github.com/bnb-chain/revm.git?rev=4be2578#4be25784feb01f97ea94202d418941f3ee04ae17" dependencies = [ "auto_impl", "cfg-if", @@ -8415,7 +8415,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "4.0.0" -source = "git+https://github.com/bnb-chain/revm.git?rev=f5cc71d#f5cc71d443a1957285ee4230562b2a59c2457552" +source = "git+https://github.com/bnb-chain/revm.git?rev=4be2578#4be25784feb01f97ea94202d418941f3ee04ae17" dependencies = [ "revm-primitives", "serde", @@ -8424,7 +8424,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "6.0.0" -source = "git+https://github.com/bnb-chain/revm.git?rev=f5cc71d#f5cc71d443a1957285ee4230562b2a59c2457552" +source = "git+https://github.com/bnb-chain/revm.git?rev=4be2578#4be25784feb01f97ea94202d418941f3ee04ae17" dependencies = [ "aurora-engine-modexp", "bls_on_arkworks", @@ -8446,7 +8446,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "3.1.1" -source = "git+https://github.com/bnb-chain/revm.git?rev=f5cc71d#f5cc71d443a1957285ee4230562b2a59c2457552" +source = "git+https://github.com/bnb-chain/revm.git?rev=4be2578#4be25784feb01f97ea94202d418941f3ee04ae17" dependencies = [ "alloy-primitives", "auto_impl", diff --git a/Cargo.toml b/Cargo.toml index d7a12835ea..e1f28d136f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -401,6 +401,6 @@ similar-asserts = "1.5.0" test-fuzz = "5" [patch.crates-io] -revm = { git = "https://github.com/bnb-chain/revm.git", rev = "f5cc71d" } -revm-primitives = { git = "https://github.com/bnb-chain/revm.git", rev = "f5cc71d" } +revm = { git = "https://github.com/bnb-chain/revm.git", rev = "4be2578" } +revm-primitives = { git = "https://github.com/bnb-chain/revm.git", rev = "4be2578" } alloy-chains = { git = "https://github.com/alloy-rs/chains.git", rev = "906d6fb" } \ No newline at end of file diff --git a/crates/optimism/node/Cargo.toml b/crates/optimism/node/Cargo.toml index 9c985825df..aa0417e195 100644 --- a/crates/optimism/node/Cargo.toml +++ b/crates/optimism/node/Cargo.toml @@ -67,4 +67,9 @@ optimism = [ "reth-evm-optimism/optimism", "reth-optimism-payload-builder/optimism", "reth-beacon-consensus/optimism", +] + +opbnb = [ + "reth-primitives/opbnb", + "revm-primitives/opbnb" ] \ No newline at end of file From 564ef712f694be694c1f2ff01b92114db7ace85f Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Wed, 29 May 2024 15:39:27 +0800 Subject: [PATCH 6/9] try to fix space issue --- .github/workflows/unit.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 8cae0f703b..c1877c198a 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -6,7 +6,7 @@ on: pull_request: merge_group: push: - branches: [main] + branches: [ main ] env: CARGO_TERM_COLOR: always @@ -19,13 +19,14 @@ concurrency: jobs: test: name: test / ${{ matrix.network }} (${{ matrix.partition }}/2) - runs-on: ubuntu-latest + runs-on: + group: Reth env: RUST_BACKTRACE: 1 strategy: matrix: - partition: [1, 2] - network: [ethereum, optimism] + partition: [ 1, 2 ] + network: [ ethereum, optimism ] timeout-minutes: 30 steps: - uses: actions/checkout@v4 @@ -53,7 +54,8 @@ jobs: state: name: Ethereum state tests - runs-on: ubuntu-latest + runs-on: + group: Reth env: RUST_LOG: info,sync=error RUST_BACKTRACE: 1 @@ -77,7 +79,8 @@ jobs: doc: name: doc tests (${{ matrix.network }}) - runs-on: ubuntu-latest + runs-on: + group: Reth env: RUST_BACKTRACE: 1 timeout-minutes: 30 @@ -101,7 +104,7 @@ jobs: name: unit success runs-on: ubuntu-latest if: always() - needs: [test, state, doc] + needs: [ test, state, doc ] timeout-minutes: 30 steps: - name: Decide whether the needed jobs succeeded or failed From c3321da013b4f552e70e46fef661cd9c009c1ac1 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Wed, 29 May 2024 15:41:05 +0800 Subject: [PATCH 7/9] Revert "try to fix space issue" This reverts commit 564ef712f694be694c1f2ff01b92114db7ace85f. --- .github/workflows/unit.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index c1877c198a..8cae0f703b 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -6,7 +6,7 @@ on: pull_request: merge_group: push: - branches: [ main ] + branches: [main] env: CARGO_TERM_COLOR: always @@ -19,14 +19,13 @@ concurrency: jobs: test: name: test / ${{ matrix.network }} (${{ matrix.partition }}/2) - runs-on: - group: Reth + runs-on: ubuntu-latest env: RUST_BACKTRACE: 1 strategy: matrix: - partition: [ 1, 2 ] - network: [ ethereum, optimism ] + partition: [1, 2] + network: [ethereum, optimism] timeout-minutes: 30 steps: - uses: actions/checkout@v4 @@ -54,8 +53,7 @@ jobs: state: name: Ethereum state tests - runs-on: - group: Reth + runs-on: ubuntu-latest env: RUST_LOG: info,sync=error RUST_BACKTRACE: 1 @@ -79,8 +77,7 @@ jobs: doc: name: doc tests (${{ matrix.network }}) - runs-on: - group: Reth + runs-on: ubuntu-latest env: RUST_BACKTRACE: 1 timeout-minutes: 30 @@ -104,7 +101,7 @@ jobs: name: unit success runs-on: ubuntu-latest if: always() - needs: [ test, state, doc ] + needs: [test, state, doc] timeout-minutes: 30 steps: - name: Decide whether the needed jobs succeeded or failed From e99d3b87381850ad6263fd7bc6c65c477f0e3d5b Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Wed, 29 May 2024 16:41:03 -0600 Subject: [PATCH 8/9] update runner --- .github/workflows/unit.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 8cae0f703b..1ab412e0dd 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -6,7 +6,7 @@ on: pull_request: merge_group: push: - branches: [main] + branches: [ main ] env: CARGO_TERM_COLOR: always @@ -19,13 +19,13 @@ concurrency: jobs: test: name: test / ${{ matrix.network }} (${{ matrix.partition }}/2) - runs-on: ubuntu-latest + runs-on: [ bnb-chain-ap-qa-cicd-runners ] env: RUST_BACKTRACE: 1 strategy: matrix: - partition: [1, 2] - network: [ethereum, optimism] + partition: [ 1, 2 ] + network: [ ethereum, optimism ] timeout-minutes: 30 steps: - uses: actions/checkout@v4 @@ -53,7 +53,7 @@ jobs: state: name: Ethereum state tests - runs-on: ubuntu-latest + runs-on: [ bnb-chain-ap-qa-cicd-runners ] env: RUST_LOG: info,sync=error RUST_BACKTRACE: 1 @@ -77,7 +77,7 @@ jobs: doc: name: doc tests (${{ matrix.network }}) - runs-on: ubuntu-latest + runs-on: [ bnb-chain-ap-qa-cicd-runners ] env: RUST_BACKTRACE: 1 timeout-minutes: 30 @@ -101,7 +101,7 @@ jobs: name: unit success runs-on: ubuntu-latest if: always() - needs: [test, state, doc] + needs: [ test, state, doc ] timeout-minutes: 30 steps: - name: Decide whether the needed jobs succeeded or failed From 3e66c7e2384de3f17d7a04b7176bed8b977c5045 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Thu, 30 May 2024 09:39:45 +0800 Subject: [PATCH 9/9] update runner --- .github/workflows/integration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 67b553965e..2764d038fc 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -19,7 +19,7 @@ concurrency: jobs: test: name: test / ${{ matrix.network }} - runs-on: ubuntu-latest + runs-on: [ bnb-chain-ap-qa-cicd-runners ] env: RUST_BACKTRACE: 1 strategy: @@ -56,7 +56,7 @@ jobs: name: sync / 100k blocks # Only run sync tests in merge groups if: github.event_name == 'merge_group' - runs-on: ubuntu-latest + runs-on: [ bnb-chain-ap-qa-cicd-runners ] env: RUST_LOG: info,sync=error RUST_BACKTRACE: 1