Skip to content

Skip proof validation when performing estimation #1471

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -416,16 +416,18 @@ contract Gateway is IGatewayBase, IGatewayV1, IGatewayV2, IInitializable, IUpgra
revert IGatewayBase.InvalidNonce();
}

bytes32 leafHash = keccak256(abi.encode(message));

$.inboundNonce.set(message.nonce);

// Produce the commitment (message root) by applying the leaf proof to the message leaf
bytes32 commitment = MerkleProof.processProof(leafProof, leafHash);
if (msg.sender != address(this)) {
Copy link
Contributor

@alistair-singh alistair-singh May 14, 2025

Choose a reason for hiding this comment

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

This should be safe because of the nonreentrant modifier. There is no way to re-enter this code path with the sender address of the gateway proxy. But we may need a test to cover that this can never happen.

For instance, in a separate branch, remove the nonreentrant modifier and maybe try sending Ether to a contract address with receive() implemented to try and reenter the Gateway skip proof verification. If its possible without nonreentrant modifier, and will it still be possible after nonreentrant modifier will give us insight into whether we want to use this method to bypass verification.

Another note is that the choice of the GatewayProxy address is arbitrary and we could of chosen any keyless account for this purpose, but the GatewayProxy is probably the most sane choice.

bytes32 leafHash = keccak256(abi.encode(message));

// Verify that the commitment is included in a parachain header finalized by BEEFY.
if (!_verifyCommitment(commitment, headerProof, true)) {
revert IGatewayBase.InvalidProof();
// Produce the commitment (message root) by applying the leaf proof to the message leaf
bytes32 commitment = MerkleProof.processProof(leafProof, leafHash);

// Verify that the commitment is included in a parachain header finalized by BEEFY.
if (!_verifyCommitment(commitment, headerProof, true)) {
revert IGatewayBase.InvalidProof();
}
}

// Dispatch the message payload
Expand Down