From 1dfc6fc889b14952b0b0962946a8e5ed626a970b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 2 Jul 2025 17:15:21 +0000 Subject: [PATCH 1/3] Initial plan From 3281357a60e14f1d5cb3c1e85b0a5824fd1e940e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 2 Jul 2025 17:24:08 +0000 Subject: [PATCH 2/3] Fix spelling and grammar errors in README Co-authored-by: yahgwai <1663175+yahgwai@users.noreply.github.com> --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b77f217..5748816 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ This workshop follows through sending transactions on Arbitrum, inspecting their ## Useful links * Arbitrum One RPC - https://arb-mainnet.g.alchemy.com/v2/cAVH7BTBvbzIucuwkjbltCH-RxNkFCe1 * Ethereum RPC - https://mainnet.infura.io/v3/6faa1b9b8d274a7f96192e868a65f6d4 -* Follow along tx id if not sending your own- `0xb6f34cb1a7ef3d6d2e062815df80b47a151cd10026227a7f5326912a257602bb` -* L1/L2 gas -https://developer.arbitrum.io/arbos/gas +* Follow along tx id if not sending your own - `0xb6f34cb1a7ef3d6d2e062815df80b47a151cd10026227a7f5326912a257602bb` +* L1/L2 gas - https://developer.arbitrum.io/arbos/gas * Transaction lifecycle - https://developer.arbitrum.io/tx-lifecycle * ArbOS precompiles - https://developer.arbitrum.io/arbos/precompiles * RLP encoding - https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/ @@ -21,10 +21,10 @@ Please install the following, if you don't have them already - followed by `foundryup` * [jq](https://stedolan.github.io/jq/) - might be installed by default - Mac OS - `brew install jq` - - Ubuntu - `apt get install jq` + - Ubuntu - `apt-get install jq` * [brotli](https://github.com/google/brotli) - compression algorithm - Mac OS - `brew install brotli` - - Ubuntu - `apt get install brotli` + - Ubuntu - `apt-get install brotli` You may need to open a new shell after installing these @@ -34,7 +34,7 @@ In a new shell do the following: ``` git clone git@github.com:yahgwai/devcon-workshop.git ``` -1. Test foundry exists - if it doesn't foundry installed properly. +1. Test foundry exists - if it doesn't, foundry didn't install properly. ``` cast --version ``` @@ -64,7 +64,7 @@ Once you've chosen a transaction hash to use, set it as an environment variable TX_ID= ``` -## Step 2 - Inpect the transaction receipt +## Step 2 - Inspect the transaction receipt 1. Get the transaction receipt by calling the ARB_ONE rpc, and prettify with jq. ``` curl -s -X POST -H "Content-Type: application/json" \ @@ -84,7 +84,7 @@ TX_ID= ``` echo $GAS_USED_L1 ``` - Is the value what you expected? You might have expected this value to be much lower as all we need L1 gas for is to pay for call data. Call data is only 16 gas per byte, and standard token transfer only has around 190 bytes when [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/) encoded. A quick calculation shows that we should have expected to use around 16 * 180 = 2880 units of l1 gas which probably isn't the same order of magnitude as the value you have for `gasUsedForL1`. But remember that although `gasUsedForL1` pays for L1 costs, it is in units of L2 gas. We'll explore that concept more in the nexts stepts. + Is the value what you expected? You might have expected this value to be much lower as all we need L1 gas for is to pay for call data. Call data is only 16 gas per byte, and standard token transfer only has around 190 bytes when [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/) encoded. A quick calculation shows that we should have expected to use around 16 * 180 = 2880 units of l1 gas which probably isn't the same order of magnitude as the value you have for `gasUsedForL1`. But remember that although `gasUsedForL1` pays for L1 costs, it is in units of L2 gas. We'll explore that concept more in the next steps. 4. Also store the value of blockhash and block number for later use: ``` L2_BLOCKHASH= @@ -92,7 +92,7 @@ TX_ID= ``` ### Step 3 - Getting the L1 base fee estimate as seen on L2 -1. Lets try to convert `gasUsedForL1` from units of L2 gas to L1 gas to see if the amount matches up with our rought estimate above. To do that we need to find out: +1. Lets try to convert `gasUsedForL1` from units of L2 gas to L1 gas to see if the amount matches up with our rough estimate above. To do that we need to find out: - What the L1 base fee was at the time, as seen by the L2 - What the L2 base fee was at the time 2. The L2 periodically receives information about the L1 base fee and updates it's local view. It also adjusts it based on how the accuracy of previous estimates. You can read more about this process [here]( https://developer.arbitrum.io/arbos/l1-pricing#adjusting-the-l1-gas-basefee). @@ -127,7 +127,7 @@ TX_ID= ### Step 5 - comparison to actual bytes 1. We can now [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/) encode the transaction and measure the number of bytes. Note that we don't expect this to be exactly the same due to a number of reasons: - - The gas used for L1 includes some compression factor - this isn't as high as when we the transaction is included in a batch, but it is a factor + - The gas used for L1 includes some compression factor - this isn't as high as when the transaction is included in a batch, but it is a factor - There is also a small amount L1 gas that must be paid for batch overheads 2. RLP encode the transaction: ``` @@ -174,4 +174,4 @@ TX_ID= ls -l ``` Now compare the size of `batchData.txt` with `compressedBatchData.br` -7. Finally, open `batchData.txt` in a text editor. Can find your RLP encoded transaction - $TX_RLP - in the data? +7. Finally, open `batchData.txt` in a text editor. Can you find your RLP encoded transaction - $TX_RLP - in the data? From 50cda2bfd116a1b5da3659341f36ca9373cc6e6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 2 Jul 2025 20:17:42 +0000 Subject: [PATCH 3/3] Fix additional spelling and grammar errors found in README Co-authored-by: yahgwai <1663175+yahgwai@users.noreply.github.com> --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5748816..a07036c 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ This workshop follows through sending transactions on Arbitrum, inspecting their ## Prerequisites Please install the following, if you don't have them already -* An ethereum wallet (eg metamasdk browser extension) +* An ethereum wallet (eg metamask browser extension) * [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) - version control system -* [curl](https://curl.se/) - A http request util, probably installed by default +* [curl](https://curl.se/) - An HTTP request util, probably installed by default * [Foundry](https://github.com/foundry-rs/foundry) - tools for, amongst other things, making ethereum JSON-RPC requests - run: `curl -L https://foundry.paradigm.xyz | bash` - followed by `foundryup` @@ -92,10 +92,10 @@ TX_ID= ``` ### Step 3 - Getting the L1 base fee estimate as seen on L2 -1. Lets try to convert `gasUsedForL1` from units of L2 gas to L1 gas to see if the amount matches up with our rough estimate above. To do that we need to find out: +1. Let's try to convert `gasUsedForL1` from units of L2 gas to L1 gas to see if the amount matches up with our rough estimate above. To do that we need to find out: - What the L1 base fee was at the time, as seen by the L2 - What the L2 base fee was at the time -2. The L2 periodically receives information about the L1 base fee and updates it's local view. It also adjusts it based on how the accuracy of previous estimates. You can read more about this process [here]( https://developer.arbitrum.io/arbos/l1-pricing#adjusting-the-l1-gas-basefee). +2. The L2 periodically receives information about the L1 base fee and updates its local view. It also adjusts it based on how the accuracy of previous estimates. You can read more about this process [here]( https://developer.arbitrum.io/arbos/l1-pricing#adjusting-the-l1-gas-basefee). 3. In order to find out what the L1 base fee estimate was at the time we can query the [getL1BaseFeeEstimate](https://github.com/OffchainLabs/nitro/blob/v2.0.7/contracts/src/precompiles/ArbGasInfo.sol#L93) function on the ArbGasInfo precompile which can be found at address `0x000000000000000000000000000000000000006c`. We can use `cast` to make this call, taking care to specify that we want the value as it was at the time the transaction was sent using the `L2_BLOCKHASH` var. ``` cast call --rpc-url $ARB_RPC -b $L2_BLOCKHASH 0x000000000000000000000000000000000000006c 'function getL1BaseFeeEstimate() external view returns (uint256)' @@ -156,7 +156,7 @@ TX_ID= echo $BATCH_TX_ID ``` -4. The sequencer submits the batch via the [addSequencerL2BatchFromOrigin](https://github.com/OffchainLabs/nitro/blob/v2.0.0/contracts/src/bridge/SequencerInbox.sol#L143) function on the SequencerInbox. The batch is the data field in the call data. Given the fixed size of the other arguments we can be sure that the data field starts at position 458 in the call data. Let's download the data, then save everything after position 458 to file. +4. The sequencer submits the batch via the [addSequencerL2BatchFromOrigin](https://github.com/OffchainLabs/nitro/blob/v2.0.0/contracts/src/bridge/SequencerInbox.sol#L143) function on the SequencerInbox. The batch is the data field in the call data. Given the fixed size of the other arguments we can be sure that the data field starts at position 458 in the call data. Let's download the data, then save everything after position 458 to a file. ``` BATCH_TX_DATA=$(cast tx --rpc-url $ETH_RPC $BATCH_TX_ID input) echo ${BATCH_TX_DATA:458} > txDataField.br