-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Update HeaderWithProof
with latest spec changes
#1672
Conversation
1a1427c
to
47e6285
Compare
Ready for an intial review on this pr. The failing tests pass locally when I use ethereum/portal-spec-tests#34 as a source for test vectors. But I'm happy to wait until that's merged to merge this one through |
I am not aware of a reason why you would need to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good. I am a little confused by this statement
But I'm happy to wait until that's merged to merge this one through
, because I thought it was assumed we wait for CI passing to merge, so the message is making me second guess myself, but I will ignore that feeling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some high level comments.
I plan to work on top of this PR, and I might suggest some changes if they are blocking my work.
@@ -40,21 +46,26 @@ impl ssz::Encode for HeaderWithProof { | |||
} | |||
|
|||
#[derive(Debug, Clone, PartialEq, Decode, Encode, Deserialize)] | |||
#[ssz(enum_behaviour = "union")] | |||
#[ssz(enum_behaviour = "transparent")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need both old type (with union and SszNone) until we are done with migration. Otherwise, I won't be able to do the migration (meaning, I won't be able to successfully decode content from the db).
I would also remove Decode
from derive, because now that it's no longer union, we can't decode it (we need header timestamp). Technically, this is not accurate as format is different enough (I believe) so that only one would decode correctly. But we shouldn't try to decode this object directly, so better not to implement the trait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more about this, I think that old type should remain the same, and the new type should have new name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the spec and it seems that ExecutionBlockProof
is different for BlockProofHistoricalRoots
and BlockProofHistoricalSummaries
, while we still use the some type.
Are all updated specs tests passing? Do we cover all these types in them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the updated specs tests are passing now. I actually don't think the test vectors cover all cases (aka, 1 pre-merge, 1 capella, 1 post-capella). This is worth addressing.
Also, looking at the spec, it looks like our naming convention is inverse of what's in the spec, which we should update to be 1-1. Though, if I'm reading everything correctly, I actually think our logic is sound. "our" HistoricalSummariesProof
type and HistoricalRootsProof
type (which I think are the types you're referring to?) seem to be up to spec. But, honestly it's confusing with all the variable naming schemes. I don't quite consider this a blocker for this pr? I'd rather address it in a follow-up pr where I'll update all the names to be spec-compliant and add missing test vectors? But can do it here if you think that's worthwhile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do it in this PR.
let header: Header = Decodable::decode(&mut header_rlp.as_slice()).map_err(|_| { | ||
ssz::DecodeError::BytesInvalid("Unable to decode bytes into header.".to_string()) | ||
})?; | ||
|
||
let proof = if header.timestamp <= MERGE_TIMESTAMP { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be <=
or <
? At least intuitively for me, MERGE_TIMESTAMP should be the timestamp of the first post-merge block (but I don't know if that's try in practice).
Either way, I think we should have tests to cover these corner cases, meaning have a test case for the last pre-merge and first post-merge blocks (also shanghai)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, according to the updated test specs, it needs to be <=
otherwise the test "last pre-merge" test vector ( 15537393.yaml
) fails decoding. The "trigger" for the merge was difficulty-based, so I'm guessing that our use of a timestamp is somewhat arbitrary
HistoricalRootsBlockProof(HistoricalRootsBlockProof), | ||
HistoricalSummariesBlockProof(HistoricalSummariesBlockProof), | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct PreMergeAccumulatorProof { | ||
pub struct HistoricalHashesAccumulatorProof { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not strictly part of this PR, but can't we replace this structure with:
pub type HistoricalHashesAccumulatorProof = FixedVector<B256, typenum::U15>;
I applied some of my suggestions in my local work: It's not polished at all, so feel free to take a look and take some or all of it. A lot of the changes are refactoring not really related to this PR/work (I might extract them into separate PR if I get to it. |
3e7bb40
to
f62095e
Compare
@KolbyML Sorry if I was confusing, I just wanted to avoid bloating this pr with too many changes. And you're right we shouldn't be merging with failing ci, I was just saying so funnily @morph-dev I moved the new types into an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Few suggestions, but I'm not going to insist on them:
- I would move new
content_value.rs
file intoethportal-api/src/types/content_value/history_pr1666.rs
- I'm not the biggest fan of
_pr1666
suffix, and either_new
or_updated
is fine as well. All of this is only temporarily.
- I'm not the biggest fan of
- We can also move new
header_with_proof.rs
one level up and name it:header_with_proof_pr1666.rs
- If I'm not mistaken, the test files (in
validation/src/asssets/fluffy
) are currently only used with this newheader_with_proof.rs
, so I would move them somewhere inethportal-api
crate.
} | ||
|
||
#[cfg(test)] | ||
mod test { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even tho it might be tested in some other places indirectly, I think we should have tests here that test that encoding and decoding works as expected.
This doesn't have to be done in this PR (we should have test vectors for this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the existing tests since they were duplicates. But I guess the tests you're referencing are for encoding/decoding the HistoryContentValue
and not necessarily the inner type. I'll circle back to this pr and add these later
197282b
to
2f3bcc5
Compare
7db5e4a
to
a828b0c
Compare
I left them where they were because I'd like to remove that entire test asset folder after the "upgrade" since they're all duplicates from the I updated the modules to the new naming convention (
I ended up moving it into |
* fix: update BlockHeaderProof type to match new specs * refactor: rename PreMergeAccumulatorProof -> HistoricalHashesAccumulatorProof * refactor: move updated hwp types to separate module * refactor: apply milos pr suggestions * fix: final pr comments
What was wrong?
Specs have been updated to the
HeaderWithProof
typeNone
type for the proofHow was it fixed?
HeaderWithProof
typePreMergeAccumulatorProof
->HistoricalHashesAccumulatorProof
to better match the specsportal-bridge
/ some test utils have a temporary invalid proof. The next step is to update the bridge to generate valid proofs, but I didn't want to combine these two prs otherwise it would get pretty large. Next, I'll work on updating the bridge and then update all the invalid proofs to be validTo-Do