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 proveL2Tx task for mantle/manta #99

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 22 additions & 0 deletions examples/manta/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/manta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"devDependencies": {
"@eth-optimism/sdk": "^3.2.3",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@rainbow-me/fee-suggestions": "^2.1.0",
"ethers": "^5.7.2",
"hardhat": "^2.9.1"
},
Expand Down
35 changes: 35 additions & 0 deletions examples/manta/scripts/mantaTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
} = require('../../optimism/scripts/opstack-utils');
const { L1_MAINNET_CONTRACTS, L1_TESTNET_CONTRACTS } = require('./constants');
const { task, types } = require('hardhat/config');
const { suggestFees } = require('@rainbow-me/fee-suggestions');
require('dotenv').config();

async function initMessenger() {
Expand Down Expand Up @@ -69,6 +70,40 @@ task('syncL2Requests', 'Send sync point to arbitrator')
// https://goerli.etherscan.io/tx/0x54ce6421e1d9c1e7d2c35af292c9e3bbaf632b60115556a94b7fb61e53905599
});

task('proveL2Tx', 'Prove L2 tx')
.addParam('txHash', 'The tx hash to prove', undefined, types.string)
.setAction(async taskArgs => {
const txHash = taskArgs.txHash;
console.log(`The l2 tx hash: ${txHash}`);

const { messenger } = await initMessenger();

const status = await messenger.getMessageStatus(txHash);
console.log(`The message status update to: ${manta.MessageStatus[status]}`);

const fees = await suggestFees(messenger.l1Provider);
console.log(`The suggest fees: ${JSON.stringify(fees)}`);
const baseFee = ethers.BigNumber.from(fees.baseFeeSuggestion);
const maxPriorityFeePerGas = ethers.BigNumber.from(fees.maxPriorityFeeSuggestions.fast);
const maxFeePerGas = maxPriorityFeePerGas.add(baseFee.mul(ethers.BigNumber.from(2)));
/**
* Wait until the message is ready to prove
* This step can take a few minutes.
*/
await messenger.waitForMessageStatus(txHash, manta.MessageStatus.READY_TO_PROVE);
/**
* Once the message is ready to be proven, you'll send an L1 transaction to prove that the message was sent on L2.
*/
console.log(`Proving the message...`);
const tx = await messenger.proveMessage(txHash, {
maxFeePerGas: maxFeePerGas,
maxPriorityFeePerGas: maxPriorityFeePerGas,
});
console.log(`The prove tx hash: ${tx.hash}`);
await tx.wait();
console.log(`The message has been proven`);
});

task('changeFeeParams', 'Change fee params for zkLink').setAction(async (_, hre) => {
const { messenger, ethereumName, mantaName } = await initMessenger();

Expand Down
22 changes: 22 additions & 0 deletions examples/mantle/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/mantle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"devDependencies": {
"@mantleio/sdk": "^1.0.3",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@rainbow-me/fee-suggestions": "^2.1.0",
"ethers": "^5.7.2",
"hardhat": "^2.9.1"
},
Expand Down
35 changes: 35 additions & 0 deletions examples/mantle/scripts/mantleTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const mantle = require('@mantleio/sdk');
const { applyL1ToL2Alias } = require('@mantleio/core-utils');
const ethers = require('ethers');
const { BigNumber, Contract } = require('ethers');
const { suggestFees } = require('@rainbow-me/fee-suggestions');
const {
syncBatchRoot,
syncL2Requests,
Expand Down Expand Up @@ -67,6 +68,40 @@ task('syncL2Requests', 'Send sync point to arbitrator')
// https://sepolia.etherscan.io/tx/0x1a0f721a5d0c4bcc334ad6d54a60ae4ce4b5e52c71f3e48f62e2f2c980885b61
});

task('proveL2Tx', 'Prove L2 tx')
.addParam('txHash', 'The tx hash to prove', undefined, types.string)
.setAction(async taskArgs => {
const txHash = taskArgs.txHash;
console.log(`The l2 tx hash: ${txHash}`);

const { messenger } = await initMessenger();

const status = await messenger.getMessageStatus(txHash);
console.log(`The message status update to: ${mantle.MessageStatus[status]}`);

const fees = await suggestFees(messenger.l1Provider);
console.log(`The suggest fees: ${JSON.stringify(fees)}`);
const baseFee = BigNumber.from(fees.baseFeeSuggestion);
const maxPriorityFeePerGas = BigNumber.from(fees.maxPriorityFeeSuggestions.fast);
const maxFeePerGas = maxPriorityFeePerGas.add(baseFee.mul(BigNumber.from(2)));
/**
* Wait until the message is ready to prove
* This step can take a few minutes.
*/
await messenger.waitForMessageStatus(txHash, mantle.MessageStatus.READY_TO_PROVE);
/**
* Once the message is ready to be proven, you'll send an L1 transaction to prove that the message was sent on L2.
*/
console.log(`Proving the message...`);
const tx = await messenger.proveMessage(txHash, {
maxFeePerGas: maxFeePerGas,
maxPriorityFeePerGas: maxPriorityFeePerGas,
});
console.log(`The prove tx hash: ${tx.hash}`);
await tx.wait();
console.log(`The message has been proven`);
});

task('changeFeeParams', 'Change fee params for zkLink').setAction(async (_, hre) => {
const { messenger, ethereumName, mantleName } = await initMessenger();

Expand Down
Loading