From 00dfef70190272f0a83724bf771570ef3713d62f Mon Sep 17 00:00:00 2001 From: Gus Gutoski Date: Wed, 5 Jun 2024 13:49:45 -0400 Subject: [PATCH] test: reference_tests use nontrivial payload, ns_table (#1557) reference_tests use nontrivial payload, ns_table --- data/header.bin | Bin 840 -> 804 bytes data/header.json | 14 ++++----- data/ns_table.bin | Bin 60 -> 24 bytes data/ns_table.json | 4 +-- sequencer/Cargo.toml | 1 + sequencer/src/reference_tests.rs | 52 ++++++++++++++++++++----------- 6 files changed, 43 insertions(+), 28 deletions(-) diff --git a/data/header.bin b/data/header.bin index 2cce5b430403d005646f781d45fd0818db319403..c1fa7a2dd05b02adbcdd070c7e1249b556d2d2fb 100644 GIT binary patch delta 254 zcmX@XwuEhi5~HG(g?aVIy}>3QtTkA8%%%6SEy)a6Wgyeh5%qM!*30j+=1+EJ)H2;Q zy`myw@te!;KF5?oxwwA`96Vfhvg5HDSF`7F3AO|C7VdlkPlT8fFj1p544GmKaEKQ9KQp`;)6Vpu6j8ZI9EKE{Tj8Y7f6U___&5bNA zQ&LkclZ?$$4U8?#OpKDuoSd zGfGJ`GwRO6K7WYbj3R3o#rv@}x-19M}GRC5bc eV{^llG*e?^3!o8cLKY?|i781bNfzcZP@@2T&`#h0 diff --git a/data/header.json b/data/header.json index 65082bd54..8868bc435 100644 --- a/data/header.json +++ b/data/header.json @@ -1,10 +1,10 @@ { "block_merkle_tree_root": "MERKLE_COMM~AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAQA", - "builder_commitment": "BUILDER_COMMITMENT~PfISPEAHYbCXqJ08RqlK74d9aSrtrZkKHdnoX7crymG5", + "builder_commitment": "BUILDER_COMMITMENT~upd4eFij7NNHTMYiVQoL-hDBw3bJiOMmCoNJxxgGwJ6h", "builder_signature": { - "r": "0xca39647d5e159ebf62e0efd163ddb2b7946f437948e6c31accdb5360a9f2da17", - "s": "0x610e51dced89ede20e3dcc5e9e26fff580738e785371df53389f2f84dadbdb87", - "v": 28 + "r": "0xc7b7c4062ada11d09530d759af4f2d9d84dd2d1ca6117299dee9b36e039642b6", + "s": "0x10cc3c7c0d0d69ba19348c720ee95cbb48470b9181cc32c9922af86b83fba9a2", + "v": 27 }, "chain_config": { "chain_config": { @@ -30,8 +30,8 @@ }, "l1_head": 124, "ns_table": { - "bytes": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "bytes": "AQAAAO7/wAAIBAAA" }, - "payload_commitment": "HASH~AazstQer_ho1SqgGT0r10_Gs0BnjfbPBHJdSO3HHbp29", + "payload_commitment": "HASH~Ojg3e_G9UzTwOygEDDcbvgakaVCqMByIiFrlkLXT72qf", "timestamp": 789 -} +} \ No newline at end of file diff --git a/data/ns_table.bin b/data/ns_table.bin index 40240ecb8c1db85301e13cd23ada87b634ac8b6c..82defd7bcf943131f0d72e98ab6d27121ba1d716 100644 GIT binary patch literal 24 ZcmZQzU}WH7fB;4y_3r-x1`ZYm1^^U40>}UW literal 60 PcmZQzU}P|0AP)cl3ibdp diff --git a/data/ns_table.json b/data/ns_table.json index 767edc5b0..6e29afa0b 100644 --- a/data/ns_table.json +++ b/data/ns_table.json @@ -1,3 +1,3 @@ { - "bytes": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" -} + "bytes": "AQAAAO7/wAAIBAAA" +} \ No newline at end of file diff --git a/sequencer/Cargo.toml b/sequencer/Cargo.toml index 624cc612b..662a96b82 100644 --- a/sequencer/Cargo.toml +++ b/sequencer/Cargo.toml @@ -17,6 +17,7 @@ required-features = ["testing"] escargot = "0.5.10" espresso-macros = { git = "https://github.com/EspressoSystems/espresso-macros.git", tag = "0.1.0" } hotshot-query-service = { workspace = true, features = ["testing"] } +hotshot-testing = { workspace = true } pretty_assertions = { workspace = true } rand = "0.8.5" reqwest = { workspace = true } diff --git a/sequencer/src/reference_tests.rs b/sequencer/src/reference_tests.rs index 76728eb8a..c5647cabe 100644 --- a/sequencer/src/reference_tests.rs +++ b/sequencer/src/reference_tests.rs @@ -23,14 +23,13 @@ use crate::{ block::tables::NameSpaceTable, state::FeeInfo, ChainConfig, FeeAccount, Header, L1BlockInfo, - Payload, SeqTypes, Transaction, TxTableEntryWord, ValidatedState, + Payload, Transaction, TxTableEntryWord, ValidatedState, }; use async_compatibility_layer::logging::{setup_backtrace, setup_logging}; use committable::Committable; use es_version::SequencerVersion; use hotshot_types::traits::{ - block_contents::vid_commitment, block_contents::TestableBlock, - signature_key::BuilderSignatureKey, BlockPayload, EncodeBytes, + block_contents::vid_commitment, signature_key::BuilderSignatureKey, BlockPayload, EncodeBytes, }; use jf_merkle_tree::MerkleTreeScheme; use pretty_assertions::assert_eq; @@ -42,11 +41,22 @@ use vbs::BinarySerializer; type Serializer = vbs::Serializer; -fn reference_ns_table() -> NameSpaceTable { - NameSpaceTable::from_bytes([0; 48]) +async fn reference_payload() -> Payload { + Payload::from_transactions( + vec![reference_transaction()], + &Default::default(), + &Default::default(), + ) + .await + .unwrap() + .0 +} + +async fn reference_ns_table() -> NameSpaceTable { + reference_payload().await.get_ns_table().clone() } -const REFERENCE_NS_TABLE_COMMITMENT: &str = "NSTABLE~GL-lEBAwNZDldxDpySRZQChNnmn9vNzdIAL8W9ENOuh_"; +const REFERENCE_NS_TABLE_COMMITMENT: &str = "NSTABLE~jqBfNUW1lSijWpKpPNc9yxQs28YckB80gFJWnHIwOQMC"; fn reference_l1_block() -> L1BlockInfo { L1BlockInfo { @@ -82,17 +92,17 @@ fn reference_fee_info() -> FeeInfo { const REFERENCE_FEE_INFO_COMMITMENT: &str = "FEE_INFO~xCCeTjJClBtwtOUrnAmT65LNTQGceuyjSJHUFfX6VRXR"; -fn reference_header() -> Header { +async fn reference_header() -> Header { let builder_key = FeeAccount::generated_from_seed_indexed(Default::default(), 0).1; let fee_info = reference_fee_info(); - let ns_table = reference_ns_table(); - let payload = as TestableBlock>::genesis(); + let payload = reference_payload().await; + let ns_table = payload.get_ns_table(); let payload_commitment = vid_commitment(&payload.encode(), 1); - let builder_commitment = payload.builder_commitment(&ns_table); + let builder_commitment = payload.builder_commitment(ns_table); let builder_signature = FeeAccount::sign_fee( &builder_key, fee_info.amount().as_u64().unwrap(), - &ns_table, + ns_table, &payload_commitment, ) .unwrap(); @@ -106,7 +116,7 @@ fn reference_header() -> Header { l1_finalized: Some(reference_l1_block()), payload_commitment, builder_commitment, - ns_table, + ns_table: ns_table.clone(), block_merkle_tree_root: state.block_merkle_tree.commitment(), fee_merkle_tree_root: state.fee_merkle_tree.commitment(), fee_info, @@ -115,7 +125,7 @@ fn reference_header() -> Header { } } -const REFERENCE_HEADER_COMMITMENT: &str = "BLOCK~6Ol30XYkdKaNFXw0QAkcif18Lk8V8qkC4M81qTlwL707"; +const REFERENCE_HEADER_COMMITMENT: &str = "BLOCK~mHlaknD1qKCz0UBtV2GpnqfO6gFqF5yN-9qkmLMRG3rp"; fn reference_transaction() -> Transaction { let payload: [u8; 1024] = std::array::from_fn(|i| (i % (u8::MAX as usize)) as u8); @@ -230,11 +240,11 @@ Actual: {actual} ); } -#[test] -fn test_reference_ns_table() { +#[async_std::test] +async fn test_reference_ns_table() { reference_test( "ns_table", - reference_ns_table(), + reference_ns_table().await, REFERENCE_NS_TABLE_COMMITMENT, ); } @@ -266,9 +276,13 @@ fn test_reference_fee_info() { ); } -#[test] -fn test_reference_header() { - reference_test("header", reference_header(), REFERENCE_HEADER_COMMITMENT); +#[async_std::test] +async fn test_reference_header() { + reference_test( + "header", + reference_header().await, + REFERENCE_HEADER_COMMITMENT, + ); } #[test]