From 2c29d90a277802c4e78acf2a38e4814e676a3e55 Mon Sep 17 00:00:00 2001 From: Zach Obront Date: Fri, 24 Jan 2025 14:05:08 -0600 Subject: [PATCH] readme --- README.md | 78 +++++++------------------- script/Counter.s.sol | 19 ------- script/GPGWallet/AddSigner.s.sol | 28 +++++++++ script/L1DataFee/.DS_Store | Bin 0 -> 6148 bytes script/L1DataFee/FundOwner.s.sol | 19 +++++++ script/L1DataFee/SendL2Tx.s.sol | 21 +++++++ script/L1DataFee/UpdateFallback.s.sol | 22 ++++++++ script/L1DataFee/UpdateOracle.s.sol | 22 ++++++++ src/Counter.sol | 14 ----- src/IGPGWallet.sol | 13 +++++ src/IGasPriceOracle.sol | 8 +++ src/IProxyAdmin.sol | 7 +++ src/MockOracle.sol | 32 +++++++++++ test/Counter.t.sol | 24 -------- 14 files changed, 191 insertions(+), 116 deletions(-) delete mode 100644 script/Counter.s.sol create mode 100644 script/GPGWallet/AddSigner.s.sol create mode 100644 script/L1DataFee/.DS_Store create mode 100644 script/L1DataFee/FundOwner.s.sol create mode 100644 script/L1DataFee/SendL2Tx.s.sol create mode 100644 script/L1DataFee/UpdateFallback.s.sol create mode 100644 script/L1DataFee/UpdateOracle.s.sol delete mode 100644 src/Counter.sol create mode 100644 src/IGPGWallet.sol create mode 100644 src/IGasPriceOracle.sol create mode 100644 src/IProxyAdmin.sol create mode 100644 src/MockOracle.sol delete mode 100644 test/Counter.t.sol diff --git a/README.md b/README.md index 9265b45..14aa09e 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,26 @@ -## Foundry +## Tea Scripts -**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** +This repo contains scripts to run on a local devnet of the Layer Tea network to verify the network's functionality. -Foundry consists of: +### Prerequisites -- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). -- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. -- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. -- **Chisel**: Fast, utilitarian, and verbose solidity REPL. +- Run a local devnet, and save the L2 RPC URL. +- Set `PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80` in your environment (this corresponds to a prefunded address on the devnet) +- Set `OWNER_PRIVATE_KEY=???` in your environment (this is the address who can update the fallback price and oracle) +- Run the `Deploy.s.sol` and `Airdrop.s.sol` scripts on the `GPGWallet` repo (you must use the same `PREFUNDED_PRIVATE_KEY` for these transactions so signatures are consistent). -## Documentation +### GPG Wallet Script -https://book.getfoundry.sh/ +- Copy the address of the wallet with the `0x49CEB217B43F2378` Key ID to `AddSigner.s.sol` (which corresponds to the GPG key used to provide the signature in that script) +- Run `forge script --rpc-url [L2RPC] script/GPGWallet/AddSigner.s.sol:AddSignerScript --broadcast` +- Verify that the transaction succeeded and the terminal output confirms the signer was added -## Usage +### L1 Data Fee Script -### Build - -```shell -$ forge build -``` - -### Test - -```shell -$ forge test -``` - -### Format - -```shell -$ forge fmt -``` - -### Gas Snapshots - -```shell -$ forge snapshot -``` - -### Anvil - -```shell -$ anvil -``` - -### Deploy - -```shell -$ forge script script/Counter.s.sol:CounterScript --rpc-url --private-key -``` - -### Cast - -```shell -$ cast -``` - -### Help - -```shell -$ forge --help -$ anvil --help -$ cast --help -``` +- We want to test that the data fee is adjusted for the currency, is responsive to the fallback price changing, and is responsive to an oracle. +- Note that after these transactions go through, the updates aren't propagated until the next epoch, so we need to wait at least 15-20 seconds between transactions. +- First, fund the owner account with ETH for transactions by calling `forge script --rpc-url [L2RPC] script/L1DataFee/FundOwner.s.sol:FundOwnerScript --broadcast`. +- Wait approximately 5 minutes for the L1BaseFee to fall to the minimum. You can check this with `cast call --rpc-url [L2RPC] 0x4200000000000000000000000000000000000015 "basefee()"`. It should return `0x7`. +- Run `forge script --rpc-url [L2RPC] script/L1DataFee/SendL2Tx.s.sol:SendL2Tx --broadcast` to send a transaction. Once the transaction is completed, use the tx hash to get the receipt with `cast receipt --rpc-url [L2RPC] [TX_HASH]`. The L1 Data Fee should be 16.8 billion or `0x3e95ba800`. +- Now, let's set a fallback. Run `forge script --rpc-url [L2RPC] script/L1DataFee/UpdateFallback.s.sol:UpdateFallbackScript --broadcast`. Wait for at least 15-20 seconds for the update to push through to the oracle. Then call the SendL2Tx transaction again, and use the tx hash to get the receipt with `cast receipt --rpc-url [L2RPC] [TX_HASH]`. The fallback should be set to 11.2 billion or `0x29b927000`. +- Finally, let's set an oracle. Run `forge script --rpc-url [L2RPC] script/L1DataFee/UpdateOracle.s.sol:UpdateOracleScript --broadcast`. Wait for at least 15-20 seconds for the update to push through to the oracle. Then call the SendL2Tx transaction again, and use the tx hash to get the receipt with `cast receipt --rpc-url [L2RPC] [TX_HASH]`. The oracle should be set to 22.4 billion or `0x53724e000`. diff --git a/script/Counter.s.sol b/script/Counter.s.sol deleted file mode 100644 index cdc1fe9..0000000 --- a/script/Counter.s.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Script, console} from "forge-std/Script.sol"; -import {Counter} from "../src/Counter.sol"; - -contract CounterScript is Script { - Counter public counter; - - function setUp() public {} - - function run() public { - vm.startBroadcast(); - - counter = new Counter(); - - vm.stopBroadcast(); - } -} diff --git a/script/GPGWallet/AddSigner.s.sol b/script/GPGWallet/AddSigner.s.sol new file mode 100644 index 0000000..4f78581 --- /dev/null +++ b/script/GPGWallet/AddSigner.s.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.15; + +import {Script, console} from "forge-std/Script.sol"; +import {IGPGWallet} from "src/IGPGWalletImpl.sol"; + +contract AddSignerScript is Script { + // Add deployed GPG Wallet here. + IGPGWallet constant WALLET = IGPGWallet(payable(address(1))); + + address EOA = makeAddr("eoa"); + bytes PUBKEY = + hex"9833046768354e16092b06010401da470f0101074089ea06d9820134822b9ddaeef1929c50ddfd9bbcf7c0794f3082d864fecb30feb42f5a616368204f62726f6e7420287465612d676574682d7465737429203c7a6f62726f6e7440676d61696c2e636f6d3e88930413160a003b162104c4e971386f7e24899b765c6b49ceb217b43f237805026768354e021b03050b0908070202220206150a09080b020416020301021e07021780000a091049ceb217b43f2378e65600ff538b73b85fc29fe716c0857343ac1efb4ac2864fd346de79f00d0e0f6d6e8e970100cdaf800a4ea1c9fabe8c982a191bff567c16019dad016c06e643b689ff3fd60eb838046768354e120a2b060104019755010501010740cf010ab1e65c0a4560292d4f8faaf2c03b6e115f2482464404d12bed986c8f530301080788780418160a0020162104c4e971386f7e24899b765c6b49ceb217b43f237805026768354e021b0c000a091049ceb217b43f237866a900fe2d50d10d916ced462d925220880b538cc9ab4fde817aa5bb3928d4f2a46003a50100d420071637d56defa999a22bc43bf0b0b179cf288d9643a54e98c13eb346df0a"; + bytes SIGNATURE = + hex"88750400160a001d162104c4e971386f7e24899b765c6b49ceb217b43f237805026793d29c000a091049ceb217b43f2378221b0100f01127f4494ccba47c7c177dfc84fd37e2521e4cdca171ff68220a36156d2a1300ff5cdff84af9d791cc03bf3d1098c97f858810d4858f4fed7bbc3c19ef166dda0c"; + + function run() external { + uint256 prefundedPrivateKey = vm.envUint("PREFUNDED_PRIVATE_KEY"); + vm.startBroadcast(prefundedPrivateKey); + + WALLET.addSigner(EOA, 0, 0, bytes32(0), PUBKEY, SIGNATURE); + + console.log("Is EOA now signer?"); + console.log(WALLET.signers(EOA)); + + vm.stopBroadcast(); + } +} diff --git a/script/L1DataFee/.DS_Store b/script/L1DataFee/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0