|
|
|
@ -56,7 +56,7 @@ func NewStateProcessor(config *params.ChainConfig, bc *BlockChain, engine consen |
|
|
|
|
// Process returns the receipts and logs accumulated during the process and
|
|
|
|
|
// returns the amount of gas that was used in the process. If any of the
|
|
|
|
|
// transactions failed to execute due to insufficient gas it will return an error.
|
|
|
|
|
func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, *types.AccessWitness, uint64, error) { |
|
|
|
|
func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, uint64, error) { |
|
|
|
|
var ( |
|
|
|
|
receipts types.Receipts |
|
|
|
|
usedGas = new(uint64) |
|
|
|
@ -65,7 +65,6 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg |
|
|
|
|
blockNumber = block.Number() |
|
|
|
|
allLogs []*types.Log |
|
|
|
|
gp = new(GasPool).AddGas(block.GasLimit()) |
|
|
|
|
accesses = types.NewAccessWitness() |
|
|
|
|
) |
|
|
|
|
// Mutate the block and state according to any hard-fork specs
|
|
|
|
|
if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 { |
|
|
|
@ -77,12 +76,12 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg |
|
|
|
|
for i, tx := range block.Transactions() { |
|
|
|
|
msg, err := tx.AsMessage(types.MakeSigner(p.config, header.Number), header.BaseFee) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, nil, accesses, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) |
|
|
|
|
return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) |
|
|
|
|
} |
|
|
|
|
statedb.Prepare(tx.Hash(), i) |
|
|
|
|
receipt, err := applyTransaction(msg, p.config, p.bc, nil, gp, statedb, blockNumber, blockHash, tx, usedGas, vmenv) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, nil, accesses, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) |
|
|
|
|
return nil, nil, 0, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) |
|
|
|
|
} |
|
|
|
|
receipts = append(receipts, receipt) |
|
|
|
|
allLogs = append(allLogs, receipt.Logs...) |
|
|
|
@ -90,7 +89,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg |
|
|
|
|
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
|
|
|
|
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles()) |
|
|
|
|
|
|
|
|
|
return receipts, allLogs, accesses, *usedGas, nil |
|
|
|
|
return receipts, allLogs, *usedGas, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, blockNumber *big.Int, blockHash common.Hash, tx *types.Transaction, usedGas *uint64, evm *vm.EVM) (*types.Receipt, error) { |
|
|
|
|