mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-11 21:04:11 +00:00
EIP 4399 changes: random -> prevRandao
This commit is contained in:
parent
f8ede9659e
commit
667cb6d750
7
nimbus/merge/eth_common_overload.nim
Normal file
7
nimbus/merge/eth_common_overload.nim
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import eth/common
|
||||||
|
|
||||||
|
template prevRandao*(h: BlockHeader | BlockHeaderRef): Hash256 =
|
||||||
|
h.mixDigest
|
||||||
|
|
||||||
|
template `prevRandao=`*(h: BlockHeader | BlockHeaderRef, hash: Hash256) =
|
||||||
|
h.mixDigest = hash
|
@ -41,7 +41,7 @@ proc calcRootHashRlp*(items: openArray[seq[byte]]): Hash256 =
|
|||||||
return tr.rootHash()
|
return tr.rootHash()
|
||||||
|
|
||||||
proc toBlockHeader(payload: ExecutionPayloadV1): eth_types.BlockHeader =
|
proc toBlockHeader(payload: ExecutionPayloadV1): eth_types.BlockHeader =
|
||||||
discard payload.random # TODO: What should this be used for?
|
discard payload.prevRandao # TODO: What should this be used for?
|
||||||
|
|
||||||
let transactions = seq[seq[byte]](payload.transactions)
|
let transactions = seq[seq[byte]](payload.transactions)
|
||||||
let txRoot = calcRootHashRlp(transactions)
|
let txRoot = calcRootHashRlp(transactions)
|
||||||
@ -84,7 +84,7 @@ proc setupEngineAPI*(
|
|||||||
return payloads[int payloadId]
|
return payloads[int payloadId]
|
||||||
|
|
||||||
# https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.5/src/engine/specification.md#engine_executepayloadv1
|
# https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.5/src/engine/specification.md#engine_executepayloadv1
|
||||||
server.rpc("engine_executePayloadV1") do(payload: ExecutionPayloadV1) -> ExecutePayloadResponse:
|
#[server.rpc("engine_executePayloadV1") do(payload: ExecutionPayloadV1) -> ExecutePayloadResponse:
|
||||||
# TODO
|
# TODO
|
||||||
if payload.transactions.len > 0:
|
if payload.transactions.len > 0:
|
||||||
# Give us a break, a block with transcations? instructions to execute?
|
# Give us a break, a block with transcations? instructions to execute?
|
||||||
@ -140,4 +140,4 @@ proc setupEngineAPI*(
|
|||||||
return ForkchoiceUpdatedResponse(status: ForkchoiceUpdatedStatus.success,
|
return ForkchoiceUpdatedResponse(status: ForkchoiceUpdatedStatus.success,
|
||||||
payloadId: some payloadId.toBytesBE.PayloadID)
|
payloadId: some payloadId.toBytesBE.PayloadID)
|
||||||
else:
|
else:
|
||||||
return ForkchoiceUpdatedResponse(status: ForkchoiceUpdatedStatus.success)
|
return ForkchoiceUpdatedResponse(status: ForkchoiceUpdatedStatus.success)]#
|
||||||
|
@ -250,7 +250,7 @@ proc generateExecutionPayload*(engine: SealingEngineRef,
|
|||||||
payloadRes.logsBloom = Web3Bloom blk.header.bloom
|
payloadRes.logsBloom = Web3Bloom blk.header.bloom
|
||||||
# TODO Check the extra data length here
|
# TODO Check the extra data length here
|
||||||
# payloadres.extraData = web3types.DynamicBytes[256] blk.header.extraData
|
# payloadres.extraData = web3types.DynamicBytes[256] blk.header.extraData
|
||||||
payloadRes.random = web3types.FixedBytes[32](payloadAttrs.random)
|
payloadRes.prevRandao = web3types.FixedBytes[32](payloadAttrs.prevRandao)
|
||||||
payloadRes.blockNumber = Web3Quantity blk.header.blockNumber.truncate(uint64)
|
payloadRes.blockNumber = Web3Quantity blk.header.blockNumber.truncate(uint64)
|
||||||
payloadRes.gasLimit = Web3Quantity blk.header.gasLimit
|
payloadRes.gasLimit = Web3Quantity blk.header.gasLimit
|
||||||
payloadRes.gasUsed = Web3Quantity blk.header.gasUsed
|
payloadRes.gasUsed = Web3Quantity blk.header.gasUsed
|
||||||
|
@ -68,7 +68,7 @@ type
|
|||||||
|
|
||||||
# EIP-4399 and EIP-3675
|
# EIP-4399 and EIP-3675
|
||||||
ttdReached: bool ## Total Terminal Difficulty reached
|
ttdReached: bool ## Total Terminal Difficulty reached
|
||||||
random: Hash256 ## POS block randomness
|
prevRandao: Hash256 ## POS block randomness
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Private functions
|
# Private functions
|
||||||
@ -83,7 +83,7 @@ proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; fee: Option[UInt256])
|
|||||||
timestamp = getTime().utc.toTime,
|
timestamp = getTime().utc.toTime,
|
||||||
gasLimit = (if dh.maxMode: dh.limits.maxLimit else: dh.limits.trgLimit),
|
gasLimit = (if dh.maxMode: dh.limits.maxLimit else: dh.limits.trgLimit),
|
||||||
fee = fee,
|
fee = fee,
|
||||||
random = dh.random,
|
prevRandao= dh.prevRandao,
|
||||||
miner = dh.miner,
|
miner = dh.miner,
|
||||||
chainDB = dh.db,
|
chainDB = dh.db,
|
||||||
ttdReached= dh.ttdReached)
|
ttdReached= dh.ttdReached)
|
||||||
@ -313,9 +313,9 @@ proc `ttdReached=`*(dh: TxChainRef; val: bool) =
|
|||||||
## Setter
|
## Setter
|
||||||
dh.ttdReached = val
|
dh.ttdReached = val
|
||||||
|
|
||||||
proc `random=`*(dh: TxChainRef; val: Hash256) =
|
proc `prevRandao=`*(dh: TxChainRef; val: Hash256) =
|
||||||
## Setter
|
## Setter
|
||||||
dh.random = val
|
dh.prevRandao = val
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# End
|
# End
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
import
|
import
|
||||||
./interpreter/opcode_values as vmo
|
./interpreter/opcode_values as vmo
|
||||||
export
|
export
|
||||||
vmo.Op, vmo.Random
|
vmo.Op, vmo.PrevRandao
|
||||||
|
|
||||||
|
|
||||||
# see vm_message
|
# see vm_message
|
||||||
|
@ -191,4 +191,4 @@ fill_enum_holes:
|
|||||||
|
|
||||||
const
|
const
|
||||||
# EIP-4399 new opcode
|
# EIP-4399 new opcode
|
||||||
Random* = Difficulty
|
PrevRandao* = Difficulty
|
||||||
|
@ -22,6 +22,10 @@ import
|
|||||||
./types,
|
./types,
|
||||||
eth/[common, keys]
|
eth/[common, keys]
|
||||||
|
|
||||||
|
# a temporary solution until nim-eth bumped
|
||||||
|
when not compiles(common.prevRandao):
|
||||||
|
import ../merge/eth_common_overload
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [Defect].}
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -59,7 +63,7 @@ proc init(
|
|||||||
timestamp: EthTime;
|
timestamp: EthTime;
|
||||||
gasLimit: GasInt;
|
gasLimit: GasInt;
|
||||||
fee: Option[Uint256];
|
fee: Option[Uint256];
|
||||||
random: Hash256;
|
prevRandao: Hash256;
|
||||||
miner: EthAddress;
|
miner: EthAddress;
|
||||||
chainDB: BaseChainDB;
|
chainDB: BaseChainDB;
|
||||||
ttdReached: bool;
|
ttdReached: bool;
|
||||||
@ -72,7 +76,7 @@ proc init(
|
|||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
self.gasLimit = gasLimit
|
self.gasLimit = gasLimit
|
||||||
self.fee = fee
|
self.fee = fee
|
||||||
self.random = random
|
self.prevRandao = prevRandao
|
||||||
self.chaindb = chainDB
|
self.chaindb = chainDB
|
||||||
self.ttdReached = ttdReached
|
self.ttdReached = ttdReached
|
||||||
self.tracer = tracer
|
self.tracer = tracer
|
||||||
@ -88,7 +92,7 @@ proc init(
|
|||||||
timestamp: EthTime;
|
timestamp: EthTime;
|
||||||
gasLimit: GasInt;
|
gasLimit: GasInt;
|
||||||
fee: Option[Uint256];
|
fee: Option[Uint256];
|
||||||
random: Hash256;
|
prevRandao: Hash256;
|
||||||
miner: EthAddress;
|
miner: EthAddress;
|
||||||
chainDB: BaseChainDB;
|
chainDB: BaseChainDB;
|
||||||
ttdReached: bool;
|
ttdReached: bool;
|
||||||
@ -102,7 +106,7 @@ proc init(
|
|||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
gasLimit = gasLimit,
|
gasLimit = gasLimit,
|
||||||
fee = fee,
|
fee = fee,
|
||||||
random = random,
|
prevRandao= prevRandao,
|
||||||
miner = miner,
|
miner = miner,
|
||||||
chainDB = chainDB,
|
chainDB = chainDB,
|
||||||
ttdReached= ttdReached,
|
ttdReached= ttdReached,
|
||||||
@ -125,7 +129,7 @@ proc new*(
|
|||||||
timestamp: EthTime; ## tx env: time stamp
|
timestamp: EthTime; ## tx env: time stamp
|
||||||
gasLimit: GasInt; ## tx env: gas limit
|
gasLimit: GasInt; ## tx env: gas limit
|
||||||
fee: Option[Uint256]; ## tx env: optional base fee
|
fee: Option[Uint256]; ## tx env: optional base fee
|
||||||
random: Hash256; ## tx env: POS block randomness
|
prevRandao: Hash256; ## tx env: POS block randomness
|
||||||
miner: EthAddress; ## tx env: coinbase(PoW) or signer(PoA)
|
miner: EthAddress; ## tx env: coinbase(PoW) or signer(PoA)
|
||||||
chainDB: BaseChainDB; ## block chain database
|
chainDB: BaseChainDB; ## block chain database
|
||||||
ttdReached: bool; ## total terminal difficulty reached
|
ttdReached: bool; ## total terminal difficulty reached
|
||||||
@ -146,7 +150,7 @@ proc new*(
|
|||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
gasLimit = gasLimit,
|
gasLimit = gasLimit,
|
||||||
fee = fee,
|
fee = fee,
|
||||||
random = random,
|
prevRandao = prevRandao,
|
||||||
miner = miner,
|
miner = miner,
|
||||||
chainDB = chainDB,
|
chainDB = chainDB,
|
||||||
ttdReached = ttdReached,
|
ttdReached = ttdReached,
|
||||||
@ -157,7 +161,7 @@ proc reinit*(self: BaseVMState; ## Object descriptor
|
|||||||
timestamp: EthTime; ## tx env: time stamp
|
timestamp: EthTime; ## tx env: time stamp
|
||||||
gasLimit: GasInt; ## tx env: gas limit
|
gasLimit: GasInt; ## tx env: gas limit
|
||||||
fee: Option[Uint256]; ## tx env: optional base fee
|
fee: Option[Uint256]; ## tx env: optional base fee
|
||||||
random: Hash256; ## tx env: POS block randomness
|
prevRandao:Hash256; ## tx env: POS block randomness
|
||||||
miner: EthAddress; ## tx env: coinbase(PoW) or signer(PoA)
|
miner: EthAddress; ## tx env: coinbase(PoW) or signer(PoA)
|
||||||
ttdReached:bool; ## total terminal difficulty reached
|
ttdReached:bool; ## total terminal difficulty reached
|
||||||
pruneTrie: bool = true): bool
|
pruneTrie: bool = true): bool
|
||||||
@ -183,7 +187,7 @@ proc reinit*(self: BaseVMState; ## Object descriptor
|
|||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
gasLimit = gasLimit,
|
gasLimit = gasLimit,
|
||||||
fee = fee,
|
fee = fee,
|
||||||
random = random,
|
prevRandao = prevRandao,
|
||||||
miner = miner,
|
miner = miner,
|
||||||
chainDB = db,
|
chainDB = db,
|
||||||
ttdReached = ttdReached,
|
ttdReached = ttdReached,
|
||||||
@ -214,7 +218,7 @@ proc reinit*(self: BaseVMState; ## Object descriptor
|
|||||||
timestamp = header.timestamp,
|
timestamp = header.timestamp,
|
||||||
gasLimit = header.gasLimit,
|
gasLimit = header.gasLimit,
|
||||||
fee = header.fee,
|
fee = header.fee,
|
||||||
random = header.random,
|
prevRandao= header.prevRandao,
|
||||||
miner = self.chainDB.getMinerAddress(header),
|
miner = self.chainDB.getMinerAddress(header),
|
||||||
ttdReached= ttdReached,
|
ttdReached= ttdReached,
|
||||||
pruneTrie = pruneTrie)
|
pruneTrie = pruneTrie)
|
||||||
@ -253,7 +257,7 @@ proc init*(
|
|||||||
header.timestamp,
|
header.timestamp,
|
||||||
header.gasLimit,
|
header.gasLimit,
|
||||||
header.fee,
|
header.fee,
|
||||||
header.random,
|
header.prevRandao,
|
||||||
chainDB.getMinerAddress(header),
|
chainDB.getMinerAddress(header),
|
||||||
chainDB,
|
chainDB,
|
||||||
ttdReached,
|
ttdReached,
|
||||||
@ -328,7 +332,7 @@ method blockNumber*(vmState: BaseVMState): BlockNumber {.base, gcsafe.} =
|
|||||||
method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
|
method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
|
||||||
if vmState.ttdReached:
|
if vmState.ttdReached:
|
||||||
# EIP-4399/EIP-3675
|
# EIP-4399/EIP-3675
|
||||||
UInt256.fromBytesBE(vmState.random.data, allowPadding = false)
|
UInt256.fromBytesBE(vmState.prevRandao.data, allowPadding = false)
|
||||||
else:
|
else:
|
||||||
vmState.chainDB.config.calcDifficulty(vmState.timestamp, vmState.parent)
|
vmState.chainDB.config.calcDifficulty(vmState.timestamp, vmState.parent)
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ type
|
|||||||
timestamp* : EthTime
|
timestamp* : EthTime
|
||||||
gasLimit* : GasInt
|
gasLimit* : GasInt
|
||||||
fee* : Option[Uint256]
|
fee* : Option[Uint256]
|
||||||
random* : Hash256
|
prevRandao* : Hash256
|
||||||
ttdReached* : bool
|
ttdReached* : bool
|
||||||
name* : string
|
name* : string
|
||||||
flags* : set[VMFlag]
|
flags* : set[VMFlag]
|
||||||
|
@ -211,7 +211,7 @@ type
|
|||||||
|
|
||||||
const
|
const
|
||||||
# EIP-4399 new opcode
|
# EIP-4399 new opcode
|
||||||
Random* = Difficulty
|
PrevRandao* = Difficulty
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Verify that Op is contiguous and sym names follow some standards
|
# Verify that Op is contiguous and sym names follow some standards
|
||||||
|
@ -21,6 +21,10 @@ import
|
|||||||
./types,
|
./types,
|
||||||
eth/[common, keys]
|
eth/[common, keys]
|
||||||
|
|
||||||
|
# a temporary solution until nim-eth bumped
|
||||||
|
when not compiles(common.prevRandao):
|
||||||
|
import ../merge/eth_common_overload
|
||||||
|
|
||||||
{.push raises: [Defect].}
|
{.push raises: [Defect].}
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -58,7 +62,7 @@ proc init(
|
|||||||
timestamp: EthTime;
|
timestamp: EthTime;
|
||||||
gasLimit: GasInt;
|
gasLimit: GasInt;
|
||||||
fee: Option[Uint256];
|
fee: Option[Uint256];
|
||||||
random: Hash256;
|
prevRandao: Hash256;
|
||||||
miner: EthAddress;
|
miner: EthAddress;
|
||||||
chainDB: BaseChainDB;
|
chainDB: BaseChainDB;
|
||||||
ttdReached: bool;
|
ttdReached: bool;
|
||||||
@ -71,7 +75,7 @@ proc init(
|
|||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
self.gasLimit = gasLimit
|
self.gasLimit = gasLimit
|
||||||
self.fee = fee
|
self.fee = fee
|
||||||
self.random = random
|
self.prevRandao = prevRandao
|
||||||
self.chaindb = chainDB
|
self.chaindb = chainDB
|
||||||
self.ttdReached = ttdReached
|
self.ttdReached = ttdReached
|
||||||
self.tracer = tracer
|
self.tracer = tracer
|
||||||
@ -87,7 +91,7 @@ proc init(
|
|||||||
timestamp: EthTime;
|
timestamp: EthTime;
|
||||||
gasLimit: GasInt;
|
gasLimit: GasInt;
|
||||||
fee: Option[Uint256];
|
fee: Option[Uint256];
|
||||||
random: Hash256;
|
prevRandao: Hash256;
|
||||||
miner: EthAddress;
|
miner: EthAddress;
|
||||||
chainDB: BaseChainDB;
|
chainDB: BaseChainDB;
|
||||||
ttdReached: bool;
|
ttdReached: bool;
|
||||||
@ -101,7 +105,7 @@ proc init(
|
|||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
gasLimit = gasLimit,
|
gasLimit = gasLimit,
|
||||||
fee = fee,
|
fee = fee,
|
||||||
random = random,
|
prevRandao= prevRandao,
|
||||||
miner = miner,
|
miner = miner,
|
||||||
chainDB = chainDB,
|
chainDB = chainDB,
|
||||||
ttdReached= ttdReached,
|
ttdReached= ttdReached,
|
||||||
@ -124,7 +128,7 @@ proc new*(
|
|||||||
timestamp: EthTime; ## tx env: time stamp
|
timestamp: EthTime; ## tx env: time stamp
|
||||||
gasLimit: GasInt; ## tx env: gas limit
|
gasLimit: GasInt; ## tx env: gas limit
|
||||||
fee: Option[Uint256]; ## tx env: optional base fee
|
fee: Option[Uint256]; ## tx env: optional base fee
|
||||||
random: Hash256; ## tx env: POS block randomness
|
prevRandao: Hash256; ## tx env: POS block randomness
|
||||||
miner: EthAddress; ## tx env: coinbase(PoW) or signer(PoA)
|
miner: EthAddress; ## tx env: coinbase(PoW) or signer(PoA)
|
||||||
chainDB: BaseChainDB; ## block chain database
|
chainDB: BaseChainDB; ## block chain database
|
||||||
ttdReached: bool; ## total terminal difficulty reached
|
ttdReached: bool; ## total terminal difficulty reached
|
||||||
@ -145,7 +149,7 @@ proc new*(
|
|||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
gasLimit = gasLimit,
|
gasLimit = gasLimit,
|
||||||
fee = fee,
|
fee = fee,
|
||||||
random = random,
|
prevRandao = prevRandao,
|
||||||
miner = miner,
|
miner = miner,
|
||||||
chainDB = chainDB,
|
chainDB = chainDB,
|
||||||
ttdReached = ttdReached,
|
ttdReached = ttdReached,
|
||||||
@ -156,7 +160,7 @@ proc reinit*(self: BaseVMState; ## Object descriptor
|
|||||||
timestamp: EthTime; ## tx env: time stamp
|
timestamp: EthTime; ## tx env: time stamp
|
||||||
gasLimit: GasInt; ## tx env: gas limit
|
gasLimit: GasInt; ## tx env: gas limit
|
||||||
fee: Option[Uint256]; ## tx env: optional base fee
|
fee: Option[Uint256]; ## tx env: optional base fee
|
||||||
random: Hash256; ## tx env: POS block randomness
|
prevRandao:Hash256; ## tx env: POS block randomness
|
||||||
miner: EthAddress; ## tx env: coinbase(PoW) or signer(PoA)
|
miner: EthAddress; ## tx env: coinbase(PoW) or signer(PoA)
|
||||||
ttdReached:bool; ## total terminal difficulty reached
|
ttdReached:bool; ## total terminal difficulty reached
|
||||||
pruneTrie: bool = true): bool
|
pruneTrie: bool = true): bool
|
||||||
@ -182,7 +186,7 @@ proc reinit*(self: BaseVMState; ## Object descriptor
|
|||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
gasLimit = gasLimit,
|
gasLimit = gasLimit,
|
||||||
fee = fee,
|
fee = fee,
|
||||||
random = random,
|
prevRandao = prevRandao,
|
||||||
miner = miner,
|
miner = miner,
|
||||||
chainDB = db,
|
chainDB = db,
|
||||||
ttdReached = ttdReached,
|
ttdReached = ttdReached,
|
||||||
@ -213,7 +217,7 @@ proc reinit*(self: BaseVMState; ## Object descriptor
|
|||||||
timestamp = header.timestamp,
|
timestamp = header.timestamp,
|
||||||
gasLimit = header.gasLimit,
|
gasLimit = header.gasLimit,
|
||||||
fee = header.fee,
|
fee = header.fee,
|
||||||
random = header.random,
|
prevRandao= header.prevRandao,
|
||||||
miner = self.chainDB.getMinerAddress(header),
|
miner = self.chainDB.getMinerAddress(header),
|
||||||
ttdReached= ttdReached,
|
ttdReached= ttdReached,
|
||||||
pruneTrie = pruneTrie)
|
pruneTrie = pruneTrie)
|
||||||
@ -252,7 +256,7 @@ proc init*(
|
|||||||
header.timestamp,
|
header.timestamp,
|
||||||
header.gasLimit,
|
header.gasLimit,
|
||||||
header.fee,
|
header.fee,
|
||||||
header.random,
|
header.prevRandao,
|
||||||
chainDB.getMinerAddress(header),
|
chainDB.getMinerAddress(header),
|
||||||
chainDB,
|
chainDB,
|
||||||
ttdReached,
|
ttdReached,
|
||||||
@ -315,7 +319,7 @@ method blockNumber*(vmState: BaseVMState): BlockNumber {.base, gcsafe.} =
|
|||||||
method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
|
method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
|
||||||
if vmState.ttdReached:
|
if vmState.ttdReached:
|
||||||
# EIP-4399/EIP-3675
|
# EIP-4399/EIP-3675
|
||||||
UInt256.fromBytesBE(vmState.random.data, allowPadding = false)
|
UInt256.fromBytesBE(vmState.prevRandao.data, allowPadding = false)
|
||||||
else:
|
else:
|
||||||
vmState.chainDB.config.calcDifficulty(vmState.timestamp, vmState.parent)
|
vmState.chainDB.config.calcDifficulty(vmState.timestamp, vmState.parent)
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ type
|
|||||||
timestamp* : EthTime
|
timestamp* : EthTime
|
||||||
gasLimit* : GasInt
|
gasLimit* : GasInt
|
||||||
fee* : Option[Uint256]
|
fee* : Option[Uint256]
|
||||||
random* : Hash256
|
prevRandao* : Hash256
|
||||||
ttdReached* : bool
|
ttdReached* : bool
|
||||||
name* : string
|
name* : string
|
||||||
flags* : set[VMFlag]
|
flags* : set[VMFlag]
|
||||||
|
@ -133,7 +133,7 @@ else:
|
|||||||
eGmt.refundGas,
|
eGmt.refundGas,
|
||||||
eGmt.returnGas,
|
eGmt.returnGas,
|
||||||
fVmo.Op,
|
fVmo.Op,
|
||||||
fVmo.Random,
|
fVmo.PrevRandao,
|
||||||
gVmg.isCreate,
|
gVmg.isCreate,
|
||||||
hStk.Stack,
|
hStk.Stack,
|
||||||
hStk.`$`,
|
hStk.`$`,
|
||||||
|
@ -46,10 +46,10 @@ const
|
|||||||
static:
|
static:
|
||||||
for n in Op:
|
for n in Op:
|
||||||
idToOpcode[$n] = newLit(ord(n))
|
idToOpcode[$n] = newLit(ord(n))
|
||||||
|
|
||||||
# EIP-4399 new opcode
|
# EIP-4399 new opcode
|
||||||
idToOpcode["Random"] = newLit(ord(Difficulty))
|
idToOpcode["PrevRandao"] = newLit(ord(Difficulty))
|
||||||
|
|
||||||
proc validateVMWord(val: string, n: NimNode): VMWord =
|
proc validateVMWord(val: string, n: NimNode): VMWord =
|
||||||
if val.len <= 2 or val.len > 66: error("invalid hex string", n)
|
if val.len <= 2 or val.len > 66: error("invalid hex string", n)
|
||||||
if not (val[0] == '0' and val[1] == 'x'): error("invalid hex string", n)
|
if not (val[0] == '0' and val[1] == 'x'): error("invalid hex string", n)
|
||||||
|
@ -326,19 +326,19 @@ proc opEnvMain*() =
|
|||||||
|
|
||||||
vmState.ttdReached = true
|
vmState.ttdReached = true
|
||||||
assembler:
|
assembler:
|
||||||
title: "EIP-4399 RANDOM 0"
|
title: "EIP-4399 PrevRandao 0"
|
||||||
code:
|
code:
|
||||||
Random
|
PrevRandao
|
||||||
STOP
|
STOP
|
||||||
stack:
|
stack:
|
||||||
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
fork: london
|
fork: london
|
||||||
|
|
||||||
vmState.random = EMPTY_UNCLE_HASH
|
vmState.prevRandao = EMPTY_UNCLE_HASH
|
||||||
assembler:
|
assembler:
|
||||||
title: "EIP-4399 RANDOM: EMPTY_UNCLE_HASH"
|
title: "EIP-4399 PrevRandao: EMPTY_UNCLE_HASH"
|
||||||
code:
|
code:
|
||||||
Random
|
PrevRandao
|
||||||
STOP
|
STOP
|
||||||
stack:
|
stack:
|
||||||
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
|
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user