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

Add coinbase depth and tx id inclusion proof to BitcoinLightClient #1863

Draft
wants to merge 9 commits into
base: nightly
Choose a base branch
from

Conversation

okkothejawa
Copy link
Contributor

Description

  • Adds coinbase depth to BitcoinLightClient to solve the merkle tree leaf node weakness issue.
  • Adds a verifyInclusionByTxId function that acts the same as verifyInclusion but uses txId instead of wtxId, as such, it requires a Bitcoin header parameter that is later validated against stored Bitcoin block hash.

Linked Issues

Testing

Added unit tests for coinbase depth fail case and verifying inclusion through tx id.

@eyusufatik
Copy link
Member

plan is to merge #1935 then update genesises for tests that start with Fork2 in this PR.

we might want to implement fork2 function here so that we can keep backwards compatibility easily. this would also mean we should update the bridge to use this new function. that can be this PR or another one.

only after these we can merge this PR. then we'll need a followup PR for #1913

@@ -32,6 +38,7 @@ contract BitcoinLightClient is IBitcoinLightClient {
blockNumber = _blockNumber;
}

/// @notice Kept for backwards compatibility
Copy link
Member

Choose a reason for hiding this comment

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

add warning that this should not be called and calling it will invalidate L2 block after Fork2 activates

/// @param _proof Merkle proof
/// @param _index Index of the transaction
/// @return If the transaction ID is included in the merkle root hash of the block
function verifyInclusionByTxId(uint256 _blockNumber, bytes32 _txId, bytes calldata _blockHeader, bytes calldata _proof, uint256 _index) external view returns (bool) {
Copy link
Member

Choose a reason for hiding this comment

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

sneaking in features I see :)

});
system_events
}

/// Populates system events based on the current soft confirmation info.
pub fn populate_system_events<'a>(
Copy link
Member

Choose a reason for hiding this comment

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

I might rewrite this

Copy link
Member

Choose a reason for hiding this comment

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

taking notes

@@ -447,6 +450,7 @@ where

let evm_txs = self.get_best_transactions()?;

let coinbase_depth = short_header_proof.verify().unwrap().coinbase_txid_merkle_proof_height.into();
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't handle it like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what's wrong with it

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.

Update BitcoinLightClient::setBlockInfo() with coinbase txid merkle proof depth
2 participants