Skip to content

op-chain-ops: implement withdrawal hashing#3469

Merged
mergify[bot] merged 4 commits intodevelopfrom
feat/xdm-withdrawals
Sep 25, 2022
Merged

op-chain-ops: implement withdrawal hashing#3469
mergify[bot] merged 4 commits intodevelopfrom
feat/xdm-withdrawals

Conversation

@tynes
Copy link
Contributor

@tynes tynes commented Sep 14, 2022

Description

Implement both the new hashing scheme and the legacy hashing for withdrawals so that the withdrawals can be migrated.
This only includes tests for legacy style hashing, will follow up with an additional PR to add tests for bedrock style withdrawal hashing to prevent this PR from growing too large.

Closes ENG-2718

@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2022

⚠️ No Changeset found

Latest commit: 8151bb8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mergify
Copy link
Contributor

mergify bot commented Sep 14, 2022

This PR changes implementation code, but doesn't include a changeset. Did you forget to add one?

@tynes tynes force-pushed the feat/xdm-withdrawals branch from 1e0fb2d to 5b61f78 Compare September 20, 2022 12:13
@tynes
Copy link
Contributor Author

tynes commented Sep 20, 2022

@tynes tynes force-pushed the feat/xdm-withdrawals branch 4 times, most recently from e322f43 to fe114c0 Compare September 21, 2022 20:58
@tynes tynes marked this pull request as ready for review September 21, 2022 20:59
Copy link
Contributor

@trianglesphere trianglesphere left a comment

Choose a reason for hiding this comment

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

LGTM - one Q about some test setup. I really like how it compares the computed slot vs what get set in the trace.

@mslipper
Copy link
Contributor

Recusing myself from review here; others will have more insightful feedback.

@mslipper mslipper removed their request for review September 21, 2022 23:33
@tynes tynes force-pushed the feat/xdm-withdrawals branch 2 times, most recently from f6f570c to 9729d90 Compare September 22, 2022 12:27
@tynes
Copy link
Contributor Author

tynes commented Sep 22, 2022

LGTM - one Q about some test setup. I really like how it compares the computed slot vs what get set in the trace.

Good call on catching that error, I have updated it to panic on error of abi deserialization

@tynes tynes force-pushed the feat/xdm-withdrawals branch from 9729d90 to 8d0c4b1 Compare September 22, 2022 12:30
tynes added a commit that referenced this pull request Sep 22, 2022
Fuzzes the L2ToL1MessagePasser for state changes to its storage.
This specifically tests that the storage slot that the proofs
are generated against is computed correctly. This is important to
test as any changes that break the proof would also break this test.

The fuzz runs were used to generate test cases in
#3469
for off chain computation of the storage slots for withdrawals.
@tynes
Copy link
Contributor Author

tynes commented Sep 22, 2022

I've added some additional functionality to this PR:

  • Split the withdrawal type into LegacyWithdrawal and Withdrawal
  • encoding + decoding with roundtrip fuzz tests of both withdrawal types
  • Test coverage of the storage slot generation for the Withdrawal type
    • Test vectors generated using foundry, this is important for the storage slot migration

tynes added a commit that referenced this pull request Sep 22, 2022
Fuzzes the L2ToL1MessagePasser for state changes to its storage.
This specifically tests that the storage slot that the proofs
are generated against is computed correctly. This is important to
test as any changes that break the proof would also break this test.

The fuzz runs were used to generate test cases in
#3469
for off chain computation of the storage slots for withdrawals.
@trianglesphere trianglesphere self-requested a review September 22, 2022 14:17
Copy link
Contributor

@trianglesphere trianglesphere left a comment

Choose a reason for hiding this comment

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

A couple small code things, but the rest is looking really good.

@tynes
Copy link
Contributor Author

tynes commented Sep 22, 2022

i have addressed the issues, thanks for the review

Copy link
Contributor

@trianglesphere trianglesphere left a comment

Choose a reason for hiding this comment

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

There's a small bug in the length check code. Fix that and it's good to go.

@tynes tynes force-pushed the feat/xdm-withdrawals branch from 6641624 to dd27400 Compare September 23, 2022 14:20
@mergify
Copy link
Contributor

mergify bot commented Sep 23, 2022

This PR has been added to the merge queue, and will be merged soon.

@tynes
Copy link
Contributor Author

tynes commented Sep 23, 2022

Not sure why this is failing in CI but not locally for me

@mslipper
Copy link
Contributor

It fails for me locally as well.

@trianglesphere
Copy link
Contributor

@tynes is there an issue with the files checked in / something around the path where it's not able to load in the test cases?

Implement both the new hashing scheme and the legacy
hashing for withdrawals so that the withdrawals can
be migrated.

Also implement encoding and decoding of the withdrawals
@tynes tynes force-pushed the feat/xdm-withdrawals branch from a14b2fd to 57dd3f9 Compare September 25, 2022 20:16
Now that the old message passer is being kept in the L2
state, be sure to the use legacy address. The new message
passer is at a different address.
@tynes
Copy link
Contributor Author

tynes commented Sep 25, 2022

@tynes is there an issue with the files checked in / something around the path where it's not able to load in the test cases?

Found the source of the bug, it was due to the way that the L2ToL1MessagePasser is now being handled. Instead of migrating the state at address(0x42..00) we are introducing a new predeploy at address(0x42..16) that will receive the migrated hashes and the proof on L1 will work against that account.

tynes added a commit that referenced this pull request Sep 25, 2022
Fuzzes the L2ToL1MessagePasser for state changes to its storage.
This specifically tests that the storage slot that the proofs
are generated against is computed correctly. This is important to
test as any changes that break the proof would also break this test.

The fuzz runs were used to generate test cases in
#3469
for off chain computation of the storage slots for withdrawals.
@mergify
Copy link
Contributor

mergify bot commented Sep 25, 2022

This PR has been added to the merge queue, and will be merged soon.

@mergify mergify bot merged commit c3980e9 into develop Sep 25, 2022
@mergify mergify bot deleted the feat/xdm-withdrawals branch September 25, 2022 20:34
@mergify
Copy link
Contributor

mergify bot commented Sep 25, 2022

This PR is next in line to be merged, and will be merged as soon as checks pass.

@mergify mergify bot removed the on-merge-train label Sep 25, 2022
tynes added a commit that referenced this pull request Sep 26, 2022
Fuzzes the L2ToL1MessagePasser for state changes to its storage.
This specifically tests that the storage slot that the proofs
are generated against is computed correctly. This is important to
test as any changes that break the proof would also break this test.

The fuzz runs were used to generate test cases in
#3469
for off chain computation of the storage slots for withdrawals.
tynes added a commit that referenced this pull request Sep 26, 2022
Fuzzes the L2ToL1MessagePasser for state changes to its storage.
This specifically tests that the storage slot that the proofs
are generated against is computed correctly. This is important to
test as any changes that break the proof would also break this test.

The fuzz runs were used to generate test cases in
#3469
for off chain computation of the storage slots for withdrawals.
mergify bot added a commit that referenced this pull request Sep 27, 2022
* contracts-bedrock: fuzz L2ToL1MessagePasser

Fuzzes the L2ToL1MessagePasser for state changes to its storage.
This specifically tests that the storage slot that the proofs
are generated against is computed correctly. This is important to
test as any changes that break the proof would also break this test.

The fuzz runs were used to generate test cases in
#3469
for off chain computation of the storage slots for withdrawals.

* contracts-bedrock: regenerate snapshot

* bindings: regenerate

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Matthew Slipper <me@matthewslipper.com>
This was referenced Sep 29, 2022
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.

4 participants