diff --git a/executor/transaction_processor.go b/executor/transaction_processor.go index 7c2dd1a1f..db2a09f34 100644 --- a/executor/transaction_processor.go +++ b/executor/transaction_processor.go @@ -377,6 +377,7 @@ func prepareBlockCtx(inputEnv txcontext.BlockEnvironment, hashError *error) *vm. BlockNumber: new(big.Int).SetUint64(inputEnv.GetNumber()), Time: inputEnv.GetTimestamp(), Difficulty: inputEnv.GetDifficulty(), + Random: inputEnv.GetRandom(), GasLimit: inputEnv.GetGasLimit(), GetHash: getHash, } diff --git a/txcontext/substate/block_environment.go b/txcontext/substate/block_environment.go index 887b30656..2a900641a 100644 --- a/txcontext/substate/block_environment.go +++ b/txcontext/substate/block_environment.go @@ -34,7 +34,12 @@ type blockEnvironment struct { } func (e *blockEnvironment) GetRandom() *common.Hash { - return nil + if e.Random == nil { + return nil + } + + h := common.Hash(e.Random.Bytes()) + return &h } func (e *blockEnvironment) GetBlockHash(block uint64) (common.Hash, error) {