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

fix: remove claim_public from fee juice #8337

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion l1-contracts/src/core/FeeJuicePortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ contract FeeJuicePortal is IFeeJuicePortal, Ownable {

// Hash the message content to be reconstructed in the receiving contract
bytes32 contentHash =
Hash.sha256ToField(abi.encodeWithSignature("mint_public(bytes32,uint256)", _to, _amount));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the change here because I think it was just outdated / used the wrong value before

Hash.sha256ToField(abi.encodeWithSignature("claim(bytes32,uint256)", _to, _amount));

// Hold the tokens in the portal
underlying.safeTransferFrom(msg.sender, address(this), _amount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ pub fn get_bridge_gas_msg_hash(owner: AztecAddress, amount: Field) -> Field {
hash_bytes[i + 36] = amount_bytes[i];
}

// Function selector: 0x3e87b9be keccak256('mint_public(bytes32,uint256)')
hash_bytes[0] = 0x3e;
hash_bytes[1] = 0x87;
hash_bytes[2] = 0xb9;
hash_bytes[3] = 0xbe;
// Function selector: 0x63f44968 keccak256('claim(bytes32,uint256)')
hash_bytes[0] = 0x63;
hash_bytes[1] = 0xf4;
hash_bytes[2] = 0x49;
hash_bytes[3] = 0x68;

let content_hash = sha256_to_field(hash_bytes);
content_hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,6 @@ contract FeeJuice {
storage.balances.at(to).write(new_balance);
}

// TODO(palla/gas) Remove this function and use the private claim flow only
#[aztec(public)]
fn claim_public(to: AztecAddress, amount: Field, secret: Field, leaf_index: Field) {
let content_hash = get_bridge_gas_msg_hash(to, amount);
let portal_address = storage.portal_address.read_public();
assert(!portal_address.is_zero());

// Consume message and emit nullifier
context.consume_l1_to_l2_message(content_hash, secret, portal_address, leaf_index);

let new_balance = storage.balances.at(to).read() + U128::from_integer(amount);
storage.balances.at(to).write(new_balance);
}

#[aztec(public)]
#[aztec(view)]
fn check_balance(fee_limit: Field) {
Expand Down
19 changes: 7 additions & 12 deletions yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
return Fr.fromString(messageHash);
}

async consumeMessageOnAztecAndMintPublicly(bridgeAmount: bigint, owner: AztecAddress, secret: Fr, leafIndex: bigint) {
this.logger.info('Consuming messages on L2 Publicly');
// Call the mint tokens function on the Aztec.nr contract
await this.l2Token.methods.claim_public(owner, bridgeAmount, secret, leafIndex).send().wait();
async consumeMessageOnAztecAndClaimPrivately(bridgeAmount: bigint, owner: AztecAddress, secret: Fr) {
this.logger.info('Consuming messages on L2 Privately');
// Call the claim function on the Aztec.nr Fee Juice contract
await this.l2Token.methods.claim(owner, bridgeAmount, secret).send().wait();
}

async getL2PublicBalanceOf(owner: AztecAddress) {
Expand Down Expand Up @@ -211,15 +211,10 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {

async bridgeFromL1ToL2(l1TokenBalance: bigint, bridgeAmount: bigint, owner: AztecAddress) {
// Prepare the tokens on the L1 side
const { secret, msgHash } = await this.prepareTokensOnL1(l1TokenBalance, bridgeAmount, owner);
const { secret } = await this.prepareTokensOnL1(l1TokenBalance, bridgeAmount, owner);

// Get message leaf index, needed for claiming in public
const maybeIndexAndPath = await this.aztecNode.getL1ToL2MessageMembershipWitness('latest', msgHash, 0n);
expect(maybeIndexAndPath).toBeDefined();
const messageLeafIndex = maybeIndexAndPath![0];

// Consume L1-> L2 message and mint public tokens on L2
await this.consumeMessageOnAztecAndMintPublicly(bridgeAmount, owner, secret, messageLeafIndex);
// Consume L1-> L2 message and claim tokens privately on L2
await this.consumeMessageOnAztecAndClaimPrivately(bridgeAmount, owner, secret);
await this.expectPublicBalanceOnL2(owner, bridgeAmount);
}
}
Expand Down
Loading