Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): Make Web3 API server work with pruned data #838

Merged
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0dba582
Brush up `debug` namespace
slowli Jan 3, 2024
8123935
Sketch pruning checks in API server
slowli Jan 3, 2024
bf1b4db
Add basic tests for `debug` namespace
slowli Jan 4, 2024
695a6e2
Test `debug` endpoints with snapshot recovery
slowli Jan 4, 2024
0feb18f
Rework API server initialization
slowli Jan 4, 2024
41cce22
Make latest miniblock number optional in DAL
slowli Jan 5, 2024
1985632
Remove `BlocksWeb3Dal::get_sealed_l1_batch_number()`
slowli Jan 5, 2024
ebbf29d
Fix pending block resolution
slowli Jan 5, 2024
e9e4bda
Add TODO for propagating DB errors in `TxSender`
slowli Jan 5, 2024
ee99e9c
Check state pruning during `BlockArgs` initialization
slowli Jan 5, 2024
b25d751
Test basic methods after snapshot recovery
slowli Jan 5, 2024
3e84404
Fix getting starting miniblock number in notifiers
slowli Jan 8, 2024
504e87e
Test snapshot recovery with subscriptions
slowli Jan 8, 2024
6ed8cc0
Test snapshot recovery for filters
slowli Jan 8, 2024
f286151
Adapt L1 batch resolution for miniblocks
slowli Jan 8, 2024
a43fd8f
Test VM-related API methods
slowli Jan 8, 2024
0aab093
Update from upstream
slowli Jan 8, 2024
83221a1
Split off filter- and VM-related API tests
slowli Jan 9, 2024
cd5d8cc
Test `TxSender::get_expected_nonce()`
slowli Jan 9, 2024
0cfdbcb
Check L1 batch pruning in relevant `zks` methods
slowli Jan 9, 2024
91fd3ad
Adapt `next_nonce_by_initiator_account()` for snapshot recovery
slowli Jan 9, 2024
a5a53a3
Test `get_transaction_count()` method
slowli Jan 9, 2024
c1cca08
Fix resolution of `BlockNumber::Earliest`
slowli Jan 9, 2024
959ce08
Test `BlockArgs::new()`
slowli Jan 9, 2024
05a8c6e
Update from upstream
slowli Jan 9, 2024
fdc63da
Fix DB query for pending nonce
slowli Jan 10, 2024
377692f
Update from upstream
slowli Jan 16, 2024
3ced742
Update from upstream
slowli Jan 16, 2024
d382eb6
Revert reordering `derive`s
slowli Jan 17, 2024
b1bb73a
Refactor `BlockStartInfo`
slowli Jan 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test snapshot recovery with subscriptions
slowli committed Jan 8, 2024
commit 504e87ebf00013322cce74c04385f63b6fc2afb8
34 changes: 21 additions & 13 deletions core/lib/zksync_core/src/api_server/web3/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -190,20 +190,27 @@ trait HttpTest: Send + Sync {
network_config: &NetworkConfig,
storage: &mut StorageProcessor<'_>,
) -> anyhow::Result<()> {
if storage.blocks_dal().is_genesis_needed().await? {
ensure_genesis_state(
storage,
network_config.zksync_network_id,
&GenesisParams::mock(),
)
.await?;
}
Ok(())
default_prepare_storage(network_config, storage).await
}

async fn test(&self, client: &HttpClient, pool: &ConnectionPool) -> anyhow::Result<()>;
}

async fn default_prepare_storage(
network_config: &NetworkConfig,
storage: &mut StorageProcessor<'_>,
) -> anyhow::Result<()> {
if storage.blocks_dal().is_genesis_needed().await? {
ensure_genesis_state(
storage,
network_config.zksync_network_id,
&GenesisParams::mock(),
)
.await?;
}
Ok(())
}

async fn test_http_server(test: impl HttpTest) {
let pool = ConnectionPool::test_pool().await;
let network_config = NetworkConfig::for_tests();
@@ -304,6 +311,7 @@ async fn store_events(
start_idx: u32,
) -> anyhow::Result<(IncludedTxLocation, Vec<VmEvent>)> {
let new_miniblock = create_miniblock(miniblock_number);
let l1_batch_number = L1BatchNumber(miniblock_number);
storage
.blocks_dal()
.insert_miniblock(&new_miniblock)
@@ -316,28 +324,28 @@ async fn store_events(
let events = vec![
// Matches address, doesn't match topics
VmEvent {
location: (L1BatchNumber(1), start_idx),
location: (l1_batch_number, start_idx),
address: Address::repeat_byte(23),
indexed_topics: vec![],
value: start_idx.to_le_bytes().to_vec(),
},
// Doesn't match address, matches topics
VmEvent {
location: (L1BatchNumber(1), start_idx + 1),
location: (l1_batch_number, start_idx + 1),
address: Address::zero(),
indexed_topics: vec![H256::repeat_byte(42)],
value: (start_idx + 1).to_le_bytes().to_vec(),
},
// Doesn't match address or topics
VmEvent {
location: (L1BatchNumber(1), start_idx + 2),
location: (l1_batch_number, start_idx + 2),
address: Address::zero(),
indexed_topics: vec![H256::repeat_byte(1), H256::repeat_byte(42)],
value: (start_idx + 2).to_le_bytes().to_vec(),
},
// Matches both address and topics
VmEvent {
location: (L1BatchNumber(1), start_idx + 3),
location: (l1_batch_number, start_idx + 3),
address: Address::repeat_byte(23),
indexed_topics: vec![H256::repeat_byte(42), H256::repeat_byte(111)],
value: (start_idx + 3).to_le_bytes().to_vec(),
Loading