Skip to content

Commit

Permalink
Merge pull request #99 from uprendis/feature/txpool-hash-check
Browse files Browse the repository at this point in the history
Txpool hash check
  • Loading branch information
uprendis authored May 1, 2021
2 parents 0817dd0 + f073a39 commit 3ed4005
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions evmcore/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ type stateReader interface {
MaxGasLimit() uint64

SubscribeNewBlock(ch chan<- ChainHeadNotify) notify.Subscription

TxExists(common.Hash) bool
}

// TxPoolConfig are the configuration parameters of the transaction pool.
Expand Down Expand Up @@ -567,6 +569,9 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if pool.chain.MinGasPrice().Cmp(tx.GasPrice()) > 0 {
return ErrUnderpriced
}
if pool.chain.TxExists(tx.Hash()) {
return ErrUnderpriced
}
// Ensure the transaction adheres to nonce ordering
if pool.currentState.GetNonce(from) > tx.Nonce() {
return ErrNonceTooLow
Expand Down
4 changes: 4 additions & 0 deletions evmcore/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ func (bc *testBlockChain) MaxGasLimit() uint64 {
return bc.CurrentBlock().GasLimit
}

func (bc *testBlockChain) TxExists(common.Hash) bool {
return false
}

func (bc *testBlockChain) CurrentBlock() *EvmBlock {
b := &EvmBlock{}
b.Number = big.NewInt(0)
Expand Down
4 changes: 4 additions & 0 deletions gossip/evm_state_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,7 @@ func (r *EvmStateReader) getBlock(h hash.Event, n idx.Block, readTxs bool) *evmc
func (r *EvmStateReader) StateAt(root common.Hash) (*state.StateDB, error) {
return r.store.evm.StateDB(hash.Hash(root))
}

func (r *EvmStateReader) TxExists(txid common.Hash) bool {
return r.store.EvmStore().GetTxPosition(txid) != nil
}
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func init() {
params.VersionMajor = 1 // Major version component of the current release
params.VersionMinor = 0 // Minor version component of the current release
params.VersionPatch = 0 // Patch version component of the current release
params.VersionMeta = "rc.1" // Version metadata to append to the version string
params.VersionMeta = "rc.2" // Version metadata to append to the version string
}

func BigToString(b *big.Int) string {
Expand Down

0 comments on commit 3ed4005

Please sign in to comment.