/
context.go
44 lines (38 loc) · 1.2 KB
/
context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package state
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"
)
var (
// CustomChainConfig accounts for the fact that EVM-Lite doesn't really have
// a concept of Chain, or Blocks (being consensus-agnostic). The EVM is
// tightly coupled with this ChainConfig object (cf interpreter.go), so this
// is a workaround that treats all blocks the same.
CustomChainConfig = params.ChainConfig{
ChainID: big.NewInt(1),
ConstantinopleBlock: big.NewInt(0),
}
)
// NewContext returns a custom Context suitable from evm-lite
func NewContext(origin common.Address,
coinbase common.Address,
gasLimit uint64,
gasPrice *big.Int) vm.Context {
context := vm.Context{
CanTransfer: core.CanTransfer,
Transfer: core.Transfer,
GetHash: func(uint64) common.Hash { return common.Hash{} },
// Message information
Origin: origin,
Coinbase: coinbase,
GasLimit: gasLimit,
GasPrice: gasPrice,
//The vm has a dependency on this
//Anything greate than ConstantinopleBlock will do here.
BlockNumber: CustomChainConfig.ConstantinopleBlock,
}
return context
}