Skip to content

ApiTester::new_from_config doesn't work properly in Electra environment #7005

@syjn99

Description

@syjn99

Background

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn get_events_electra() {
let mut config = ApiTesterConfig::default();
config.spec.altair_fork_epoch = Some(Epoch::new(0));
config.spec.bellatrix_fork_epoch = Some(Epoch::new(0));
config.spec.capella_fork_epoch = Some(Epoch::new(0));
config.spec.deneb_fork_epoch = Some(Epoch::new(0));
config.spec.electra_fork_epoch = Some(Epoch::new(0));
ApiTester::new_from_config(config)
.await
.test_get_events_electra()
.await;
}

I was working on #7003, and found that current unit test(get_events_electra) doesn't work properly due to the merkle_proof package issue.

Reproduction

#![cfg(not(debug_assertions))] // Tests are too slow in debug.

  1. Intentionally disabled #![cfg(not(debug_assertions))] for testing purpose.

  2. Run following command:

RUST_BACKTRACE=1 RUST_MIN_STACK=16777216 cargo test get_events_electra -p http_api --test bn_http_api_tests

Backtrace

...
thread 'tokio-runtime-worker' panicked at consensus/merkle_proof/src/lib.rs:317:9:
assertion failed: current_node.is_leaf()
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/panicking.rs:76:14
   2: core::panicking::panic
             at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/core/src/panicking.rs:148:5
   3: merkle_proof::MerkleTree::generate_proof
             at /Users/junsong/projects/ethereum-core/cl/lighthouse/consensus/merkle_proof/src/lib.rs:319:9
   4: types::beacon_state::BeaconState<E>::generate_proof
             at /Users/junsong/projects/ethereum-core/cl/lighthouse/consensus/types/src/beacon_state.rs:2631:26
   5: types::beacon_state::BeaconState<E>::compute_finalized_root_proof
             at /Users/junsong/projects/ethereum-core/cl/lighthouse/consensus/types/src/beacon_state.rs:2619:25
   6: beacon_chain::light_client_server_cache::LightClientCachedData<E>::from_state
             at /Users/junsong/projects/ethereum-core/cl/lighthouse/beacon_node/beacon_chain/src/light_client_server_cache.rs:424:13
   7: beacon_chain::light_client_server_cache::LightClientServerCache<T>::cache_state_data
             at /Users/junsong/projects/ethereum-core/cl/lighthouse/beacon_node/beacon_chain/src/light_client_server_cache.rs:70:31
   8: beacon_chain::beacon_chain::BeaconChain<T>::import_block
             at /Users/junsong/projects/ethereum-core/cl/lighthouse/beacon_node/beacon_chain/src/beacon_chain.rs:4038:13
   9: beacon_chain::beacon_chain::BeaconChain<T>::import_available_block::{{closure}}::{{closure}}
             at /Users/junsong/projects/ethereum-core/cl/lighthouse/beacon_node/beacon_chain/src/beacon_chain.rs:3749:21
...

Additional comment

pub fn generate_proof(

generate_proof function with index = 169, depth = 6 would fall current_node back into Zero node. So this makes assertion(is_leaf()) fail.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingelectraRequired for the Electra/Prague forklight-client

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions