Skip to content

Commit

Permalink
fix(resharding): MissingTrieValue in tests (#12677)
Browse files Browse the repository at this point in the history
Partially applies the patch: #12597

It was failing for delayed receipt tests with
`MissingTrieValue(TrieStorage)` inside
`check_state_shard_uid_mapping_after_resharding`.
The reason is that trie access interface returns `None` for a key with
an empty value (which is the case for delayed receipts and negative
refcounts).
That was not caught up before the patch, because the
`check_state_shard_uid_mapping_after_resharding` was called after
resharding, but not in the end of the test (after gc kicked in).

**Changes**
This PR modifies the `check_state_shard_uid_mapping_after_resharding` to
not check entries with negative refcount.
The test is refactored so that the main loop does not finish an epoch
after resharding, but keeps running until gc kicks in.
For that, the code responsible for testing temporary account is moved to
a loop action,
and all loop actions are moved to a separate file for readability.

**Note**
`test_resharding_v3_yield_resume` is still failing with the original
patch: #12597
  • Loading branch information
staffik authored Jan 2, 2025
1 parent 23e6b81 commit 5749548
Show file tree
Hide file tree
Showing 9 changed files with 638 additions and 479 deletions.
4 changes: 2 additions & 2 deletions integration-tests/src/test_loop/tests/congestion_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn do_deploy_contract(
let code = near_test_contracts::rs_contract().to_vec();
let tx = deploy_contract(test_loop, node_datas, rpc_id, contract_id, code, 1);
test_loop.run_for(Duration::seconds(5));
check_txs(&*test_loop, node_datas, rpc_id, &[tx]);
check_txs(&test_loop.data, node_datas, rpc_id, &[tx]);
}

/// Call the contract from all accounts and wait until the transactions are executed.
Expand Down Expand Up @@ -144,7 +144,7 @@ fn do_call_contract(
txs.push(tx);
}
test_loop.run_for(Duration::seconds(20));
check_txs(&*test_loop, node_datas, &rpc_id, &txs);
check_txs(&test_loop.data, node_datas, &rpc_id, &txs);
}

/// The condition that can be used for the test loop to wait until the chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn deploy_contracts(
contracts.push(contract);
}
env.test_loop.run_for(Duration::seconds(2));
check_txs(&env.test_loop, &env.datas, rpc_id, &txs);
check_txs(&env.test_loop.data, &env.datas, rpc_id, &txs);
contracts
}

Expand Down Expand Up @@ -175,5 +175,5 @@ fn call_contracts(
}
}
env.test_loop.run_for(Duration::seconds(2));
check_txs(&env.test_loop, &env.datas, &rpc_id, &txs);
check_txs(&env.test_loop.data, &env.datas, &rpc_id, &txs);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn do_call_contract(env: &mut TestLoopEnv, rpc_id: &AccountId, contract_id: &Acc
nonce,
);
env.test_loop.run_for(Duration::seconds(5));
check_txs(&env.test_loop, &env.datas, rpc_id, &[tx]);
check_txs(&env.test_loop.data, &env.datas, rpc_id, &[tx]);
}

/// Tracks latest block heights and checks that all chunks are produced.
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/src/test_loop/tests/max_receipt_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn slow_test_max_receipt_size() {
&account0,
vec![0u8; 2_000_000],
account0_signer,
get_shared_block_hash(&env.datas, &env.test_loop),
get_shared_block_hash(&env.datas, &env.test_loop.data),
);
let large_tx_exec_res =
execute_tx(&mut env.test_loop, &rpc_id, large_tx, &env.datas, Duration::seconds(5));
Expand All @@ -43,7 +43,7 @@ fn slow_test_max_receipt_size() {
&account0,
near_test_contracts::rs_contract().into(),
&account0_signer,
get_shared_block_hash(&env.datas, &env.test_loop),
get_shared_block_hash(&env.datas, &env.test_loop.data),
);
run_tx(&mut env.test_loop, &rpc_id, deploy_contract_tx, &env.datas, Duration::seconds(5));

Expand All @@ -59,7 +59,7 @@ fn slow_test_max_receipt_size() {
"generate_large_receipt".into(),
r#"{"account_id": "account0", "method_name": "noop", "total_args_size": 3000000}"#.into(),
300 * TGAS,
get_shared_block_hash(&env.datas, &env.test_loop),
get_shared_block_hash(&env.datas, &env.test_loop.data),
);
run_tx(&mut env.test_loop, &rpc_id, large_receipt_tx, &env.datas, Duration::seconds(5));

Expand All @@ -73,7 +73,7 @@ fn slow_test_max_receipt_size() {
"generate_large_receipt".into(),
r#"{"account_id": "account0", "method_name": "noop", "total_args_size": 5000000}"#.into(),
300 * TGAS,
get_shared_block_hash(&env.datas, &env.test_loop),
get_shared_block_hash(&env.datas, &env.test_loop.data),
);
let too_large_receipt_tx_exec_res = execute_tx(
&mut env.test_loop,
Expand Down Expand Up @@ -115,7 +115,7 @@ fn slow_test_max_receipt_size() {
"sum_n".into(),
5_u64.to_le_bytes().to_vec(),
300 * TGAS,
get_shared_block_hash(&env.datas, &env.test_loop),
get_shared_block_hash(&env.datas, &env.test_loop.data),
);
let sum_4_res = run_tx(&mut env.test_loop, &rpc_id, sum_4_tx, &env.datas, Duration::seconds(5));
assert_eq!(sum_4_res, 10u64.to_le_bytes().to_vec());
Expand Down
Loading

0 comments on commit 5749548

Please sign in to comment.