Skip to content

Commit 1043f66

Browse files
authored
feay(feynman): include history storage in witness for blockhash opcode (#1218)
* feat(feynman): include history storage in witness for blockhash * update param
1 parent 3661d18 commit 1043f66

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

core/vm/instructions.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,13 @@ func opBlockhashPostFeynman(pc *uint64, interpreter *EVMInterpreter, scope *Scop
490490
witness.AddBlockHash(num64)
491491
}
492492
num.SetBytes(res[:])
493+
494+
// for provability, revm loads block hash from the history storage system contract,
495+
// so we need to ensure that the corresponding slot is present in the execution witness.
496+
ringIndex := num64 % params.HistoryServeWindow
497+
var key common.Hash
498+
binary.BigEndian.PutUint64(key[24:], ringIndex)
499+
interpreter.evm.StateDB.GetState(params.HistoryStorageAddress, key)
493500
} else {
494501
num.Clear()
495502
}

params/protocol_params.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ const (
174174
BlobTxBlobGaspriceUpdateFraction = 5007716 // Controls the maximum rate of change for blob gas price, using Prague parameters
175175

176176
BlobTxTargetBlobGasPerBlock = 6 * BlobTxBlobGasPerBlob // Target consumable blob gas for data blobs per block (for 1559-like pricing), using Prague parameters
177-
178-
HistoryServeWindow = 8192 // Number of blocks to serve historical block hashes for, EIP-2935.
179177
)
180178

181179
// Gas discount table for BLS12-381 G1 and G2 multi exponentiation operations
@@ -197,4 +195,5 @@ var (
197195
// EIP-2935 - Serve historical block hashes from state
198196
HistoryStorageAddress = common.HexToAddress("0x0000F90827F1C53a10cb7A02335B175320002935")
199197
HistoryStorageCode = common.FromHex("3373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f35600143038111604257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611fff60014303065500")
198+
HistoryServeWindow = uint64(8191)
200199
)

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 8 // Minor version component of the current release
27-
VersionPatch = 63 // Patch version component of the current release
27+
VersionPatch = 64 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

0 commit comments

Comments
 (0)