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

core: implement EIP-2935 #29465

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

core: implement EIP-2935 #29465

wants to merge 1 commit into from

Conversation

s1na
Copy link
Contributor

@s1na s1na commented Apr 5, 2024

Copied over and adapted from https://github.com/gballet/go-ethereum/tree/kaustinen-with-shapella, following the latest changes to the spec: ethereum/EIPs#8166

core/vm/eips.go Outdated

func getBlockHashFromContract(number uint64, statedb StateDB) common.Hash {
ringIndex := number % 256
var pnum common.Hash
Copy link
Contributor

Choose a reason for hiding this comment

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

pnum isn't very helpful. pNum? but what is p?

Copy link
Contributor

Choose a reason for hiding this comment

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

how about parentNumber

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to slot as it is the encoded storage key for a given ancestor.

core/vm/eips.go Outdated
func enable2935(jt *JumpTable) {
jt[BLOCKHASH] = &operation{
execute: opBlockhash2935,
// TODO: gas params
Copy link
Member

Choose a reason for hiding this comment

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

Leftover note to self?

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 ended up deleting the new BLOCKHASH implementation. We can just continue how we did it before. Specially since the spec doesn't update the gas price of the opcode.

miner/worker.go Show resolved Hide resolved
cmd/evm/internal/t8ntool/execution.go Show resolved Hide resolved
@jsign
Copy link
Contributor

jsign commented Apr 15, 2024

@s1na, pinging you to be aware of some extra changes that happened on Kaustinen after you pulled the work from the other branch, see: gballet#411, which some days after where also updated in the EIP ethereum/EIPs@2b73ecb

core/state_processor.go Outdated Show resolved Hide resolved
Comment on lines +84 to +86
if p.config.IsPrague(block.Number(), block.Time()) {
ProcessBlockHashHistory(statedb, block.Header(), p.config, p.bc)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is a bit convoluted. There are basically two paths:

  1. On the exact fork-block: we need to iterate and add 256 hashes
  2. On every block after the fork: we need to add the parent hash.

The code, as written, makes path 1 the 'default-path'. We always enter the ProcessBlockHashHistory, which invokes ProcessParentBlockHash and just exits before iterating. IMO it would be more intuitive to default to path 2, invoke ProcessParentBlockHash by default, and only ever once invoke ProcessBlockHashHistory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think of it this way: the parent's block hash is always inserted. The other 8191 block hashes are only inserted in a certain condition after the parent one. Also having one wrapping method makes the footprint inside state_processor, miner etc. smaller.

@lightclient lightclient force-pushed the eip-2935 branch 2 times, most recently from 64e49c2 to 62cf853 Compare May 13, 2024 09:12
Co-authored-by: Guillaume Ballet <gballet@gmail.com>
Co-authored-by: Ignacio Hagopian <jsign.uy@gmail.com>
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.

None yet

6 participants