Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Implemented missing data structure for serialization and deserialization of external transition #202

Merged
merged 10 commits into from
May 3, 2022

Conversation

sudo-shashank
Copy link
Contributor

@sudo-shashank sudo-shashank commented Apr 5, 2022

Summary of changes
Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes #194
#143 except: test: Implement test_snapp_command().

Other information and links

@sudo-shashank sudo-shashank changed the title Implemented Transaction Snark Data Structure WIP: Implemented Transaction Snark Data Structure Apr 6, 2022
@sudo-shashank sudo-shashank force-pushed the shashank/#194 branch 5 times, most recently from 75b6e47 to 07ae35f Compare April 7, 2022 09:10
@codecov-commenter
Copy link

codecov-commenter commented Apr 7, 2022

Codecov Report

Merging #202 (bb7e2ea) into main (29b121d) will increase coverage by 0.94%.
The diff coverage is 95.00%.

@@            Coverage Diff             @@
##             main     #202      +/-   ##
==========================================
+ Coverage   86.58%   87.52%   +0.94%     
==========================================
  Files         101      103       +2     
  Lines        4471     4682     +211     
==========================================
+ Hits         3871     4098     +227     
+ Misses        600      584      -16     
Impacted Files Coverage Δ
base/src/lib.rs 100.00% <ø> (ø)
base/src/snark_work.rs 0.00% <0.00%> (ø)
base/src/staged_ledger_diff.rs 93.10% <0.00%> (-3.33%) ⬇️
...col/serialization-types/src/external_transition.rs 100.00% <ø> (ø)
protocol/serialization-types/src/lib.rs 100.00% <ø> (ø)
base/src/serialization_type_conversions/mod.rs 99.00% <100.00%> (+3.22%) ⬆️
protocol/bin-prot/src/ser.rs 87.50% <100.00%> (+6.37%) ⬆️
protocol/serialization-types/src/snark_work.rs 100.00% <100.00%> (ø)
...ocol/serialization-types/src/staged_ledger_diff.rs 86.36% <100.00%> (+5.41%) ⬆️
protocol/bin-prot/src/read_ext.rs 95.89% <0.00%> (-1.37%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29b121d...bb7e2ea. Read the comment docs.

@sudo-shashank sudo-shashank changed the title WIP: Implemented Transaction Snark Data Structure Implemented Transaction Snark Data Structure Apr 7, 2022
@hanabi1224
Copy link
Contributor

Amazing work, just one thing, is it possible to get block(s) that can exercise uncovered serde code? It looks like the overall codecov drop by ~3% with this change

@sudo-shashank sudo-shashank added the Do not merge Status: Do not merge Added to PRs that are not allowed to be merged label Apr 11, 2022
@sudo-shashank sudo-shashank changed the title Implemented Transaction Snark Data Structure WIP: Implemented Transaction Snark Data Structure Apr 11, 2022
@sudo-shashank sudo-shashank force-pushed the shashank/#194 branch 3 times, most recently from b5be92f to 4a0b53a Compare April 12, 2022 12:19
@sudo-shashank sudo-shashank changed the title WIP: Implemented Transaction Snark Data Structure Implemented missing data structure for serialization and deserialization of external transition Apr 12, 2022
@sudo-shashank sudo-shashank force-pushed the shashank/#194 branch 3 times, most recently from dabd9ba to a6cdb12 Compare April 20, 2022 03:37
@sudo-shashank sudo-shashank linked an issue Apr 21, 2022 that may be closed by this pull request
5 tasks
Copy link
Contributor

@willemolding willemolding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work dude! Just needs a tidy up and we are good

base/src/numbers.rs Outdated Show resolved Hide resolved
base/src/snark_work.rs Outdated Show resolved Hide resolved
self.writer.bin_write_variant_index(b)?;
// Use variant name to identify polyvar type, else sum type
fn write_variant_index_or_tag(&mut self, name: &str, index: u32, variant: &str) -> Result<()> {
if name == "Polyvar" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we not already merge this stuff?

@@ -37,5 +37,5 @@ pub struct ExternalTransition {
pub struct ExternalTransitionV1(pub Versioned<ExternalTransition, 1>);

impl bin_prot::encodable::BinProtEncodable for ExternalTransitionV1 {
const PREALLOCATE_BUFFER_BYTES: usize = 13 * 1024;
const PREALLOCATE_BUFFER_BYTES: usize = 13 * 1024; // FIXME: This size is not suitable for blocks with snark work data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest removing this trait entirely since it is only a helper for writing tests. Feel free to increase the buffer to make things work (but it might break again if we get a larger block)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increased the buffer size for now, to support all the sample test blocks we have

@@ -439,6 +449,7 @@ fn test_staged_ledger_diff_diff_commands_status() {
#[wasm_bindgen_test]
fn test_staged_ledger_diff_diff_coinbase() {
block_path_test_batch! {
// FIXME: The given path is not valid for all test blocks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test makes invalid assumptions (that the variant is always the second one in

pub enum CoinBase {
    Zero,
    // FIXME: other variants are not covered by current test block
    One(Option<CoinBaseFeeTransferV1>),
    Two,
}

This is invalid so we should just remove the test entirely. It is covered by the next line anyway

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's safe to disable the test for now since we have e2e coverage, ideally, the logic here should be, deserializing the binary into all variants and asserting there is exactly one being successful

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out #218

CoinBaseBalanceDataV1 => "t/staged_ledger_diff/t/diff/t/0/t/t/internal_command_balances/0/t/[sum]"
// FIXME: The given path is not valid for all test blocks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

protocol/test-fixtures/src/lib.rs Show resolved Hide resolved
protocol/test-serialization/src/test_blocks_de.rs Outdated Show resolved Hide resolved
@sudo-shashank sudo-shashank force-pushed the shashank/#194 branch 2 times, most recently from eab18d1 to 12d1534 Compare April 22, 2022 09:57
@sudo-shashank sudo-shashank removed Do not merge Status: Do not merge Added to PRs that are not allowed to be merged labels Apr 22, 2022
@sudo-shashank sudo-shashank added ready for review and removed Do not merge Status: Do not merge Added to PRs that are not allowed to be merged labels Apr 22, 2022
@@ -28,3 +28,7 @@ pub struct ExternalTransition {
impl BinProtSerializationType for ExternalTransition {
type T = ExternalTransitionV1;
}

impl bin_prot::encodable::BinProtEncodable for ExternalTransition {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been removed

@hanabi1224
Copy link
Contributor

hanabi1224 commented Apr 26, 2022

It's strange that when I run the tests from #221 in this PR, CI jobs time out, there might be some perf issue to investigate

}
};
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment describing why we need this dummy struct for later reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i'll add it

@sudo-shashank sudo-shashank force-pushed the shashank/#194 branch 2 times, most recently from 05f258f to b9d8e53 Compare May 3, 2022 04:17
@sudo-shashank sudo-shashank merged commit 855c8de into main May 3, 2022
@sudo-shashank sudo-shashank deleted the shashank/#194 branch May 3, 2022 14:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[M1] Implement missing serialization types data structures [M4] Test coverages staged ledger diff
5 participants