Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
fix: add random field to BlockContext using block header hash
Browse files Browse the repository at this point in the history
  • Loading branch information
austinchandra committed Nov 30, 2022
1 parent 7f8b51e commit 9fbe153
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 9fbe153

Please sign in to comment.