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

Commit

Permalink
Add random opcode using consensus hash
Browse files Browse the repository at this point in the history
  • Loading branch information
austinchandra committed Nov 30, 2022
1 parent 7f8b51e commit 59beaf5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,21 @@ func (k *Keeper) NewEVM(
tracer vm.EVMLogger,
stateDB vm.StateDB,
) evm.EVM {
header := ctx.BlockHeader()
// Use EvidenceHash (parallel to MixDigest on Ethereum block)
random := common.BytesToHash(header.EvidenceHash)

blockCtx := vm.BlockContext{
CanTransfer: core.CanTransfer,
Transfer: core.Transfer,
GetHash: k.GetHashFn(ctx),
Coinbase: cfg.CoinBase,
GasLimit: ethermint.BlockGasLimit(ctx),
BlockNumber: big.NewInt(ctx.BlockHeight()),
Time: big.NewInt(ctx.BlockHeader().Time.Unix()),
Time: big.NewInt(header.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 59beaf5

Please sign in to comment.