Skip to content

Conversation

IchiBera
Copy link
Contributor

@IchiBera IchiBera commented Jun 5, 2025

Description

Guide for Write EIP 2935 Gas Comparison Guide #121.

Contribution

@IchiBera IchiBera self-assigned this Jun 5, 2025
@IchiBera IchiBera changed the title EIP-2935 Historical Block Hashes Quickstart for Guide EIP-2935 Historical Block Hashes Detailed Guide Jun 5, 2025
Copy link

vercel bot commented Jun 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
berachain-docs-bex ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2025 9:32pm

@IchiBera
Copy link
Contributor Author

IchiBera commented Jun 9, 2025

@okjintao Thanks for your review! I've gone through and made changes, as well as left a comment for us to sync up on.

Copy link
Contributor

@okjintao okjintao left a comment

Choose a reason for hiding this comment

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

lg


Before EIP-2935, smart contracts could access only the last 256 block hashes using the `BLOCKHASH` opcode. This process raised challenges though:

- Accessing a hash outside that window, returned `0x0`, silently,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Accessing a hash outside that window, returned `0x0`, silently,
- Accessing a hash outside that window returns `0x0` silently

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change made.

Before EIP-2935, smart contracts could access only the last 256 block hashes using the `BLOCKHASH` opcode. This process raised challenges though:

- Accessing a hash outside that window, returned `0x0`, silently,
- You couldn’t fetch a blockhash using dynamic inputs (e.g. calldata or computation),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove commas at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change made.

- `eip2935GasComparison.s.sol` - A solidity script used to deploy the `eip2935GasComparison.sol` and make calls to it to simulate different blockhash reading methods.
- `run_gas_comparison.sh` - A bash script created to deploy `eip2935GasComparison.sol` and tabulate the gas expenditure results.

### Prerequisites
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
### Prerequisites
### Requirements

and make it a list with versions of each tool needed vs installs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes made.


Anyone can later call the system contract to retrieve a blockhash from that range.

## Guide
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revise for keywords

Suggested change
## Guide
## How To Obtain BlockHashes & Store Them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


Go through the following steps:

### Step 1 - Install Deps
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
### Step 1 - Install Deps
### Step 1 - Install Dependencies


```bash
# From apps/eip-2935-gas-comparison
source .env && anvil --fork-url $BEPOLIA_RPC_URL --fork-block-number 4867668 --chain-id 80069 --port 8545
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use ```bash-vue to add variables for the bepolia rpc and chain id


```bash
# From apps/eip-2935-gas-comparison
./script/run_gas-comparison.sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
./script/run_gas-comparison.sh
# FROM: ./
./script/run_gas-comparison.sh;
# [Expected Similar Result]:
# ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe I have seen it written in the way I wrote within other guides. So are we always doing relative path locations like this going forward?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes made, and also added in a code snippit of what the terminal output should look like when running the script. I left it so the guide still elaborates on the results later on.


The bash script, `run_gas_comparison.sh` deploys the `eip2935GasComparison.sol` contract on the locally ran anvil fork of Bepolia. It then goes through the results and tabulates the total gas expenses for each blockhashing method, including storing the blockhash or replicating the usage of an oracle.

#### Step 6 - Highlevel Review of the Solidity File
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#### Step 6 - Highlevel Review of the Solidity File
### Step 6 - Highlevel Review of the Solidity File

Comment on lines +159 to +161
### Step 5 - Understanding What the Script Does

The bash script, `run_gas_comparison.sh` deploys the `eip2935GasComparison.sol` contract on the locally ran anvil fork of Bepolia. It then goes through the results and tabulates the total gas expenses for each blockhashing method, including storing the blockhash or replicating the usage of an oracle.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Go over the solidity code here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I continue to go through the solidity code, and the methods assessed after this small section. Did you want me to rewrite it in a particular way?

@codingwithmanny
Copy link
Collaborator

Missing link in sidebar or contributions section

@IchiBera
Copy link
Contributor Author

IchiBera commented Jun 12, 2025

Thanks for the reviews @okjintao @codingwithmanny. Manny, I made a couple of comments on some of your CRs. Please let me know if you would like me to correct anything else / if I misinterpreted your comments.

I will make the same changes to the quickstart (if applicable) in the guides repo..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants