checking txn chain id before adding it to the tx pool (#4855)

This commit is contained in:
Enrique Jose Avila Asapche 2022-07-29 04:26:15 +03:00 committed by GitHub
parent 59bcbb4f33
commit 8b1574127a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,6 +26,13 @@ func (api *APIImpl) SendRawTransaction(ctx context.Context, encodedTx hexutil.By
return common.Hash{}, err
}
txnChainId := txn.GetChainID()
chainId := api._chainConfig.ChainID
if chainId.Cmp(txnChainId.ToBig()) != 0 {
return common.Hash{}, fmt.Errorf("invalid chain id, expected: %d got: %d", chainId, *txnChainId)
}
// If the transaction fee cap is already specified, ensure the
// fee of the given transaction is _reasonable_.
if err := checkTxFee(txn.GetPrice().ToBig(), txn.GetGas(), ethconfig.Defaults.RPCTxFeeCap); err != nil {