diff options
author | Martin Holst Swende <martin@swende.se> | 2018-03-19 15:29:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-19 15:29:54 +0800 |
commit | faed47b3c56017922a9709e57ca2795af5a535a9 (patch) | |
tree | c975560c39f4d50a47ac513517e6d8815cbcb128 /core | |
parent | fe6cf00f480aa6347b8d55079cbe6c473482ea27 (diff) | |
parent | c1d70ea97082145f5ba04cf4feb9792136b51507 (diff) | |
download | go-tangerine-faed47b3c56017922a9709e57ca2795af5a535a9.tar.gz go-tangerine-faed47b3c56017922a9709e57ca2795af5a535a9.tar.zst go-tangerine-faed47b3c56017922a9709e57ca2795af5a535a9.zip |
Merge pull request #15990 from markya0616/sim_backend_block_hash
accounts/abi, core: add AddTxWithChain in BlockGen for simulation
Diffstat (limited to 'core')
-rw-r--r-- | core/chain_makers.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/core/chain_makers.go b/core/chain_makers.go index 6744428ff..31c9e3fb7 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -82,11 +82,23 @@ func (b *BlockGen) SetExtra(data []byte) { // added. Notably, contract code relying on the BLOCKHASH instruction // will panic during execution. func (b *BlockGen) AddTx(tx *types.Transaction) { + b.AddTxWithChain(nil, tx) +} + +// AddTxWithChain adds a transaction to the generated block. If no coinbase has +// been set, the block's coinbase is set to the zero address. +// +// AddTxWithChain panics if the transaction cannot be executed. In addition to +// the protocol-imposed limitations (gas limit, etc.), there are some +// further limitations on the content of transactions that can be +// added. If contract code relies on the BLOCKHASH instruction, +// the block in chain will be returned. +func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction) { if b.gasPool == nil { b.SetCoinbase(common.Address{}) } b.statedb.Prepare(tx.Hash(), common.Hash{}, len(b.txs)) - receipt, _, err := ApplyTransaction(b.config, nil, &b.header.Coinbase, b.gasPool, b.statedb, b.header, tx, &b.header.GasUsed, vm.Config{}) + receipt, _, err := ApplyTransaction(b.config, bc, &b.header.Coinbase, b.gasPool, b.statedb, b.header, tx, &b.header.GasUsed, vm.Config{}) if err != nil { panic(err) } |