From 2f18a5732f86469a66ec1e722568d41f3a3f63a0 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Fri, 20 Sep 2024 12:05:36 +0200 Subject: [PATCH 1/8] Added fee token pricer command --- scripts/ethcommands.ts | 59 ++++++++++++++++++++++++++++++++++++++++++ scripts/index.ts | 2 ++ test-node.bash | 13 ++++++++++ 3 files changed, 74 insertions(+) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index ac85ed69..a9854271 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -139,6 +139,41 @@ async function deployERC20Contract(deployerWallet: Wallet, decimals: number): Pr return token.address; } +async function deployFeeTokenPricerContract(deployerWallet: Wallet, exchangeRate: BigNumber): Promise { + //// Bytecode below is generated from this simple FeeTokenPricer contract + + // pragma solidity ^0.8.16; + + // interface IFeeTokenPricer { + // /** + // * @notice Get the number of child chain's fee tokens per 1 parent chain's native token. Exchange rate must be + // * denominated in 18 decimals. + // * @dev For example, parent chain's native token is ETH, fee token is DAI. If price of 1ETH = 2000DAI, then function should return 2000*1e18. + // * If fee token is USDC instead and price of 1ETH = 2000USDC, function should still return 2000*1e18, no matter that USDC uses 6 decimals. + // */ + // function getExchangeRate() external returns (uint256); + // } + + // contract ConstantFeeTokenPricer is IFeeTokenPricer { + // uint256 immutable public constExchangeRate; + // constructor(uint256 _constExchangeRate) { + // constExchangeRate = _constExchangeRate; + // } + + // function getExchangeRate() external view returns (uint256) { + // return constExchangeRate; + // } + // } + + const feeTokenPricerBytecode = "0x60a0604052348015600e575f80fd5b506040516101c63803806101c68339818101604052810190602e9190606d565b8060808181525050506093565b5f80fd5b5f819050919050565b604f81603f565b81146058575f80fd5b50565b5f815190506067816048565b92915050565b5f60208284031215607f57607e603b565b5b5f608a84828501605b565b91505092915050565b6080516101166100b05f395f8181606a0152608f01526101165ff3fe6080604052348015600e575f80fd5b50600436106030575f3560e01c8063b8910a29146034578063e6aa216c14604e575b5f80fd5b603a6068565b6040516045919060c9565b60405180910390f35b6054608c565b604051605f919060c9565b60405180910390f35b7f000000000000000000000000000000000000000000000000000000000000000081565b5f7f0000000000000000000000000000000000000000000000000000000000000000905090565b5f819050919050565b60c38160b3565b82525050565b5f60208201905060da5f83018460bc565b9291505056fea2646970667358221220ee17f22614d853ccf8b3f854137f68f06ff92f9f71ba8b811d78b1313eead0c564736f6c634300081a0033"; + const abi = ["constructor(uint256 exchangeRate)"]; + const feeTokenPricerFactory = new ContractFactory(abi, feeTokenPricerBytecode, deployerWallet); + const feeTokenPricer = await feeTokenPricerFactory.deploy(exchangeRate); + await feeTokenPricer.deployTransaction.wait(); + + return feeTokenPricer.address; +} + export const bridgeFundsCommand = { command: "bridge-funds", describe: "sends funds from l1 to l2", @@ -372,6 +407,30 @@ export const createERC20Command = { }, }; +export const createFeeTokenPricerCommand = { + command: "create-fee-token-pricer", + describe: "creates Constant Fee Token Pricer on L2", + builder: { + deployer: { + string: true, + describe: "account (see general help)" + }, + }, + handler: async (argv: any) => { + console.log("create-fee-token-pricer"); + + argv.provider = new ethers.providers.WebSocketProvider(argv.l2url); + const deployerWallet = new Wallet( + ethers.utils.sha256(ethers.utils.toUtf8Bytes(argv.deployer)), + argv.provider + ); + const feeTokenPricerAddress = await deployFeeTokenPricerContract(deployerWallet, BigNumber.from("10000000000000000000")); + console.log("Contract deployed at address:", feeTokenPricerAddress); + + argv.provider.destroy(); + }, +}; + export const transferERC20Command = { command: "transfer-erc20", describe: "transfers ERC20 token", diff --git a/scripts/index.ts b/scripts/index.ts index 69cfe156..bad2a155 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -21,6 +21,7 @@ import { sendRPCCommand, waitForSyncCommand, transferL3ChainOwnershipCommand, + createFeeTokenPricerCommand, } from "./ethcommands"; async function main() { @@ -38,6 +39,7 @@ async function main() { .command(bridgeToL3Command) .command(bridgeNativeTokenToL3Command) .command(createERC20Command) + .command(createFeeTokenPricerCommand) .command(transferERC20Command) .command(sendL1Command) .command(sendL2Command) diff --git a/test-node.bash b/test-node.bash index 685dea29..4cd8319b 100755 --- a/test-node.bash +++ b/test-node.bash @@ -201,6 +201,14 @@ while [[ $# -gt 0 ]]; do l3_custom_fee_token=true shift ;; + --l3-fee-token-pricer) + if ! $l3_custom_fee_token; then + echo "Error: --l3-fee-token-pricer requires --l3-fee-token to be provided." + exit 1 + fi + l3_custom_fee_token_pricer=true + shift + ;; --l3-fee-token-decimals) if ! $l3_custom_fee_token; then echo "Error: --l3-fee-token-decimals requires --l3-fee-token to be provided." @@ -495,6 +503,11 @@ if $force_init; then docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to l3owner docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to user_token_bridge_deployer EXTRA_L3_DEPLOY_FLAG="-e FEE_TOKEN_ADDRESS=$nativeTokenAddress" + if $l3_custom_fee_token_pricer; then + echo == Deploying custom fee token pricer + feeTokenPricerAddress=`docker compose run scripts create-fee-token-pricer --deployer user_fee_token_deployer | tail -n 1 | awk '{ print $NF }'` + EXTRA_L3_DEPLOY_FLAG="$EXTRA_L3_DEPLOY_FLAG -e FEE_TOKEN_PRICER_ADDRESS=$feeTokenPricerAddress" + fi fi echo == Deploying L3 From d5298335856c7df9a29b882daabf75b96c5eb980 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Thu, 26 Sep 2024 13:51:13 +0200 Subject: [PATCH 2/8] Updated nitro contracts version --- scripts/ethcommands.ts | 2 +- test-node.bash | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index a9854271..a363f85f 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -424,7 +424,7 @@ export const createFeeTokenPricerCommand = { ethers.utils.sha256(ethers.utils.toUtf8Bytes(argv.deployer)), argv.provider ); - const feeTokenPricerAddress = await deployFeeTokenPricerContract(deployerWallet, BigNumber.from("10000000000000000000")); + const feeTokenPricerAddress = await deployFeeTokenPricerContract(deployerWallet, BigNumber.from("15000000000000000000")); console.log("Contract deployed at address:", feeTokenPricerAddress); argv.provider.destroy(); diff --git a/test-node.bash b/test-node.bash index 4cd8319b..d40566c6 100755 --- a/test-node.bash +++ b/test-node.bash @@ -6,7 +6,7 @@ NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.1.2-309340a-dev BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.1.0-0e716c8 # This commit matches v2.1.0 release of nitro-contracts, with additional support to set arb owner through upgrade executor -DEFAULT_NITRO_CONTRACTS_VERSION="99c07a7db2fcce75b751c5a2bd4936e898cda065" +DEFAULT_NITRO_CONTRACTS_VERSION="e852b6a0e4d770ae35f4213be357bb93830ca44d" DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2" # Set default versions if not overriden by provided env vars @@ -44,6 +44,7 @@ l3node=false consensusclient=false redundantsequencers=0 l3_custom_fee_token=false +l3_custom_fee_token_pricer=false l3_token_bridge=false l3_custom_fee_token_decimals=18 batchposters=1 From 351be2e1906347acd415ad9bf50a4c56ba1488b3 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Thu, 26 Sep 2024 15:15:45 +0200 Subject: [PATCH 3/8] Reset nitro contracts version --- test-node.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-node.bash b/test-node.bash index d40566c6..65acbfb1 100755 --- a/test-node.bash +++ b/test-node.bash @@ -6,7 +6,7 @@ NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.1.2-309340a-dev BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.1.0-0e716c8 # This commit matches v2.1.0 release of nitro-contracts, with additional support to set arb owner through upgrade executor -DEFAULT_NITRO_CONTRACTS_VERSION="e852b6a0e4d770ae35f4213be357bb93830ca44d" +DEFAULT_NITRO_CONTRACTS_VERSION="99c07a7db2fcce75b751c5a2bd4936e898cda065" DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2" # Set default versions if not overriden by provided env vars From f504a0a0eb87cb7aeb1c215fb1f4b53b7631656c Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Tue, 4 Feb 2025 16:55:35 +0000 Subject: [PATCH 4/8] Commented out fee token pricer change --- test-node.bash | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test-node.bash b/test-node.bash index 412da0a5..31e71f54 100755 --- a/test-node.bash +++ b/test-node.bash @@ -227,14 +227,14 @@ while [[ $# -gt 0 ]]; do l3_custom_fee_token=true shift ;; - --l3-fee-token-pricer) - if ! $l3_custom_fee_token; then - echo "Error: --l3-fee-token-pricer requires --l3-fee-token to be provided." - exit 1 - fi - l3_custom_fee_token_pricer=true - shift - ;; + # --l3-fee-token-pricer) + # if ! $l3_custom_fee_token; then + # echo "Error: --l3-fee-token-pricer requires --l3-fee-token to be provided." + # exit 1 + # fi + # l3_custom_fee_token_pricer=true + # shift + # ;; --l3-fee-token-decimals) if ! $l3_custom_fee_token; then echo "Error: --l3-fee-token-decimals requires --l3-fee-token to be provided." @@ -592,11 +592,11 @@ if $force_init; then docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to l3owner docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to user_token_bridge_deployer EXTRA_L3_DEPLOY_FLAG="-e FEE_TOKEN_ADDRESS=$nativeTokenAddress" - if $l3_custom_fee_token_pricer; then - echo == Deploying custom fee token pricer - feeTokenPricerAddress=`docker compose run scripts create-fee-token-pricer --deployer user_fee_token_deployer | tail -n 1 | awk '{ print $NF }'` - EXTRA_L3_DEPLOY_FLAG="$EXTRA_L3_DEPLOY_FLAG -e FEE_TOKEN_PRICER_ADDRESS=$feeTokenPricerAddress" - fi + # if $l3_custom_fee_token_pricer; then + # echo == Deploying custom fee token pricer + # feeTokenPricerAddress=`docker compose run scripts create-fee-token-pricer --deployer user_fee_token_deployer | tail -n 1 | awk '{ print $NF }'` + # EXTRA_L3_DEPLOY_FLAG="$EXTRA_L3_DEPLOY_FLAG -e FEE_TOKEN_PRICER_ADDRESS=$feeTokenPricerAddress" + # fi fi echo == Deploying L3 From 939927d361275db6a96eb8353acab56aaadae7a9 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Tue, 4 Feb 2025 17:25:52 +0000 Subject: [PATCH 5/8] Added docker tmp access --- test-node.bash | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test-node.bash b/test-node.bash index 31e71f54..438531d1 100755 --- a/test-node.bash +++ b/test-node.bash @@ -227,14 +227,14 @@ while [[ $# -gt 0 ]]; do l3_custom_fee_token=true shift ;; - # --l3-fee-token-pricer) - # if ! $l3_custom_fee_token; then - # echo "Error: --l3-fee-token-pricer requires --l3-fee-token to be provided." - # exit 1 - # fi - # l3_custom_fee_token_pricer=true - # shift - # ;; + --l3-fee-token-pricer) + if ! $l3_custom_fee_token; then + echo "Error: --l3-fee-token-pricer requires --l3-fee-token to be provided." + exit 1 + fi + l3_custom_fee_token_pricer=true + shift + ;; --l3-fee-token-decimals) if ! $l3_custom_fee_token; then echo "Error: --l3-fee-token-decimals requires --l3-fee-token to be provided." @@ -384,7 +384,7 @@ if $build_utils; then if [ "$ci" == true ]; then # workaround to cache docker layers and keep using docker-compose in CI - docker buildx bake --file docker-compose.yaml --file docker-compose-ci-cache.json $LOCAL_BUILD_NODES + docker buildx bake --allow=fs=/tmp/ --file docker-compose.yaml --file docker-compose-ci-cache.json $LOCAL_BUILD_NODES else UTILS_NOCACHE="" if $force_build_utils; then @@ -592,11 +592,11 @@ if $force_init; then docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to l3owner docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to user_token_bridge_deployer EXTRA_L3_DEPLOY_FLAG="-e FEE_TOKEN_ADDRESS=$nativeTokenAddress" - # if $l3_custom_fee_token_pricer; then - # echo == Deploying custom fee token pricer - # feeTokenPricerAddress=`docker compose run scripts create-fee-token-pricer --deployer user_fee_token_deployer | tail -n 1 | awk '{ print $NF }'` - # EXTRA_L3_DEPLOY_FLAG="$EXTRA_L3_DEPLOY_FLAG -e FEE_TOKEN_PRICER_ADDRESS=$feeTokenPricerAddress" - # fi + if $l3_custom_fee_token_pricer; then + echo == Deploying custom fee token pricer + feeTokenPricerAddress=`docker compose run scripts create-fee-token-pricer --deployer user_fee_token_deployer | tail -n 1 | awk '{ print $NF }'` + EXTRA_L3_DEPLOY_FLAG="$EXTRA_L3_DEPLOY_FLAG -e FEE_TOKEN_PRICER_ADDRESS=$feeTokenPricerAddress" + fi fi echo == Deploying L3 From b06268535687cb8a7090f549545aa6adae43f1cd Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Sat, 8 Feb 2025 12:11:28 +0000 Subject: [PATCH 6/8] Set config version --- scripts/config.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/config.ts b/scripts/config.ts index 6323c7b5..e10f5718 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -72,7 +72,14 @@ function writeGethGenesisConfig(argv: any) { "shanghaiTime": 0, "cancunTime": 1706778826, "terminalTotalDifficulty": 0, - "terminalTotalDifficultyPassed": true + "terminalTotalDifficultyPassed": true, + "blobSchedule": { + "cancun": { + "target": 3, + "max": 6, + "baseFeeUpdateFraction": 3338477 + } + } }, "difficulty": "0", "extradata": "0x00000000000000000000000000000000000000000000000000000000000000003f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E0B0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", From 12652fe11861e913943e64af6c5db171d6cad6c0 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Sat, 8 Feb 2025 12:47:06 +0000 Subject: [PATCH 7/8] Use older geth version --- docker-compose.yaml | 2 +- scripts/config.ts | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 670d1238..43b71248 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -47,7 +47,7 @@ services: - "127.0.0.1:6379:6379" geth: - image: ethereum/client-go:stable + image: ethereum/client-go:v1.14.13 ports: - "127.0.0.1:8545:8545" - "127.0.0.1:8551:8551" diff --git a/scripts/config.ts b/scripts/config.ts index e10f5718..6323c7b5 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -72,14 +72,7 @@ function writeGethGenesisConfig(argv: any) { "shanghaiTime": 0, "cancunTime": 1706778826, "terminalTotalDifficulty": 0, - "terminalTotalDifficultyPassed": true, - "blobSchedule": { - "cancun": { - "target": 3, - "max": 6, - "baseFeeUpdateFraction": 3338477 - } - } + "terminalTotalDifficultyPassed": true }, "difficulty": "0", "extradata": "0x00000000000000000000000000000000000000000000000000000000000000003f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E0B0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", From af62d00c1deeceee9f686d4dc518e16c04e48a40 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Fri, 21 Feb 2025 15:37:43 +0000 Subject: [PATCH 8/8] Switch back to stable --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index e1c797cc..0f1e5501 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -47,7 +47,7 @@ services: - "127.0.0.1:6379:6379" geth: - image: ethereum/client-go:v1.14.13 + image: ethereum/client-go:stable ports: - "127.0.0.1:8545:8545" - "127.0.0.1:8551:8551"