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

chore: rewrite block payload #1499

Merged
merged 237 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 219 commits
Commits
Show all changes
237 commits
Select commit Hold shift + click to select a range
1e30509
new struct Payload2
ggutoski Apr 3, 2024
8869999
WIP new fns usize_to_bytes, max_from_byte_len with tests
ggutoski Apr 3, 2024
8147b36
implement NamespaceBuider
ggutoski Apr 4, 2024
0a0d581
WIP begin implementing from_transactions
ggutoski Apr 4, 2024
f6f4552
dead end: const generics not stable in Rust https://stackoverflow.com…
ggutoski Apr 4, 2024
6ba8d47
finish impl for from_transactions, use macro_rules to generalize usiz…
ggutoski Apr 4, 2024
32c584a
WIP friendly deserializers
ggutoski Apr 5, 2024
499c357
generalized friendly deserializer
ggutoski Apr 5, 2024
570109a
usize_from_bytes const generic param, add xxx_from_bytes functions
ggutoski Apr 5, 2024
ea4100d
impl namespace_with_proof and some helpers
ggutoski Apr 5, 2024
f301d52
WIP test infra for namespace proofs
ggutoski Apr 5, 2024
86f8957
tweak test
ggutoski Apr 5, 2024
de406c9
Payload2:namespace_with_proof pass tests (yay)
ggutoski Apr 6, 2024
ed9364c
don't double count dupliate namespace ids
ggutoski Apr 8, 2024
fbd0e5a
tidy
ggutoski Apr 8, 2024
ea6347e
restore block.rs from main, new file block2.rs
ggutoski Apr 8, 2024
ed5f6b4
move mod tx_table to separate file payload_bytes.rs
ggutoski Apr 8, 2024
0e2d58e
rename block2::Payload2 -> Payload
ggutoski Apr 8, 2024
9c689d7
set Payload::ns_iter() Item to NamespaceId
ggutoski Apr 8, 2024
8b7f90c
move namespace iterator to a separate file
ggutoski Apr 8, 2024
f5fcc54
rename payload2 -> ns_payload_builder
ggutoski Apr 8, 2024
e7707df
visibility tweaks for ns_iter
ggutoski Apr 8, 2024
f88b5cc
new fn verify_namespace_proof, temporary re-use of old parse_ns_paylo…
ggutoski Apr 8, 2024
905e829
move namespace_with_proof and test to ns_proof.rs, use new verify_nam…
ggutoski Apr 8, 2024
074aa98
move Payload::ns_iter, etc to ns_iter.rs
ggutoski Apr 8, 2024
f4fde59
rename ns_payload_builder -> ns_payload
ggutoski Apr 8, 2024
390841b
new mod tx_iter, a proper impl for parse_ns_payload
ggutoski Apr 8, 2024
c000916
WIP combined iterator for QueryablePayload
ggutoski Apr 9, 2024
47ff5dd
move the combined iterator to iter.rs, delete the extra namespace ite…
ggutoski Apr 9, 2024
023da80
stub impl of QueryablePayload for Payload
ggutoski Apr 11, 2024
b2a1dd0
more stubs, tidy, new file tx_proof.rs
ggutoski Apr 11, 2024
065ee87
fix bug in TxIter, fix test
ggutoski Apr 11, 2024
33c5d4b
impl Payload::transaction with test
ggutoski Apr 11, 2024
4638c8c
move tests to new file test.rs
ggutoski Apr 11, 2024
6260e92
tidy and comments
ggutoski Apr 12, 2024
b1fb534
NsProof do not store VID common data
ggutoski Apr 12, 2024
8351972
tidying and stub
ggutoski Apr 14, 2024
17496f5
new fn tx_table_range with doc
ggutoski Apr 14, 2024
b84a87f
impl transaction_with_proof, still pretty messy tho
ggutoski Apr 17, 2024
13c3630
WIP tx proof only for num_txs
ggutoski Apr 20, 2024
97868f6
fix bug in iter, fix test
ggutoski Apr 22, 2024
a2eef4b
test: verify transaction proofs
ggutoski Apr 22, 2024
e9128ea
major rework of ns_iter: new struct NsTable, NsIter::Item is now just…
ggutoski Apr 24, 2024
c03550c
newtype NsIndex
ggutoski Apr 24, 2024
7b4005e
TxIndex is now a serialized index, newtype NsPayload with awesome hel…
ggutoski Apr 25, 2024
3278884
fix name _max_from_byte_len2 -> _max_from_byte_len
ggutoski Apr 25, 2024
2d2d48b
xxx_from_bytes allow small byte lengths
ggutoski Apr 25, 2024
249179b
NsIndex in serialized form like TxIndex
ggutoski Apr 25, 2024
c5ebf08
move tx_iter mod into ns_payload to enable private data in TxIndex
ggutoski Apr 25, 2024
06f337c
rename module ns_iter -> ns_table
ggutoski Apr 25, 2024
505dc47
tweak todo comments
ggutoski Apr 25, 2024
ba68eae
move ns_payload, ns_proof, tx_proof modules inside ns_table
ggutoski Apr 25, 2024
fa4956a
tidy
ggutoski Apr 25, 2024
9d76178
put TxIndex in a new mod tx_iter, move NsPayload::read_tx_offset into…
ggutoski Apr 25, 2024
f5f5e9a
add tx table range proof to TxProof
ggutoski Apr 25, 2024
d408afd
NsPayload now a DST, add newtype NsPayloadOwned so that it's to NsPay…
ggutoski Apr 26, 2024
01508fb
untested: TxProof::verify check tx table proof
ggutoski Apr 26, 2024
cc42c9d
dumbest bug ever
ggutoski Apr 29, 2024
9d6dbb6
TxProof::verify now check tx payload proof (yay)
ggutoski Apr 29, 2024
3de0f11
tidy: new module ns_iter like tx_iter, new method NsTable::read_ns_of…
ggutoski Apr 29, 2024
c826e68
new struct NsPayloadRange with helpers
ggutoski Apr 29, 2024
0babfd9
WIP tweak tx_payload_range[_relative]
ggutoski Apr 29, 2024
6cb3106
make NsPayloadRange a Range<usize>
ggutoski Apr 29, 2024
7770603
WIP prep for experiments with NsPayload
ggutoski Apr 30, 2024
8cbf349
add range field to NsPayload, it can no longer be a DST (boo)
ggutoski May 1, 2024
532ae6b
revert back to DST for NsPayload
ggutoski May 2, 2024
ad05e92
move tx_payload_range method from NsPayload to NsPayloadRange, add ar…
ggutoski May 2, 2024
65430e8
move modules ns_proof, tx_proof from ns_table up to block
ggutoski May 2, 2024
81377ee
move module ns_payload_range to its own file
ggutoski May 2, 2024
df6e12e
Index fields private
ggutoski May 2, 2024
99bf8bb
move module ns_iter to its own file
ggutoski May 2, 2024
1362448
move module tx_iter to its own file
ggutoski May 2, 2024
626ee91
newtype NumTxs
ggutoski May 2, 2024
7e4dfa1
manual serde impl for NumTxs
ggutoski May 2, 2024
882eac4
NsPayloadRange::tx_payload_range arg type change usize -> NumTxs
ggutoski May 3, 2024
3e66e93
new struct TxTableEntries
ggutoski May 3, 2024
c3391a9
manual serde impl for TxTableEntries
ggutoski May 3, 2024
30e06fc
tidy ns_table
ggutoski May 3, 2024
05526f7
move module num_txs into its own file
ggutoski May 3, 2024
20999a0
move module tx_table_entries to its own file
ggutoski May 3, 2024
d17ab52
remove pub(crate) from NsPayloadRange newtype field
ggutoski May 3, 2024
69b146b
add TODOs, ugh Rust is killing me
ggutoski May 3, 2024
0cb6cec
TxIndex newtype from array to usize
ggutoski May 6, 2024
f60cb77
NsIndex newtype from array to usize
ggutoski May 6, 2024
456e9b4
move module num_txs up to block, experiment with access key design pa…
ggutoski May 6, 2024
736e390
move module ns_iter up to block
ggutoski May 6, 2024
70da541
move module tx_table_entries up to block
ggutoski May 7, 2024
f245b60
move module tx_iter up to block
ggutoski May 7, 2024
53aab56
move module ns_payload up to block
ggutoski May 7, 2024
3898de1
move module ns_payload_range up to block
ggutoski May 7, 2024
abb462f
move some NsTable impls into ns_table module
ggutoski May 7, 2024
845d64b
NsTable member private
ggutoski May 7, 2024
3c701b5
move some impl Payload to block module
ggutoski May 8, 2024
30a537f
move NsProof construction from Payload to NsProof
ggutoski May 8, 2024
34313fc
move TxProof construction from Payload to TxProof
ggutoski May 8, 2024
d61fe3a
move struct Payload to a new module payload
ggutoski May 8, 2024
a9f25fe
visibility restrictions to payload module
ggutoski May 8, 2024
e5ae1aa
oops
ggutoski May 8, 2024
e705ea9
delete num_txs_as_bytes from payload_bytes
ggutoski May 8, 2024
80e7b3e
delete num_txs_from_bytes from payload_bytes
ggutoski May 8, 2024
56b9581
delete tx_offset_as_bytes from payload_bytes
ggutoski May 8, 2024
9aa3743
delete tx_offset_from_bytes from payload_bytes
ggutoski May 8, 2024
aabeaea
delete num_nss_as_bytes from payload_bytes
ggutoski May 8, 2024
88221e0
delete num_nss_from_bytes from payload_bytes
ggutoski May 8, 2024
93e79eb
delete ns_offset_as_bytes from payload_bytes
ggutoski May 8, 2024
3791a9b
delete ns_offset_from_bytes from payload_bytes
ggutoski May 8, 2024
e03b304
delete ns_offset_[as|from]_bytes from payload_bytes
ggutoski May 8, 2024
e5c7329
tweak: Payload::ns_payload re-use ns_payload_range
ggutoski May 8, 2024
65a1946
move byte len constants to block module
ggutoski May 8, 2024
b6923b3
rename module payload_bytes -> uint_bytes
ggutoski May 8, 2024
38cc08a
tidy, minor refactor new function usize_fits
ggutoski May 9, 2024
b924c56
replace NsTable::num_nss_with_duplicates -> in_bounds, reflect the ch…
ggutoski May 9, 2024
0700d8b
check tx index in TxProof::new, new method NsPayload::in_bounds
ggutoski May 9, 2024
fed56ea
WIP new model for NsPayload[Range]
ggutoski May 10, 2024
485c27a
WIP read_tx_offset
ggutoski May 10, 2024
7846533
new traits AsBytes, BytesReader, new test for TxProof2
ggutoski May 10, 2024
52454f2
PoC TxTableEntries in the new model
ggutoski May 10, 2024
9838259
tidy, rename
ggutoski May 13, 2024
8a2fe89
remove const generic param from AsPayloadBytes trait
ggutoski May 13, 2024
f18f63c
new structs NumTxs2, TxTableEntries2 using traits AsPayloadBytes
ggutoski May 13, 2024
1497096
add tx payload range to TxProof2
ggutoski May 13, 2024
40b89ad
error checking in TxProof::new
ggutoski May 13, 2024
f96d3b0
TxProof::verify: add ns_table arg, remove ns_payload_range from proof…
ggutoski May 13, 2024
423fc0a
derive serde for types in TxProof2
ggutoski May 13, 2024
1b9c9c4
delete old type TxProof in favor of TxProof2
ggutoski May 13, 2024
4b282fe
NsProofExistence use NsPayloadOwned2 instead of NsPayloadOwned
ggutoski May 14, 2024
f66fecc
Iter use TxIter::new2 instead of new (progress toward switching from …
ggutoski May 14, 2024
5fc5d62
move NamespacePayloadBuilder to module newtypes
ggutoski May 14, 2024
d1374ca
delete module ns_payload_range
ggutoski May 14, 2024
800f4d1
delete old modules
ggutoski May 14, 2024
81f27c1
newtype NsPayloadByteLen
ggutoski May 14, 2024
95bdbec
newtype NumTxsChecked
ggutoski May 14, 2024
f7e4714
move tx_table_entries_range_relative into TxTableEntriesRange::new
ggutoski May 14, 2024
216a1d1
move module tx_iter into newtypes
ggutoski May 15, 2024
811f7a9
impl AsPayloadBytes for TxIndex
ggutoski May 15, 2024
1a5fd29
WIP test fails: AsPayloadBytes new param T
ggutoski May 15, 2024
509695b
fix test, but AsPayloadBytes trait is now unusable (boo)
ggutoski May 15, 2024
a6c0065
fix TxTableEntries deserialization
ggutoski May 15, 2024
42e96dd
delete unneeded stuff
ggutoski May 15, 2024
dd78148
rename a bunch of types in module newtypes
ggutoski May 15, 2024
cdad7bb
make AsPayloadBytes readable and rename it to FromPayloadBytes
ggutoski May 15, 2024
3230029
tidy and rename
ggutoski May 15, 2024
c6077a9
rename ns_payload[_range]2.rx -> without the 2
ggutoski May 15, 2024
3e090e1
tidy and renaming
ggutoski May 15, 2024
2d57bdb
newtype PayloadByteLen
ggutoski May 15, 2024
0305101
tidy and docs
ggutoski May 15, 2024
792771b
tidy ns_table
ggutoski May 15, 2024
764404d
tidy payload
ggutoski May 15, 2024
d7395fd
fix macro bytes_serde_impl
ggutoski May 15, 2024
2dcea14
delete ns_iter.rs, move contents to ns_table.rs
ggutoski May 15, 2024
74f9f8d
restrict visibility of magic constants to a single file (yay)
ggutoski May 15, 2024
f76859c
tidy ns_payload
ggutoski May 15, 2024
58ff930
replace NsPayloadRange::offset with block_payload_range, simplify NsP…
ggutoski May 15, 2024
3c8ee26
tidy tx_proof, rename some things
ggutoski May 16, 2024
0f6284b
tidy
ggutoski May 16, 2024
dc86260
new method export_tx, in prep for reduced visibility
ggutoski May 16, 2024
3eb0444
fix use statements
ggutoski May 16, 2024
fb5f327
new module full_payload
ggutoski May 16, 2024
a215a9c
WIP new module namespace_payload
ggutoski May 16, 2024
46e75f1
move tx_proof, iter to namespace_payload; add helpers to avoid excess…
ggutoski May 16, 2024
d676990
new helper Payload::ns_payload
ggutoski May 16, 2024
7329c27
doc for bytes_serde_impl macro
ggutoski May 21, 2024
62ee02e
move ns_payload_traits module into newtypes
ggutoski May 21, 2024
532aa3a
rename module newtypes -> types
ggutoski May 21, 2024
11bd8c1
WIP merge main
ggutoski May 21, 2024
18813ad
fix build after merge main
ggutoski May 22, 2024
e4ff160
WIP swap out block for block2
ggutoski May 22, 2024
e184e8c
WIP fix test_namespace_query for block2
ggutoski May 23, 2024
2125cc5
WIP fix nasty_client except for NsIndex serialization issue
ggutoski May 23, 2024
8375b59
fix nasty-client for new block2, appease clippy
ggutoski May 23, 2024
88f957e
Merge branch 'main' into gg/1076
ggutoski May 23, 2024
b0fe672
fix reference test for new ns table format
ggutoski May 23, 2024
10fda30
fix test demo, tidy
ggutoski May 23, 2024
5181105
accounting for block byte length limit
ggutoski May 23, 2024
f63421e
temporary hack to pass tests
ggutoski May 23, 2024
e6903db
set forge-std git submodule to correct commit
ggutoski May 24, 2024
8da185e
fix test_message_compat
ggutoski May 24, 2024
4be3eee
failing test for large namespace ids
ggutoski May 24, 2024
f4b3cb5
single-character bug fix (damn that feels good)
ggutoski May 24, 2024
961a31e
fix doctest
ggutoski May 24, 2024
9fa09f1
update reference tests (again)
ggutoski May 24, 2024
159f87e
add test enforce_max_block_size
ggutoski May 24, 2024
ef9262b
delete old block module
ggutoski May 24, 2024
29dd485
tidy TODOs, some general tidying
ggutoski May 24, 2024
eb8a6aa
NsTable::read_ns_id check index in bounds
ggutoski May 24, 2024
84b112f
NsTable::ns_range check index in bounds
ggutoski May 24, 2024
0e7c0cf
use read_ns_id_unchecked in NsIter
ggutoski May 24, 2024
6c74929
revert NsTable::ns_range to unchecked and restrict visibility
ggutoski May 24, 2024
5f82526
revert NsTable::read_ns_id to unchecked
ggutoski May 24, 2024
de3f461
re-arrange methods
ggutoski May 24, 2024
88c30ab
NsTable::as_bytes_slice restrict visibility
ggutoski May 25, 2024
57997a0
delete NsTable::as_bytes_slice in favor of Encode trait
ggutoski May 25, 2024
acd63f9
delete Payload::as_byte_slice in favor of Encode trait
ggutoski May 25, 2024
efc4159
tidy PayloadByteLen
ggutoski May 25, 2024
42abab3
restrict visibility for NsIter
ggutoski May 25, 2024
802a2cb
restrict visibility of PayloadByteLen
ggutoski May 25, 2024
5aedcc2
restrict visibility of NsPayload
ggutoski May 25, 2024
3d23823
restrict visibility of NsPayloadRange
ggutoski May 25, 2024
53f95e2
restrict visibility of NsPayloadBuilder
ggutoski May 25, 2024
ba3f016
restrict visibility of TxIndex, TxIter
ggutoski May 25, 2024
32f1b2f
Merge branch 'main' into gg/1076
ggutoski May 25, 2024
d95c721
rename module block2 -> block
ggutoski May 25, 2024
46bbe9a
rename ns_payload_unchecked -> ns_payload
ggutoski May 25, 2024
687e324
remove obsolete todo
ggutoski May 27, 2024
9418f78
Merge branch 'main' into gg/1076
ggutoski May 27, 2024
5ca8853
Merge branch 'main' into gg/1076
ggutoski May 27, 2024
b593a96
revert https://github.com/EspressoSystems/espresso-sequencer/pull/150…
ggutoski May 27, 2024
5c9fe51
detailed specification rustdoc for Payload, NsTable
ggutoski May 28, 2024
311a7f3
detailed specification in rustdoc for namespace payload
ggutoski May 28, 2024
9d9bb1c
rename Payload::payload -> ns_payloads
ggutoski May 28, 2024
8a0543e
merge main, resolve conflicts
ggutoski May 29, 2024
f907be5
NsProof do not prove non-existence
ggutoski May 29, 2024
01ccf24
Payload::is_consistent return Result instead of bool, eliminate panic
ggutoski May 29, 2024
ce7d205
Merge branch 'main' into gg/1076
ggutoski May 29, 2024
d7fa607
NsProof::new take NsIndex arg instead of NamespaceId
ggutoski May 29, 2024
17b1a64
NamespaceProofQueryData::proof is now optional
ggutoski May 29, 2024
6cd90dc
fix: NsProof::ns_proof for empty payload should be None
ggutoski May 29, 2024
9997b8a
Merge branch 'main' into gg/1076
ggutoski May 29, 2024
1a9506b
Merge branch 'main' into gg/1076
ggutoski May 29, 2024
a1269fa
address https://github.com/EspressoSystems/espresso-sequencer/pull/14…
ggutoski May 29, 2024
f8d5182
merge main, resolve conflicts
ggutoski Jun 6, 2024
8f2eb1b
NsTable field for backwards compatibility
ggutoski Jun 6, 2024
697d3aa
set NS_ID_BYTE_LEN to 4 for backwards compatibility
ggutoski Jun 6, 2024
a7d54ba
Payload::builder_commitment hack for backwards compatibility
ggutoski Jun 6, 2024
ab276e5
TODOs for NamespaceId, fix tests in block/test.rs
ggutoski Jun 6, 2024
06305c8
Merge branch 'main' into gg/1076
ggutoski Jun 6, 2024
1a562c0
Merge branch 'main' into gg/1076
ggutoski Jun 6, 2024
596d82e
restore data/ files from main branch
ggutoski Jun 6, 2024
e5db138
remove obsolete comment
ggutoski Jun 6, 2024
f035be6
merge main, resolve conflicts
ggutoski Jun 7, 2024
65b6f62
fix doc for NsProof::new as per https://github.com/EspressoSystems/es…
ggutoski Jun 7, 2024
176f001
new method NsTable::read_ns_id_unchecked as per https://github.com/Es…
ggutoski Jun 7, 2024
5e840c1
merge main, resolve conflicts
ggutoski Jun 7, 2024
fed1161
NamespaceId manual Deserialize impl enforce u32::MAX
ggutoski Jun 10, 2024
26a6b29
NamespaceId impl From<u32> as per https://github.com/EspressoSystems/…
ggutoski Jun 10, 2024
7930830
doc: links to github issues in code comments
ggutoski Jun 10, 2024
a5b490f
Merge branch 'main' into gg/1076
ggutoski Jun 10, 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
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ mod test {
vid_commitment, BlockHeader, BlockPayload, EncodeBytes, GENESIS_VID_NUM_STORAGE_NODES,
};
use hotshot_types::utils::BuilderCommitment;
use sequencer::block::payload::Payload;
use sequencer::block::Payload;
use sequencer::persistence::no_storage::{self, NoStorage};
use sequencer::persistence::sql;
use sequencer::{empty_builder_commitment, Header};
Expand Down
Binary file modified data/header.bin
Binary file not shown.
14 changes: 6 additions & 8 deletions data/header.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"block_merkle_tree_root": "MERKLE_COMM~AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAQA",
"builder_commitment": "BUILDER_COMMITMENT~PfISPEAHYbCXqJ08RqlK74d9aSrtrZkKHdnoX7crymG5",
"builder_commitment": "BUILDER_COMMITMENT~sb1x_a6aU3coBtMC2XowRwxDb3SJveIZxW-_Q9CSrkXd",
"builder_signature": {
"r": "0xca39647d5e159ebf62e0efd163ddb2b7946f437948e6c31accdb5360a9f2da17",
"s": "0x610e51dced89ede20e3dcc5e9e26fff580738e785371df53389f2f84dadbdb87",
"r": "0x1596a279e9e0060b5d30577e56820f89a6bd0b5ab91efb70dc63f08b27e63cd0",
"s": "0x731ed939db42204098c6ffeb13812679576534e5cb3eeec335586402a28d99b5",
"v": 28
},
"chain_config": {
Expand All @@ -29,9 +29,7 @@
"timestamp": "0x456"
},
"l1_head": 124,
"ns_table": {
"bytes": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
"payload_commitment": "HASH~AazstQer_ho1SqgGT0r10_Gs0BnjfbPBHJdSO3HHbp29",
"ns_table": "AQAAAO7/wAAAAAAACAQAAA==",
"payload_commitment": "HASH~Ojg3e_G9UzTwOygEDDcbvgakaVCqMByIiFrlkLXT72qf",
"timestamp": 789
}
}
Binary file modified data/messages.bin
Binary file not shown.
10 changes: 3 additions & 7 deletions data/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"data": {
"block_header": {
"block_merkle_tree_root": "MERKLE_COMM~AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAQA",
"builder_commitment": "BUILDER_COMMITMENT~tEvs0rxqOiMCvfe2R0omNNaphSlUiEDrb2q0IZpRcgA_",
"builder_commitment": "BUILDER_COMMITMENT~_FlsTMQYXvjU_M1TpJFyrGe9BGPU9Di-qALdKJb2hegZ",
"builder_signature": null,
"chain_config": {
"chain_config": {
Expand All @@ -29,9 +29,7 @@
"height": 0,
"l1_finalized": null,
"l1_head": 0,
"ns_table": {
"bytes": "AAAAAA=="
},
"ns_table": "AAAAAA==",
"payload_commitment": "HASH~AazstQer_ho1SqgGT0r10_Gs0BnjfbPBHJdSO3HHbp29",
"timestamp": 0
},
Expand Down Expand Up @@ -319,9 +317,7 @@
2,
3
],
"metadata": {
"bytes": "AQAAAAEAAAALAAAA"
},
"metadata": "AQAAAAEAAAAAAAAACwAAAA==",
"view_number": 0
},
"signature": "BLS_SIG~g3CUcLMD7fnDsBhItKvSqXLwEqdWfvusSrgpL1GBAxf-SWFW0t32Agt2jrOiempjjpI7dBwYGgXv-0mvI4sGEEE"
Expand Down
Binary file modified data/ns_table.bin
Binary file not shown.
4 changes: 1 addition & 3 deletions data/ns_table.json
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"bytes": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
"AQAAAO7/wAAAAAAACAQAAA=="
3 changes: 3 additions & 0 deletions sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ libp2p = []

[dev-dependencies]
espresso-macros = { git = "https://github.com/EspressoSystems/espresso-macros.git", tag = "0.1.0" }
fluent-asserter = "0.1.9"
hotshot-query-service = { workspace = true, features = ["testing"] }
hotshot-testing = { workspace = true }
pretty_assertions = { workspace = true }
rand = "0.8.5"
reqwest = { workspace = true }
Expand Down Expand Up @@ -54,6 +56,7 @@ es-version = { workspace = true }
ethers = { workspace = true }
ethers-contract-derive = "2.0.10"
futures = { workspace = true }
paste = "1.0"

hotshot = { workspace = true }
hotshot-events-service = { workspace = true }
Expand Down
37 changes: 27 additions & 10 deletions sequencer/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,16 +620,15 @@ mod api_tests {
use crate::{
persistence::no_storage,
testing::{wait_for_decide_on_handle, TestConfig},
Header,
Header, NamespaceId,
};
use async_compatibility_layer::logging::{setup_backtrace, setup_logging};
use committable::Committable;
use data_source::testing::TestableSequencerDataSource;
use endpoints::NamespaceProofQueryData;
use es_version::SequencerVersion;
use futures::stream::StreamExt;
use hotshot_query_service::availability::LeafQueryData;
use hotshot_types::vid::vid_scheme;
use hotshot_query_service::availability::{LeafQueryData, VidCommonQueryData};
use portpicker::pick_unused_port;
use surf_disco::Client;
use test_helpers::{
Expand Down Expand Up @@ -661,8 +660,9 @@ mod api_tests {
setup_logging();
setup_backtrace();

let vid = vid_scheme(5);
let txn = Transaction::new(Default::default(), vec![1, 2, 3, 4]);
// Arbitrary transaction, arbitrary namespace ID
let ns_id = NamespaceId::from(42);
let txn = Transaction::new(ns_id, vec![1, 2, 3, 4]);

// Start query service.
let port = pick_unused_port().expect("No ports free");
Expand Down Expand Up @@ -711,14 +711,31 @@ mod api_tests {
.await
.unwrap();
let ns_query_res: NamespaceProofQueryData = client
.get(&format!("availability/block/{block_num}/namespace/0"))
.get(&format!("availability/block/{block_num}/namespace/{ns_id}"))
.send()
.await
.unwrap();
ns_query_res
.proof
.verify(&vid, &header.payload_commitment, &header.ns_table)
.unwrap();

// Verify namespace proof if present
if let Some(ns_proof) = ns_query_res.proof {
let vid_common: VidCommonQueryData<SeqTypes> = client
.get(&format!("availability/vid/common/{block_num}"))
.send()
.await
.unwrap();

ns_proof
.verify(
&header.ns_table,
&header.payload_commitment,
vid_common.common(),
)
.unwrap();
} else {
// Namespace proof should be present if ns_id exists in ns_table
assert!(header.ns_table.find_ns_id(&ns_id).is_none());
assert!(ns_query_res.transactions.is_empty());
}

found_empty_block = found_empty_block || ns_query_res.transactions.is_empty();

Expand Down
60 changes: 20 additions & 40 deletions sequencer/src/api/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ use super::{
StorageState,
};
use crate::{
block::payload::{parse_ns_payload, NamespaceProof},
network,
persistence::SequencerPersistence,
NamespaceId, SeqTypes, Transaction,
block::NsProof, network, persistence::SequencerPersistence, NamespaceId, SeqTypes, Transaction,
};
use anyhow::Result;
use async_std::sync::{Arc, RwLock};
Expand Down Expand Up @@ -45,7 +42,7 @@ use vbs::version::StaticVersionType;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NamespaceProofQueryData {
pub proof: NamespaceProof,
pub proof: Option<NsProof>,
pub transactions: Vec<Transaction>,
}

Expand Down Expand Up @@ -99,32 +96,25 @@ where
}
)?;

let proof = block
.payload()
.namespace_with_proof(
block.payload().get_ns_table(),
ns_id,
common.common().clone(),
)
.context(CustomSnafu {
message: format!("failed to make proof for namespace {ns_id}"),
status: StatusCode::NotFound,
})?;

let transactions = if let NamespaceProof::Existence {
ref ns_payload_flat,
..
} = proof
{
parse_ns_payload(ns_payload_flat, ns_id)
if let Some(ns_index) = block.payload().ns_table().find_ns_id(&ns_id) {
let proof = NsProof::new(block.payload(), &ns_index, common.common()).context(
CustomSnafu {
message: format!("failed to make proof for namespace {ns_id}"),
status: StatusCode::InternalServerError,
},
)?;

Ok(NamespaceProofQueryData {
transactions: proof.export_all_txs(&ns_id),
proof: Some(proof),
})
} else {
Vec::new()
};

Ok(NamespaceProofQueryData {
transactions,
proof,
})
// ns_id not found in ns_table
Ok(NamespaceProofQueryData {
proof: None,
transactions: Vec::new(),
})
}
}
.boxed()
})?;
Expand Down Expand Up @@ -178,16 +168,6 @@ where
.body_auto::<Transaction, Ver>(Ver::instance())
.map_err(Error::from_request_error)?;

// Transactions with namespaces that do not fit in the u32
// cannot be included in the block.
// TODO: This issue will be addressed in the next release.
if tx.namespace() > NamespaceId::from(u32::MAX as u64) {
return Err(Error::Custom {
message: "Transaction namespace > u32::MAX".to_string(),
status: StatusCode::BadRequest,
});
}
ggutoski marked this conversation as resolved.
Show resolved Hide resolved

let hash = tx.commit();
state
.submit(tx)
Expand Down
26 changes: 16 additions & 10 deletions sequencer/src/bin/nasty-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ use hotshot_query_service::{
metrics::PrometheusMetrics,
node::TimeWindowQueryData,
};
use hotshot_types::{
traits::metrics::{Counter, Gauge, Metrics as _},
vid::{vid_scheme, VidSchemeType},
};
use hotshot_types::traits::metrics::{Counter, Gauge, Metrics as _};
use jf_merkle_tree::{
ForgetableMerkleTreeScheme, MerkleCommitment, MerkleTreeScheme, UniversalMerkleTreeScheme,
};
use jf_vid::VidScheme;
use rand::{seq::SliceRandom, RngCore};
use sequencer::{
api::endpoints::NamespaceProofQueryData,
Expand Down Expand Up @@ -940,11 +936,13 @@ impl ResourceManager<BlockQueryData<SeqTypes>> {
.context(format!("fetching header {block}"))
})
.await?;
if header.ns_table.is_empty() {
let num_namespaces = header.ns_table.iter().count();
ggutoski marked this conversation as resolved.
Show resolved Hide resolved
if num_namespaces == 0 {
tracing::info!("not fetching namespace because block {block} is empty");
ggutoski marked this conversation as resolved.
Show resolved Hide resolved
return Ok(());
}
let ns = header.ns_table.get_table_entry(index).0;
let ns_index = header.ns_table.iter().nth(index % num_namespaces).unwrap();
ggutoski marked this conversation as resolved.
Show resolved Hide resolved
let ns = header.ns_table.read_ns_id(&ns_index);

let ns_proof: NamespaceProofQueryData = self
.retry(info_span!("fetch namespace", %ns), || async {
Expand All @@ -966,13 +964,21 @@ impl ResourceManager<BlockQueryData<SeqTypes>> {
.context(format!("fetching VID common {block}"))
})
.await?;
let vid = vid_scheme(VidSchemeType::get_num_storage_nodes(vid_common.common()) as usize);
ensure!(
ns_proof.proof.is_some(),
format!("missing namespace proof for {block}:{ns}")
);
ensure!(
ns_proof
.proof
.verify(&vid, &header.payload_commitment, &header.ns_table)
.unwrap()
.verify(
&header.ns_table,
&header.payload_commitment,
vid_common.common()
)
.is_some(),
format!("namespace proof for {block}:{ns} is invalid")
format!("failure to verify namespace proof for {block}:{ns}")
);

self.metrics.query_namespace_actions.add(1);
Expand Down
Loading
Loading