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

Update to support casper 2.0.0-rc4 #9

Merged
merged 12 commits into from
Sep 24, 2024
Merged

Update to support casper 2.0.0-rc4 #9

merged 12 commits into from
Sep 24, 2024

Conversation

Avi-D-coder
Copy link
Contributor

@Avi-D-coder Avi-D-coder commented Sep 10, 2024

Deletes a bunch of stuff.
Makes a new version.

Other than using upstream types the main breaking change is replacing casper_node::JsonBlock with casper_types::JsonBlockWithSignatures.

JsonBlock has been removed from casper_node, it was briefly added to casper_sidecar, but then it was removed. I believe everything now uses JsonBlockWithSignatures.
JsonBlockWithSignatures sounds like it should be the same type when serialized, but it's rep is very different.

Upstream users of this library are unlikely to be able to continue getting JsonBlocks from the l1, and should now update to use JsonBlockWithSignatures.

This change has been made in litmus-wasm, but the service worker will also have to update.

I did attempt to support an updated V2 compatible version of JsonBlock, but it's a pain, and is still a breaking change so I stopped, it's best if that change is done in the JS.

Start introducing the V2 block format

Fix clippy lints

Make BlockV2 serde prop tests

Make Era stuff work

Fix tests

Fix end era v2

BlockHeaderV2 proptests

More Tests
@xcthulhu xcthulhu self-requested a review September 10, 2024 14:22
src/block.rs Outdated Show resolved Hide resolved
@Avi-D-coder Avi-D-coder marked this pull request as ready for review September 17, 2024 05:19
src/consensus.rs Outdated Show resolved Hide resolved
@xcthulhu
Copy link
Contributor

We could just get rid of src/crypto.rs and use casper-types implementation. However, this might make proptesting elsewhere harder...

@Avi-D-coder
Copy link
Contributor Author

@xcthulhu All deleted

Copy link
Contributor

@xcthulhu xcthulhu left a comment

Choose a reason for hiding this comment

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

LGTM

src/merkle_proof.rs Outdated Show resolved Hide resolved
@uchu
Copy link

uchu commented Sep 20, 2024

Looks good, can we merge it? Avi, Matt

src/kernel.rs Outdated
Comment on lines 24 to 28
// impl From<SignatureVerificationError> for BlockSignaturesValidationError {
// fn from(signature_verification_error: SignatureVerificationError) -> Self {
// BlockSignaturesValidationError::SignatureVerificationError(signature_verification_error)
// }
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

We can delete this I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I deleted this in the last commit.

pub fn validate(
&self,
block_header_with_signatures: &BlockHeaderWithSignatures,
JsonBlockWithSignatures { block, proofs }: JsonBlockWithSignatures,
Copy link
Contributor

Choose a reason for hiding this comment

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

@uchu Does this work with what the new side-care outputs when you try to get block by height?

src/kernel.rs Outdated
.proofs()
.iter()
{
let mut signature_data = block.hash().inner().into_vec();
Copy link
Contributor

@xcthulhu xcthulhu Sep 20, 2024

Choose a reason for hiding this comment

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

So the hash on a block could possibly be forged (this accessor doesn't compute the hash, it accesses it from the Block data structure).

You need to add a check that block.block_header().block_hash() == block.hash()

Copy link
Contributor

Choose a reason for hiding this comment

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

You would also want to check the hash of the block body to make sure it matches the body hash in the header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@xcthulhu xcthulhu merged commit fbb5719 into main Sep 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants