aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm/block.go
diff options
context:
space:
mode:
authorAaron Buchwald <[email protected]>2020-12-17 13:58:14 -0500
committerAaron Buchwald <[email protected]>2020-12-17 13:58:14 -0500
commit3960b690bf8c67afe706bb469b0ff2798424a26e (patch)
tree77b60c080f63df21af115406e6b78a7862a68ad9 /plugin/evm/block.go
parentea099f5811574d3dae79a31053d21b523d008d75 (diff)
Decrease minimum gas price at apricot upgrade
Diffstat (limited to 'plugin/evm/block.go')
-rw-r--r--plugin/evm/block.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/plugin/evm/block.go b/plugin/evm/block.go
index 5a0d377..08ef231 100644
--- a/plugin/evm/block.go
+++ b/plugin/evm/block.go
@@ -6,9 +6,9 @@ package evm
import (
"errors"
"fmt"
+ "math/big"
"github.com/ava-labs/coreth/core/types"
- "github.com/ava-labs/coreth/params"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
@@ -85,9 +85,11 @@ func (b *Block) Verify() error {
// Only enforce a minimum fee when bootstrapping has finished
if b.vm.ctx.IsBootstrapped() {
// Ensure the minimum gas price is paid for every transaction
+ timestamp := b.ethBlock.Header().Time
+ minGasPrice := b.vm.minGasPrice.GetMin(new(big.Int).SetUint64(timestamp))
for _, tx := range b.ethBlock.Transactions() {
- if tx.GasPrice().Cmp(params.MinGasPrice) < 0 {
- return errInvalidBlock
+ if tx.GasPrice().Cmp(minGasPrice) < 0 {
+ return fmt.Errorf("block contains tx %s with gas price too low (%d < %d), timestamp: %d", tx.Hash(), tx.GasPrice(), minGasPrice, timestamp)
}
}
}
@@ -139,17 +141,21 @@ func (b *Block) Verify() error {
}
utx := tx.UnsignedTx.(UnsignedAtomicTx)
- if utx.SemanticVerify(vm, tx) != nil {
- return errInvalidBlock
+ if err := utx.SemanticVerify(vm, tx); err != nil {
+ return fmt.Errorf("block atomic tx failed verification due to: %w", err)
}
bc := vm.chain.BlockChain()
_, _, _, err = bc.Processor().Process(b.ethBlock, pState, *bc.GetVMConfig())
if err != nil {
- return errInvalidBlock
+ return fmt.Errorf("block failed processing due to: %w", err)
}
}
_, err := b.vm.chain.InsertChain([]*types.Block{b.ethBlock})
- return err
+ if err != nil {
+ return fmt.Errorf("failed to insert block into chain due to: %w", err)
+ }
+
+ return nil
}
// Bytes implements the snowman.Block interface