From 8796c13da413c2aa1d394b9cc9156cf1ef305602 Mon Sep 17 00:00:00 2001 From: Guillaume Babin-Tremblay Date: Thu, 25 Jul 2024 18:15:42 -0600 Subject: [PATCH] Fixed IBC tests --- unittests/finality_proof.hpp | 1 + unittests/svnn_ibc_tests.cpp | 29 ++++++++++-------- .../test-contracts/savanna/common/savanna.hpp | 7 +++-- unittests/test-contracts/savanna/ibc/ibc.abi | 6 +++- unittests/test-contracts/savanna/ibc/ibc.cpp | 2 +- unittests/test-contracts/savanna/ibc/ibc.wasm | Bin 69127 -> 69552 bytes 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/unittests/finality_proof.hpp b/unittests/finality_proof.hpp index 1af902cbaa..098eb019e5 100644 --- a/unittests/finality_proof.hpp +++ b/unittests/finality_proof.hpp @@ -245,6 +245,7 @@ namespace finality_proof { // compute digest for verification purposes digest_type finality_digest = fc::sha256::hash(finality_digest_data_v1{ .active_finalizer_policy_generation = is_genesis ? 1 : active_finalizer_policy.generation, + .pending_finalizer_policy_generation = is_genesis ? 1 : last_pending_finalizer_policy.generation, .finality_tree_digest = finality_root, .l2_commitments_digest = level_2_commitments_digest }); diff --git a/unittests/svnn_ibc_tests.cpp b/unittests/svnn_ibc_tests.cpp index e43f020cc0..f318c4da73 100644 --- a/unittests/svnn_ibc_tests.cpp +++ b/unittests/svnn_ibc_tests.cpp @@ -113,7 +113,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("qc_block", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) ("witness_hash", block_3_result.level_2_commitments_digest) ("finality_mroot", block_3_result.finality_root) ) @@ -129,7 +129,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("finality_data", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) ("witness_hash", block_2_result.level_2_commitments_digest) ("finality_mroot", block_2_result.finality_root) ) @@ -152,7 +152,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("qc_block", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) ("witness_hash", block_3_result.level_2_commitments_digest) ("finality_mroot", block_3_result.finality_root) ) @@ -187,7 +187,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("qc_block", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) ("witness_hash", block_4_result.level_2_commitments_digest) ("finality_mroot", block_4_result.finality_root) ) @@ -203,7 +203,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("finality_data", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) ("witness_hash", block_2_result.level_2_commitments_digest) ("finality_mroot", block_2_result.finality_root) ) @@ -229,7 +229,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("finality_data", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) ("witness_hash", block_2_result.level_2_commitments_digest) ("finality_mroot", block_2_result.finality_root) ) @@ -388,7 +388,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("qc_block", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) ("witness_hash", block_8_result.level_2_commitments_digest) ("finality_mroot", block_8_result.finality_root) ) @@ -404,7 +404,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("finality_data", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) ("witness_hash", block_7_result.level_2_commitments_digest) ("finality_mroot", block_7_result.finality_root) ) @@ -429,7 +429,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("finality_data", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) ("witness_hash", block_7_result.level_2_commitments_digest) ("finality_mroot", block_7_result.finality_root) ) @@ -493,7 +493,8 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("qc_block", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) + ("pending_finalizer_policy_generation", 2) ("witness_hash", block_11_result.level_2_commitments_digest) ("finality_mroot", block_11_result.finality_root) ) @@ -509,7 +510,8 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("finality_data", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) + ("pending_finalizer_policy_generation", 2) ("new_finalizer_policy", cluster.last_pending_finalizer_policy) ("witness_hash", block_10_result.level_3_commitments_digest) ("last_pending_finalizer_policy_start_num", block_10_result.last_pending_finalizer_policy_start_num ) @@ -541,7 +543,7 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("qc_block", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 2) + ("active_finalizer_policy_generation", 2) ("witness_hash", block_12_result.level_2_commitments_digest) ("finality_mroot", block_12_result.finality_root) ) @@ -557,7 +559,8 @@ BOOST_AUTO_TEST_SUITE(svnn_ibc) ("finality_data", mvo() ("major_version", 1) ("minor_version", 0) - ("finalizer_policy_generation", 1) + ("active_finalizer_policy_generation", 1) + ("pending_finalizer_policy_generation", 2) ("witness_hash", block_11_result.level_2_commitments_digest) ("finality_mroot", block_11_result.finality_root) ) diff --git a/unittests/test-contracts/savanna/common/savanna.hpp b/unittests/test-contracts/savanna/common/savanna.hpp index 7e86aaaea4..adc2cbe981 100644 --- a/unittests/test-contracts/savanna/common/savanna.hpp +++ b/unittests/test-contracts/savanna/common/savanna.hpp @@ -296,7 +296,8 @@ namespace savanna { uint32_t minor_version; //finalizer_policy_generation for this block - uint32_t finalizer_policy_generation; + uint32_t active_finalizer_policy_generation; + std::optional pending_finalizer_policy_generation; //Allows the contract to obtain knowledge about them and to record them in its internal state. std::optional new_finalizer_policy; @@ -343,9 +344,11 @@ namespace savanna { //internal representation of finality data struct block_finality_data_internal : block_finality_data { checksum256 resolved_witness_hash; + uint32_t pending_finalizer_policy_generation = 0; block_finality_data_internal(const block_finality_data& base) : block_finality_data(base){ resolved_witness_hash = base.resolve_witness(); + pending_finalizer_policy_generation = base.pending_finalizer_policy_generation.has_value() ? base.pending_finalizer_policy_generation.value() : active_finalizer_policy_generation; } checksum256 finality_digest() const { @@ -354,7 +357,7 @@ namespace savanna { return hash; } - EOSLIB_SERIALIZE(block_finality_data_internal, (major_version)(minor_version)(finalizer_policy_generation)(finality_mroot)(resolved_witness_hash)) + EOSLIB_SERIALIZE(block_finality_data_internal, (major_version)(minor_version)(active_finalizer_policy_generation)(pending_finalizer_policy_generation)(finality_mroot)(resolved_witness_hash)) }; //used in "heavy" proofs, where verification of finality digest is performed diff --git a/unittests/test-contracts/savanna/ibc/ibc.abi b/unittests/test-contracts/savanna/ibc/ibc.abi index 25b958fe24..85e3545a5e 100644 --- a/unittests/test-contracts/savanna/ibc/ibc.abi +++ b/unittests/test-contracts/savanna/ibc/ibc.abi @@ -97,9 +97,13 @@ "type": "uint32" }, { - "name": "finalizer_policy_generation", + "name": "active_finalizer_policy_generation", "type": "uint32" }, + { + "name": "pending_finalizer_policy_generation", + "type": "uint32?" + }, { "name": "new_finalizer_policy", "type": "finalizer_policy_input?" diff --git a/unittests/test-contracts/savanna/ibc/ibc.cpp b/unittests/test-contracts/savanna/ibc/ibc.cpp index 8cab262a36..7213f939a2 100644 --- a/unittests/test-contracts/savanna/ibc/ibc.cpp +++ b/unittests/test-contracts/savanna/ibc/ibc.cpp @@ -92,7 +92,7 @@ finalizer_policy_input ibc::_get_stored_finalizer_policy(const uint64_t finalize void ibc::_check_finality_proof(const finality_proof& finality_proof, const block_proof_of_inclusion& target_block_proof_of_inclusion){ //attempt to retrieve the stored policy with the correct generation number - finalizer_policy_input finalizer_policy = _get_stored_finalizer_policy(finality_proof.qc_block.finalizer_policy_generation); + finalizer_policy_input finalizer_policy = _get_stored_finalizer_policy(finality_proof.qc_block.active_finalizer_policy_generation); //verify QC. If QC is valid, it means that we have reached finality on the block referenced by the finality_mroot _check_qc(finality_proof.qc, block_finality_data_internal(finality_proof.qc_block).finality_digest(), finalizer_policy); diff --git a/unittests/test-contracts/savanna/ibc/ibc.wasm b/unittests/test-contracts/savanna/ibc/ibc.wasm index a5f302a8d75be9687f86e07c5544b884cb5032dd..328d916c8580132d3e14bb96cc6518f4dd7f0db3 100755 GIT binary patch delta 5874 zcmcIoeT-aH6@T~MHy?C%(^qA2vu){{x21gxQ_JVHHWc?(K5MlLK@1VtF3^Ir6iOvA zEeUT3i&P59(7Qs7O*)B9tRc#VC25IPrljJUZ0Q)F*{a|~+ps3ZOpPXMB+=hF_q~~A zgP36a=iPI^&OP^h{LZ=WseSI)es}E7w0!*^h?mXTBfaJux39#& z?%S(wuBwIuwbb#IZkpm<7e;%Puhu!MR0XZBsFJQb-ezBgvZC@SAA_MBRYf@^L8prH z?YOO@)pc3&UGH(x6Vtpaz%JV3r-r?+$$rZ!NL|;7Gl>Jucx!XmvP+coHBM2oFiuHl zOBifQBKj0Wq7AA~HRUR`%?eo-STUkXA?*oeS(yccUz%4|_RJAw?iyU5sR-gzH!lr- zZ}IBV3df96R2st57 za2`n{^o&Ej{5)Uuscps^+9I0f+e5v*tU#wvHEvy{SUXk@sMMFljzl^#@ec8q6z*>y-i*I)E)5y}G2GH4au%(~SmVrR+eq6r}w~;fkysfwi&b9Nk@le!;t& z6p$h_3GF8)a-i5CquGp(E|lO)FpdC4MiN%-!$C@iTk~1yogE>o-=F;c6&pJxgid)^ z2N}}7<1fkhSsgx5D#}aI!(ix(P=<7RC<{T>Y#Ll1L40)hRJIvWDL;Edr<2R!N@9(( znpzkUr;{n+&~6V#4hk$JS0@Ej(a9v8z361)4mA~l6}Zuu@TD)j5#gs`!*0Iv25ir; zMPp@Wec7k7%$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