diff options
author | Felix Lange <fjl@twurst.com> | 2016-11-14 17:52:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-14 17:52:02 +0800 |
commit | ca73dea3b9bcdf3b5424b5c48c70817439e2e304 (patch) | |
tree | 670e2833878e72555644fbbd81db6c5a1b44493f /accounts/abi/bind/backends/simulated.go | |
parent | 21701190ac0a838e347f31b7a918bb0a60c1e8c1 (diff) | |
parent | 648bd22427000b6e20a5e1a9c397005aa1ad4f9b (diff) | |
download | go-tangerine-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar go-tangerine-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.gz go-tangerine-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.bz2 go-tangerine-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.lz go-tangerine-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.xz go-tangerine-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.tar.zst go-tangerine-ca73dea3b9bcdf3b5424b5c48c70817439e2e304.zip |
Merge pull request #3179 from obscuren/eip-158
EIP158 & 160 Hardfork
Diffstat (limited to 'accounts/abi/bind/backends/simulated.go')
-rw-r--r-- | accounts/abi/bind/backends/simulated.go | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index bdc2a98bc..00a8cd3e9 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -31,11 +31,12 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/params" "golang.org/x/net/context" ) // Default chain configuration which sets homestead phase at block 0 (i.e. no frontier) -var chainConfig = &core.ChainConfig{HomesteadBlock: big.NewInt(0)} +var chainConfig = ¶ms.ChainConfig{HomesteadBlock: big.NewInt(0), EIP150Block: new(big.Int), EIP158Block: new(big.Int)} // This nil assignment ensures compile time that SimulatedBackend implements bind.ContractBackend. var _ bind.ContractBackend = (*SimulatedBackend)(nil) @@ -51,6 +52,8 @@ type SimulatedBackend struct { mu sync.Mutex pendingBlock *types.Block // Currently pending block that will be imported on request pendingState *state.StateDB // Currently pending state that will be the active on on request + + config *params.ChainConfig } // NewSimulatedBackend creates a new binding backend using a simulated blockchain @@ -85,7 +88,7 @@ func (b *SimulatedBackend) Rollback() { } func (b *SimulatedBackend) rollback() { - blocks, _ := core.GenerateChain(nil, b.blockchain.CurrentBlock(), b.database, 1, func(int, *core.BlockGen) {}) + blocks, _ := core.GenerateChain(chainConfig, b.blockchain.CurrentBlock(), b.database, 1, func(int, *core.BlockGen) {}) b.pendingBlock = blocks[0] b.pendingState, _ = state.New(b.pendingBlock.Root(), b.database) } @@ -234,7 +237,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa b.mu.Lock() defer b.mu.Unlock() - sender, err := tx.From() + sender, err := types.Sender(types.HomesteadSigner{}, tx) if err != nil { panic(fmt.Errorf("invalid transaction: %v", err)) } @@ -243,7 +246,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa panic(fmt.Errorf("invalid transaction nonce: got %d, want %d", tx.Nonce(), nonce)) } - blocks, _ := core.GenerateChain(nil, b.blockchain.CurrentBlock(), b.database, 1, func(number int, block *core.BlockGen) { + blocks, _ := core.GenerateChain(chainConfig, b.blockchain.CurrentBlock(), b.database, 1, func(number int, block *core.BlockGen) { for _, tx := range b.pendingBlock.Transactions() { block.AddTx(tx) } @@ -259,12 +262,11 @@ type callmsg struct { ethereum.CallMsg } -func (m callmsg) From() (common.Address, error) { return m.CallMsg.From, nil } -func (m callmsg) FromFrontier() (common.Address, error) { return m.CallMsg.From, nil } -func (m callmsg) Nonce() uint64 { return 0 } -func (m callmsg) CheckNonce() bool { return false } -func (m callmsg) To() *common.Address { return m.CallMsg.To } -func (m callmsg) GasPrice() *big.Int { return m.CallMsg.GasPrice } -func (m callmsg) Gas() *big.Int { return m.CallMsg.Gas } -func (m callmsg) Value() *big.Int { return m.CallMsg.Value } -func (m callmsg) Data() []byte { return m.CallMsg.Data } +func (m callmsg) From() common.Address { return m.CallMsg.From } +func (m callmsg) Nonce() uint64 { return 0 } +func (m callmsg) CheckNonce() bool { return false } +func (m callmsg) To() *common.Address { return m.CallMsg.To } +func (m callmsg) GasPrice() *big.Int { return m.CallMsg.GasPrice } +func (m callmsg) Gas() *big.Int { return m.CallMsg.Gas } +func (m callmsg) Value() *big.Int { return m.CallMsg.Value } +func (m callmsg) Data() []byte { return m.CallMsg.Data } |