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

Fix the height recorded for a new epoch #640

Merged
merged 3 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions apps/src/lib/node/ledger/shell/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,17 @@ mod test_queries {
/// Test if [`QueriesExt::can_send_validator_set_update`] behaves as
/// expected.
#[test]
#[ignore]
// TODO: we should fix this test to cope with epoch changes only
// happening at the first block of a new epoch. an erroneous change
// was introduced to the ledger, that updated the epoch correctly
// at the first block of the new epoch, but recorded `height + 1`
// instead of the actual height of the epoch change. since this
// test depended on that erroneous logic to pass, it's busted.
//
// linked issues:
// - <https://github.com/anoma/namada/issues/599>
// - <https://github.com/anoma/namada/issues/600>
fn test_can_send_validator_set_update() {
let (mut shell, _recv, _) = test_utils::setup_at_height(0u64);

Expand Down
18 changes: 13 additions & 5 deletions shared/src/ledger/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ where
let evidence_max_age_num_blocks: u64 = 100000;
self.block
.pred_epochs
.new_epoch(height + 1, evidence_max_age_num_blocks);
.new_epoch(height, evidence_max_age_num_blocks);
tracing::info!("Began a new epoch {}", self.block.epoch);
}
self.update_epoch_in_merkle_tree()?;
Expand Down Expand Up @@ -830,12 +830,20 @@ mod tests {
block_height + epoch_duration.min_num_of_blocks);
assert_eq!(storage.next_epoch_min_start_time,
block_time + epoch_duration.min_duration);
assert_eq!(storage.block.pred_epochs.get_epoch(block_height), Some(epoch_before));
assert_eq!(storage.block.pred_epochs.get_epoch(block_height + 1), Some(epoch_before.next()));
assert_eq!(
storage.block.pred_epochs.get_epoch(BlockHeight(block_height.0 - 1)),
Some(epoch_before));
assert_eq!(
storage.block.pred_epochs.get_epoch(block_height),
Some(epoch_before.next()));
} else {
assert_eq!(storage.block.epoch, epoch_before);
assert_eq!(storage.block.pred_epochs.get_epoch(block_height), Some(epoch_before));
assert_eq!(storage.block.pred_epochs.get_epoch(block_height + 1), Some(epoch_before));
assert_eq!(
storage.block.pred_epochs.get_epoch(BlockHeight(block_height.0 - 1)),
Some(epoch_before));
assert_eq!(
storage.block.pred_epochs.get_epoch(block_height),
Some(epoch_before));
}
// Last epoch should only change when the block is committed
assert_eq!(storage.last_epoch, epoch_before);
Expand Down
28 changes: 14 additions & 14 deletions wasm/checksums.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"tx_bridge_pool.wasm": "tx_bridge_pool.e21563260c03cfdab1f195878f49bf93722027ad26fcd097cfebbc5c4d279082.wasm",
"tx_from_intent.wasm": "tx_from_intent.7a56e31fb9977d230d5d601129fd11e67bf54159ab2d694184fc934ec2244314.wasm",
"tx_ibc.wasm": "tx_ibc.fe0036ec90159b3e704247201345ddff0aea5fa2e234e85d0e4df895b509d692.wasm",
"tx_init_account.wasm": "tx_init_account.313e8ab8c7eac72e75f916c67a6c7ec2f204f77d60d89e825acc78b4856a70c5.wasm",
"tx_init_nft.wasm": "tx_init_nft.5339cef3b36a3a31ea370cd67e6a43f99e03d13032bb786335976dd251988d4e.wasm",
"tx_init_proposal.wasm": "tx_init_proposal.d5598fcac82ebd5c618b84f4582992a2de80c2dfbb37f10fb574afaa36045ec2.wasm",
"tx_init_validator.wasm": "tx_init_validator.1e1374e7bcd0973cf7d3166085946ddf43443bb67037b56cfa6f2a5715d44ef2.wasm",
"tx_mint_nft.wasm": "tx_mint_nft.15b0e03bc27c41feda24918f56263f85d84b26f43be831998c6c619baa92a601.wasm",
"tx_transfer.wasm": "tx_transfer.2195fe962f9cb0c776d8518d0df9a450cc2521510d60423b57f0e2744ce38564.wasm",
"tx_unbond.wasm": "tx_unbond.a7313bb14d1c3a852630f86fc07d5e048e5df19a8f4be193d95c21fbeb49ae03.wasm",
"tx_from_intent.wasm": "tx_from_intent.a155e7bc5dd5502ce21387eb2378c004224d32b88b3c172a7c45f5d4da78a0e2.wasm",
"tx_ibc.wasm": "tx_ibc.f461624e4618db59ad42aee505011882d27dd4e31b02116071054e72a4529026.wasm",
"tx_init_account.wasm": "tx_init_account.b25a6b5babd91bb1101ba1dacef7c4d84acc3019dc1178ff4cdd0688a96e4395.wasm",
"tx_init_nft.wasm": "tx_init_nft.68d95a870c42023288cebe58510f9c32d3dcee3c58dbfd0122fbb45ba2619a9e.wasm",
"tx_init_proposal.wasm": "tx_init_proposal.a73ca65889db6a2c9c60d6352fcf72cec3631332cdba720ba231302fb4f95e6d.wasm",
"tx_init_validator.wasm": "tx_init_validator.061d5f7a94da2949ec44cf701fab8005daf1c8903b0ecd4b11e9605a04d9f971.wasm",
"tx_mint_nft.wasm": "tx_mint_nft.fb5de60d558232e07f2a1a2429b0589a925a7a11557a134c6057a14a853306fa.wasm",
"tx_transfer.wasm": "tx_transfer.5bc06525dacf355dbfbce567b1dbe519205d31b7f9cc10aef994a5ee230526ce.wasm",
"tx_unbond.wasm": "tx_unbond.3409ade177afa0e7ee2a4ad3f72cd7ecaa2955b7f90e81ce8446c847d370deb2.wasm",
"tx_update_vp.wasm": "tx_update_vp.f21d0233f9629193cea49c9c3742c2cac6764b09dd0adc7360d1f649543f2c39.wasm",
"tx_vote_proposal.wasm": "tx_vote_proposal.08daa0021aac28a1255ebb28005e1f07e01fc8118496934a0d46ee4456da7470.wasm",
"tx_withdraw.wasm": "tx_withdraw.0de22e367b9931045cf4c6b844cdd2e1390796e9cc7f8b15288d7753913e3ca9.wasm",
"vp_nft.wasm": "vp_nft.4656bec0cf0ff84b672605e45e25b16915a36ee982ffddf1ee0b7d6c72871e5a.wasm",
"vp_testnet_faucet.wasm": "vp_testnet_faucet.41c53f6536966989374dfb4b732b389919c0b980fba316ed842dc4b889b3abc1.wasm",
"tx_vote_proposal.wasm": "tx_vote_proposal.794f51beec3ddc4fae9ea169f08514fb04ad6229eaf2aa354c595618667fee09.wasm",
"tx_withdraw.wasm": "tx_withdraw.eb428dd309729e59bdb4b4f15eeee9183bd11e6db0a0570a73f45f2376e33ada.wasm",
"vp_nft.wasm": "vp_nft.adb4abb9213dc5c2c59035893214bb7f44d6ab3d0915ba2cb5481077deacc1c4.wasm",
"vp_testnet_faucet.wasm": "vp_testnet_faucet.1799952f853a0ba5fab662c28af1316817933d6e0bea629e603590053944dc00.wasm",
"vp_token.wasm": "vp_token.6eff1ea735d6b79e72e9f860a261e3eb91004b829cda2e3e3cc8f1b24e3b6715.wasm",
"vp_user.wasm": "vp_user.7829b1e5eb367785abc50bb7eaefa917665bec380495c162e83e08eaa57065f7.wasm"
"vp_user.wasm": "vp_user.a33860b4c4496c94dac96562dd9b8fa51f42118122021c28449a59b0e336601d.wasm"
}