From 9fbe153bc4144784da0f2d3bdc04c9d70323822e Mon Sep 17 00:00:00 2001 From: Austin Chandra Date: Wed, 30 Nov 2022 11:37:42 -0800 Subject: [PATCH] fix: add random field to BlockContext using block header hash --- x/evm/keeper/state_transition.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 3103a45cad..dec2384819 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -79,6 +79,9 @@ func (k *Keeper) NewEVM( tracer vm.EVMLogger, stateDB vm.StateDB, ) evm.EVM { + // Use BlockHash for random field + random := common.BytesToHash(ctx.HeaderHash()) + blockCtx := vm.BlockContext{ CanTransfer: core.CanTransfer, Transfer: core.Transfer, @@ -89,6 +92,7 @@ func (k *Keeper) NewEVM( Time: big.NewInt(ctx.BlockHeader().Time.Unix()), Difficulty: big.NewInt(0), // unused. Only required in PoW context BaseFee: cfg.BaseFee, + Random: &random, } txCtx := core.NewEVMTxContext(msg)