Skip to content

Commit

Permalink
chore: nightly fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
allnil committed Oct 10, 2024
1 parent b98ae05 commit d3041b5
Show file tree
Hide file tree
Showing 20 changed files with 62 additions and 72 deletions.
7 changes: 3 additions & 4 deletions crates/ethereum/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ use alloc::vec::Vec;
use alloy_primitives::{Address, Bytes, TxKind, U256};
use reth_chainspec::{ChainSpec, Head};
use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes};
use reth_primitives::{transaction::FillTxEnv, Header, TransactionSigned};
use reth_primitives::{
constants::ETHEREUM_BLOCK_GAS_LIMIT, transaction::FillTxEnv, Header, TransactionSigned,
};
use revm_primitives::{
AnalysisKind, BlobExcessGasAndPrice, BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, Env, SpecId, TxEnv,
};
use reth_primitives::{
constants::ETHEREUM_BLOCK_GAS_LIMIT,
};
use std::sync::Arc;

mod config;
Expand Down
8 changes: 2 additions & 6 deletions crates/net/eth-wire-types/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@ impl FromIterator<PooledTransactionsElement> for PooledTransactions {

#[cfg(test)]
mod tests {
use std::ops::Deref;
use crate::{message::RequestPair, GetPooledTransactions, PooledTransactions};
use alloy_consensus::{TxEip1559, TxLegacy};
use alloy_primitives::{hex, Parity, TxKind, U256};
use alloy_primitives::{hex, hex::Buffer, Parity, TxKind, U256};
use alloy_rlp::{Decodable, Encodable};
use reth_chainspec::MIN_TRANSACTION_GAS;
use reth_primitives::{PooledTransactionsElement, Signature, Transaction, TransactionSigned};
use std::str::FromStr;
use alloy_primitives::hex::Buffer;
use std::{ops::Deref, str::FromStr};

#[test]
// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
Expand Down Expand Up @@ -386,8 +384,6 @@ mod tests {
message: PooledTransactions(message),
};



let decoded_transactions =
RequestPair::<PooledTransactions>::decode(&mut &data[..]).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion crates/node/core/src/args/txpool.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Transaction pool arguments
use std::sync::atomic::Ordering::SeqCst;
use crate::cli::config::RethTransactionPoolConfig;
use alloy_primitives::Address;
use clap::Args;
Expand All @@ -14,6 +13,7 @@ use reth_transaction_pool::{
TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER, TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT,
TXPOOL_SUBPOOL_MAX_TXS_DEFAULT,
};
use std::sync::atomic::Ordering::SeqCst;
/// Parameters for debugging purposes
#[derive(Debug, Clone, Args, PartialEq, Eq)]
#[command(next_help_heading = "TxPool")]
Expand Down
10 changes: 7 additions & 3 deletions crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,11 @@ pub mod serde_bincode_compat {

#[cfg(test)]
mod tests {
use crate::{transaction::{signature::Signature, TxEip1559, TxKind, TxLegacy}, Transaction, transaction, TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash};
use crate::{
transaction,
transaction::{signature::Signature, TxEip1559, TxKind, TxLegacy},
Transaction, TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash,
};
use alloy_eips::eip2718::{Decodable2718, Encodable2718};
use alloy_primitives::{address, b256, bytes, hex, Address, Bytes, Parity, B256, U256};
use alloy_rlp::{Decodable, Encodable, Error as RlpError};
Expand Down Expand Up @@ -1935,8 +1939,8 @@ mod tests {
// WVM: fixed hex bytes, MIN_TRANSACTION_GAS changed to 500k

// let mut buf = vec![];
// let expected = TransactionSigned::from_transaction_and_signature(transaction.clone(), signature);
// expected.encode(&mut buf);
// let expected = TransactionSigned::from_transaction_and_signature(transaction.clone(),
// signature); expected.encode(&mut buf);
// let out = hex::encode(buf);
// println!("{}",out);

Expand Down
3 changes: 1 addition & 2 deletions crates/transaction-pool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use reth_primitives::{
constants::{ETHEREUM_BLOCK_GAS_LIMIT, MIN_PROTOCOL_BASE_FEE},
EIP4844_TX_TYPE_ID,
};
use std::collections::HashSet;
use std::sync::atomic::Ordering::SeqCst;
use std::{collections::HashSet, sync::atomic::Ordering::SeqCst};

/// Guarantees max transactions for one sender, compatible with geth/erigon
pub const TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER: usize = 16;
Expand Down
3 changes: 2 additions & 1 deletion crates/transaction-pool/src/test_utils/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use alloy_primitives::{Address, Bytes, TxKind, B256, U256};
use rand::Rng;
use reth_chainspec::MAINNET;
use reth_primitives::{
constants::{MIN_PROTOCOL_BASE_FEE,get_latest_min_protocol_base_fee}, sign_message, Transaction, TransactionSigned,
constants::{get_latest_min_protocol_base_fee, MIN_PROTOCOL_BASE_FEE},
sign_message, Transaction, TransactionSigned,
};

/// A generator for transactions for testing purposes.
Expand Down
4 changes: 3 additions & 1 deletion crates/transaction-pool/tests/it/evict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
use alloy_primitives::{Address, B256};
use rand::distributions::Uniform;
use reth_primitives::constants::{get_latest_min_protocol_base_fee, MIN_PROTOCOL_BASE_FEE, ETHEREUM_BLOCK_GAS_LIMIT};
use reth_primitives::constants::{
get_latest_min_protocol_base_fee, ETHEREUM_BLOCK_GAS_LIMIT, MIN_PROTOCOL_BASE_FEE,
};
use reth_transaction_pool::{
error::PoolErrorKind,
test_utils::{
Expand Down
5 changes: 1 addition & 4 deletions wvm-apps/wvm-exexed/crates/lambda/src/lambda.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use reth::{
api::FullNodeComponents,
primitives::{TransactionSigned},
};
use reth::{api::FullNodeComponents, primitives::TransactionSigned};

use alloy_primitives::Address;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use alloy_primitives::Bytes;
use arweave_upload::ArweaveRequest;
use rbrotli::to_brotli;
use reth::{
primitives::{
revm_primitives::{Precompile, PrecompileError, PrecompileOutput, PrecompileResult},
},
use reth::primitives::revm_primitives::{
Precompile, PrecompileError, PrecompileOutput, PrecompileResult,
};
use reth_revm::{precompile::PrecompileErrors};
use reth_revm::precompile::PrecompileErrors;
use std::str::FromStr;
use alloy_primitives::{Bytes};

pub const PC_ADDRESS: u64 = 0x17;
pub const ARWEAVE_PC_BASE: u64 = 3_450;
Expand Down Expand Up @@ -62,10 +60,9 @@ fn arweave_upload(input: &Bytes, gas_limit: u64) -> PrecompileResult {
#[cfg(test)]
mod arupload_pc_tests {
use crate::inner::arweave_precompile::{arweave_upload, SOLANA_SILLY_PRIVATE_KEY};
use reth::primitives::{revm_primitives::PrecompileOutput};
use alloy_primitives::Bytes;
use reth::primitives::revm_primitives::PrecompileOutput;
use std::env;
use alloy_primitives::{Bytes};


#[test]
pub fn test_arweave_precompile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use crate::inner::{
graphql_util::{build_transaction_query, send_graphql},
util::{clean_gateway_url, download_tx, DEFAULT_ARWEAVE_TX_ENDPOINT},
};
use reth::primitives::{
revm_primitives::{Precompile, PrecompileError, PrecompileErrors, PrecompileResult},
use alloy_primitives::Bytes;
use reth::primitives::revm_primitives::{
Precompile, PrecompileError, PrecompileErrors, PrecompileResult,
};
use serde::{Deserialize, Serialize};
use alloy_primitives::Bytes;

pub const ARWEAVE_PC_READ_BASE: u64 = 10_000;

Expand Down Expand Up @@ -117,8 +117,8 @@ fn arweave_read(input: &Bytes, gas_limit: u64) -> PrecompileResult {
#[cfg(test)]
mod arweave_read_pc_tests {
use crate::inner::arweave_read_precompile::{arweave_read, parse_gateway_content};
use reth::primitives::{revm_primitives::PrecompileOutput};
use alloy_primitives::Bytes;
use reth::primitives::revm_primitives::PrecompileOutput;

#[test]
pub fn test_arweave_read_precompile() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use reth::primitives::{
revm_primitives::{Precompile, PrecompileOutput, PrecompileResult},
};
use alloy_primitives::Bytes;
use reth::primitives::revm_primitives::{Precompile, PrecompileOutput, PrecompileResult};

pub const HELLO_WORLD_PC: Precompile = Precompile::Standard(hello_world_pc);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ use crate::{
},
WVM_DATA_PUBLISHERS,
};
use alloy_primitives::Bytes;
use rbrotli::from_brotli;
use reth::primitives::{
revm_primitives::{Precompile, PrecompileOutput, PrecompileResult},
};
use reth::primitives::revm_primitives::{Precompile, PrecompileOutput, PrecompileResult};
use revm_primitives::{PrecompileError, PrecompileErrors};
use wevm_borsh::block::BorshSealedBlockWithSenders;
use alloy_primitives::Bytes;

pub const WVM_BLOCK_PC: Precompile = Precompile::Standard(wevm_read_block_pc);

Expand Down Expand Up @@ -242,8 +240,8 @@ fn wevm_read_block_pc(input: &Bytes, gas_limit: u64) -> PrecompileResult {
#[cfg(test)]
mod arweave_read_pc_tests {
use crate::inner::wevm_block_precompile::wevm_read_block_pc;
use reth::primitives::{revm_primitives::PrecompileOutput};
use alloy_primitives::Bytes;
use reth::primitives::revm_primitives::PrecompileOutput;

#[test]
pub fn test_read_wvm_block() {
Expand Down
4 changes: 2 additions & 2 deletions wvm-apps/wvm-exexed/crates/precompiles/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use reth_chainspec::ChainSpec;
use reth_ethereum_engine_primitives::EthPayloadAttributes;
use reth_node_ethereum::{
node::{
EthereumAddOns, EthereumConsensusBuilder, EthereumNetworkBuilder, EthereumPayloadBuilder,
EthereumPoolBuilder, EthereumEngineValidatorBuilder,
EthereumAddOns, EthereumConsensusBuilder, EthereumEngineValidatorBuilder,
EthereumNetworkBuilder, EthereumPayloadBuilder, EthereumPoolBuilder,
},
EthEngineTypes, EthExecutorProvider,
};
Expand Down
27 changes: 17 additions & 10 deletions wvm-apps/wvm-exexed/crates/precompiles/src/wevm_node_config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloy_primitives::{Address, Bytes, U256};
use parking_lot::RwLock;
use reth::{
api::{ConfigureEvm, ConfigureEvmEnv},
Expand All @@ -13,18 +14,18 @@ use reth::{
ContextPrecompile, ContextPrecompiles, Database, Evm, EvmBuilder, GetInspector,
},
};
use alloy_primitives::{Bytes, Address, U256};

use reth_evm_ethereum::{revm_spec_by_timestamp_after_merge};
use reth_evm_ethereum::revm_spec_by_timestamp_after_merge;

use reth_chainspec::{ChainSpec};
use reth::{
api::NextBlockEnvAttributes, chainspec::EthereumHardfork,
primitives::constants::EIP1559_INITIAL_BASE_FEE,
};
use reth_chainspec::ChainSpec;
use reth_node_ethereum::EthEvmConfig;
use revm_primitives::{BlobExcessGasAndPrice, BlockEnv, CfgEnv, EnvWithHandlerCfg};
use schnellru::{ByLength, LruMap};
use std::{collections::HashMap, sync::Arc};
use reth::api::NextBlockEnvAttributes;
use reth::chainspec::EthereumHardfork;
use reth::primitives::constants::EIP1559_INITIAL_BASE_FEE;

/// Type alias for the LRU cache used within the [`PrecompileCache`].
type PrecompileLRUCache = LruMap<(Bytes, u64), PrecompileResult>;
Expand Down Expand Up @@ -82,7 +83,6 @@ impl ConfigureEvmEnv for WvmEthEvmConfig {
self.evm_config.fill_cfg_env(cfg_env, header, total_difficulty);
}


fn next_cfg_and_block_env(
&self,
parent: &Self::Header,
Expand All @@ -92,7 +92,8 @@ impl ConfigureEvmEnv for WvmEthEvmConfig {
let cfg = CfgEnv::default().with_chain_id(self.evm_config.chain_spec().chain().id());

// ensure we're not missing any timestamp based hardforks
let spec_id = revm_spec_by_timestamp_after_merge(&self.evm_config.chain_spec(), attributes.timestamp);
let spec_id =
revm_spec_by_timestamp_after_merge(&self.evm_config.chain_spec(), attributes.timestamp);

// if the parent block did not have excess blob gas (i.e. it was pre-cancun), but it is
// cancun now, we need to set the excess blob gas to the default value
Expand All @@ -116,9 +117,15 @@ impl ConfigureEvmEnv for WvmEthEvmConfig {

// If we are on the London fork boundary, we need to multiply the parent's gas limit by the
// elasticity multiplier to get the new gas limit.
if self.evm_config.chain_spec().fork(EthereumHardfork::London).transitions_at_block(parent.number + 1) {
if self
.evm_config
.chain_spec()
.fork(EthereumHardfork::London)
.transitions_at_block(parent.number + 1)
{
let elasticity_multiplier = self
.evm_config.chain_spec()
.evm_config
.chain_spec()
.base_fee_params_at_timestamp(attributes.timestamp)
.elasticity_multiplier;

Expand Down
2 changes: 1 addition & 1 deletion wvm-apps/wvm-exexed/crates/wevm-borsh/src/address.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::b256::BorshB256;
use borsh::{BorshDeserialize, BorshSerialize};
use alloy_primitives::Address;
use borsh::{BorshDeserialize, BorshSerialize};
use std::io::{Read, Write};

pub struct BorshAddress(pub Address);
Expand Down
2 changes: 1 addition & 1 deletion wvm-apps/wvm-exexed/crates/wevm-borsh/src/b256.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use borsh::{BorshDeserialize, BorshSerialize};
use alloy_primitives::{B256, U256};
use borsh::{BorshDeserialize, BorshSerialize};
use std::io::{Read, Write};

pub struct BorshB256(pub B256);
Expand Down
4 changes: 2 additions & 2 deletions wvm-apps/wvm-exexed/crates/wevm-borsh/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};
use borsh::{BorshDeserialize, BorshSerialize};
use reth::primitives::{
Request, Requests, SealedBlock, BlockBody, SealedBlockWithSenders, Withdrawal, Withdrawals,
BlockBody, Request, Requests, SealedBlock, SealedBlockWithSenders, Withdrawal, Withdrawals,
};
use std::io::{Read, Write};

Expand Down Expand Up @@ -69,7 +69,7 @@ impl BorshDeserialize for BorshSealedBlock {
original_reqs
})
.map(|i| Requests(i)),
}
},
};

Ok(BorshSealedBlock(sealed_block))
Expand Down
2 changes: 1 addition & 1 deletion wvm-apps/wvm-exexed/crates/wevm-borsh/src/bloom.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use borsh::{BorshDeserialize, BorshSerialize};
use alloy_primitives::Bloom;
use borsh::{BorshDeserialize, BorshSerialize};
use std::io::{Read, Write};

pub struct BorshBloom(pub Bloom);
Expand Down
2 changes: 1 addition & 1 deletion wvm-apps/wvm-exexed/crates/wevm-borsh/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::{
b256::{BorshB256, BorshU256},
bloom::BorshBloom,
};
use alloy_primitives::{Bytes, B64};
use borsh::{BorshDeserialize, BorshSerialize};
use reth::primitives::{Header, SealedHeader};
use alloy_primitives::{B64, Bytes};
use std::io::{Read, Write};

pub struct BorshHeader(pub Header);
Expand Down
14 changes: 3 additions & 11 deletions wvm-apps/wvm-exexed/crates/wevm-borsh/src/signature.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use alloy_primitives::{Parity, Signature, U256};
use borsh::{BorshDeserialize, BorshSerialize};
use std::io::{Error, ErrorKind, Read, Write};
use alloy_primitives::{Parity, U256};
use alloy_primitives::Signature;



pub struct BorshSignature(pub Signature);

Expand All @@ -22,16 +19,11 @@ pub fn to_signature(bytes: &[u8]) -> std::io::Result<Signature> {
let s = U256::from_be_bytes(s_bytes);

let odd_y_parity = bytes[64] - 27;
let signature= Signature::new(
r,
s,
Parity::Parity(odd_y_parity != 0),
);
let signature = Signature::new(r, s, Parity::Parity(odd_y_parity != 0));

Ok(signature)
}


impl BorshSerialize for BorshSignature {
fn serialize<W: Write>(&self, writer: &mut W) -> std::io::Result<()> {
self.0.as_bytes().to_vec().serialize(writer)
Expand All @@ -53,7 +45,7 @@ mod signature_tests {

#[test]
pub fn test_sealed_header() {
let data = Signature::test_signature();
let data = Signature::test_signature();
let borsh_data = BorshSignature(data.clone());
let to_borsh = borsh::to_vec(&borsh_data).unwrap();
let from_borsh: BorshSignature = borsh::from_slice(to_borsh.as_slice()).unwrap();
Expand Down

0 comments on commit d3041b5

Please sign in to comment.