Skip to content

Feat/merkle library #75

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

Merged
merged 10 commits into from
May 11, 2022
Merged

Feat/merkle library #75

merged 10 commits into from
May 11, 2022

Conversation

shotaronowhere
Copy link
Contributor

Implements a space efficient merkle tree data structure and merkle proof functions as stand alone contracts which will be incorporated into the fastBridgeReceiver and fastBridgeSender.

Contrary to the name of the branch, the merkle tree is not actually implemented in a library.

On rollups, there is no contract size limit, and duplicating the merkle tree data structure and merkle proof functions directly into the fast bridge will save gas.

  • On L1, incorporating the merkle proof functions directly into the fast bridge receiver is a significant gas saving (maybe 3k gas per message).
  • On L2, incorporating the merkle tree data structure into the fast bridge sender is a modest gas savings. Discarding the L1 fixed transaction cost and L1 calldata cost from L2 transactions, insertions with a merkle tree library cost 0.000000251911548938 eth versus 0.00000013056669626 eth when the merkle tree data structure is directly implemented in the fast bridge contract. This is a significant relative gas savings, but modest overall (saves fractions of pennies which can add up over time).

The leaves of the merkle tree are hashed with a different hash function (sha256) than the interior leaves to prevent a so-called '2nd pre-image attack'

https://flawed.net.nz/2018/02/21/attacking-merkle-trees-with-a-second-preimage-attack/

@codeclimate
Copy link

codeclimate bot commented May 11, 2022

Code Climate has analyzed commit 9d3c1d3 and detected 0 issues on this pull request.

View more on Code Climate.

@jaybuidl jaybuidl self-requested a review May 11, 2022 11:55
@jaybuidl jaybuidl added this to the prealpha-3 milestone May 11, 2022
@jaybuidl
Copy link
Member

Required to resolve #54

@jaybuidl jaybuidl linked an issue May 11, 2022 that may be closed by this pull request
@shotaronowhere shotaronowhere merged commit 9e392ad into master May 11, 2022
@jaybuidl
Copy link
Member

Required by #76

@jaybuidl jaybuidl added the Compatibility: ABI change 🗯 Smart contract ABI is changing. label Aug 8, 2022
Params10 pushed a commit that referenced this pull request Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fast Bridging: message batching
2 participants