Skip to content

Commit 4d324f5

Browse files
committed
just fix
1 parent 5fbc033 commit 4d324f5

File tree

3 files changed

+23
-44
lines changed

3 files changed

+23
-44
lines changed

crates/flashblocks-rpc/tests/layering.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ use alloy_genesis::GenesisAccount;
2424
use alloy_primitives::{Address, B256, U256};
2525
use eyre::Context;
2626
use rand::{SeedableRng, rngs::StdRng};
27-
use reth::api::NodeTypesWithDBAdapter;
28-
use reth::revm::db::{AccountState, BundleState, Cache, CacheDB, DbAccount, State};
27+
use reth::{
28+
api::NodeTypesWithDBAdapter,
29+
revm::db::{AccountState, BundleState, Cache, CacheDB, DbAccount, State},
30+
};
2931
use reth_db::{
3032
ClientVersion, DatabaseEnv, init_db,
3133
mdbx::{DatabaseArguments, KILOBYTE, MEGABYTE, MaxReadTransactionDuration},
@@ -35,11 +37,11 @@ use reth_optimism_chainspec::{BASE_MAINNET, OpChainSpec, OpChainSpecBuilder};
3537
use reth_optimism_node::OpNode;
3638
use reth_primitives_traits::SealedHeader;
3739
use reth_provider::{
38-
HeaderProvider, ProviderFactory, StateProviderFactory, providers::{BlockchainProvider, StaticFileProvider},
40+
HeaderProvider, ProviderFactory, StateProviderFactory,
41+
providers::{BlockchainProvider, StaticFileProvider},
3942
};
4043
use reth_testing_utils::generators::generate_keys;
41-
use revm::Database;
42-
use revm::primitives::KECCAK_EMPTY;
44+
use revm::{Database, primitives::KECCAK_EMPTY};
4345

4446
type NodeTypes = NodeTypesWithDBAdapter<OpNode, Arc<TempDatabase<DatabaseEnv>>>;
4547

@@ -170,10 +172,7 @@ fn layering_old_state_only_cannot_see_pending_state() -> eyre::Result<()> {
170172
let account = db.basic(alice_address)?.expect("account should exist");
171173

172174
// Old implementation sees canonical nonce (0), not any pending state
173-
assert_eq!(
174-
account.nonce, 0,
175-
"Old State-only layering can only see canonical state"
176-
);
175+
assert_eq!(account.nonce, 0, "Old State-only layering can only see canonical state");
177176

178177
Ok(())
179178
}
@@ -337,12 +336,8 @@ fn layering_cachedb_makes_pending_balance_visible() -> eyre::Result<()> {
337336
.provider
338337
.state_by_block_hash(harness.header.hash())
339338
.context("getting state provider")?;
340-
let canonical_balance2 =
341-
state_provider2.account_balance(&alice_address)?.unwrap_or(U256::ZERO);
342-
assert_eq!(
343-
canonical_balance, canonical_balance2,
344-
"Canonical state should be unchanged"
345-
);
339+
let canonical_balance2 = state_provider2.account_balance(&alice_address)?.unwrap_or(U256::ZERO);
340+
assert_eq!(canonical_balance, canonical_balance2, "Canonical state should be unchanged");
346341

347342
Ok(())
348343
}
@@ -409,10 +404,7 @@ fn layering_bundle_prestate_makes_pending_nonce_visible() -> eyre::Result<()> {
409404

410405
// Read through State without prestate - should see canonical nonce (0)
411406
let account2 = db_without_prestate.basic(alice_address)?.expect("account should exist");
412-
assert_eq!(
413-
account2.nonce, 0,
414-
"State without bundle_prestate should see canonical nonce"
415-
);
407+
assert_eq!(account2.nonce, 0, "State without bundle_prestate should see canonical nonce");
416408

417409
Ok(())
418410
}

crates/flashblocks-rpc/tests/state.rs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -865,18 +865,10 @@ async fn test_eth_call_sees_flashblock_state_changes() {
865865

866866
// Flashblock 1: Alice sends a large amount to Bob
867867
let transfer_to_bob = 1_000_000_000_000_000_000u128; // 1 ETH
868-
let tx = test.build_transaction_to_send_eth_with_nonce(
869-
User::Alice,
870-
User::Bob,
871-
transfer_to_bob,
872-
0,
873-
);
874-
test.send_flashblock(
875-
FlashblockBuilder::new(&test, 1)
876-
.with_transactions(vec![tx])
877-
.build(),
878-
)
879-
.await;
868+
let tx =
869+
test.build_transaction_to_send_eth_with_nonce(User::Alice, User::Bob, transfer_to_bob, 0);
870+
test.send_flashblock(FlashblockBuilder::new(&test, 1).with_transactions(vec![tx]).build())
871+
.await;
880872

881873
// Verify via state overrides that Bob received the funds
882874
let overrides = test
@@ -928,27 +920,20 @@ async fn test_sequential_nonces_across_flashblocks() {
928920
// Flashblock 1: Alice sends to Bob with nonce 0
929921
let tx_nonce_0 = test.build_transaction_to_send_eth_with_nonce(User::Alice, User::Bob, 1000, 0);
930922
test.send_flashblock(
931-
FlashblockBuilder::new(&test, 1)
932-
.with_transactions(vec![tx_nonce_0])
933-
.build(),
923+
FlashblockBuilder::new(&test, 1).with_transactions(vec![tx_nonce_0]).build(),
934924
)
935925
.await;
936926

937927
// Verify flashblock 1 was processed - Alice's pending nonce should now be 1
938928
let alice_state = test.account_state(User::Alice);
939-
assert_eq!(
940-
alice_state.nonce, 1,
941-
"After flashblock 1, Alice's pending nonce should be 1"
942-
);
929+
assert_eq!(alice_state.nonce, 1, "After flashblock 1, Alice's pending nonce should be 1");
943930

944931
// Flashblock 2: Alice sends to Charlie with nonce 1
945932
// This will FAIL if the execution layer can't see flashblock 1's state change
946933
let tx_nonce_1 =
947934
test.build_transaction_to_send_eth_with_nonce(User::Alice, User::Charlie, 2000, 1);
948935
test.send_flashblock(
949-
FlashblockBuilder::new(&test, 2)
950-
.with_transactions(vec![tx_nonce_1])
951-
.build(),
936+
FlashblockBuilder::new(&test, 2).with_transactions(vec![tx_nonce_1]).build(),
952937
)
953938
.await;
954939

crates/metering/src/tests/meter.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ use alloy_primitives::{Address, B256, Bytes, U256, keccak256};
77
use eyre::Context;
88
use op_alloy_consensus::OpTxEnvelope;
99
use rand::{SeedableRng, rngs::StdRng};
10-
use reth::revm::db::{BundleState, Cache};
11-
use reth::{api::NodeTypesWithDBAdapter, chainspec::EthChainSpec};
10+
use reth::{
11+
api::NodeTypesWithDBAdapter,
12+
chainspec::EthChainSpec,
13+
revm::db::{BundleState, Cache},
14+
};
1215
use reth_db::{DatabaseEnv, test_utils::TempDatabase};
1316
use reth_optimism_chainspec::{BASE_MAINNET, OpChainSpec, OpChainSpecBuilder};
1417
use reth_optimism_node::OpNode;
@@ -465,4 +468,3 @@ fn meter_bundle_requires_correct_layering_for_pending_nonce() -> eyre::Result<()
465468

466469
Ok(())
467470
}
468-

0 commit comments

Comments
 (0)