diff --git a/.changeset/thirty-radios-sniff.md b/.changeset/thirty-radios-sniff.md new file mode 100644 index 0000000000000..3340bc37e2366 --- /dev/null +++ b/.changeset/thirty-radios-sniff.md @@ -0,0 +1,5 @@ +--- +"@eth-optimism/l2geth": patch +--- + +Prevent 0 value transactions with calldata via RPC diff --git a/l2geth/eth/api_backend.go b/l2geth/eth/api_backend.go index 06c495eab004f..45b63575df8e7 100644 --- a/l2geth/eth/api_backend.go +++ b/l2geth/eth/api_backend.go @@ -320,6 +320,14 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) if len(signedTx.Data()) > b.MaxCallDataSize { return fmt.Errorf("Calldata cannot be larger than %d, sent %d", b.MaxCallDataSize, len(signedTx.Data())) } + // If there is a value field set then reject transactions that + // contain calldata. The feature of sending transactions with value + // and calldata will be added in the future. + if signedTx.Value().Cmp(common.Big0) != 0 { + if len(signedTx.Data()) > 0 { + return errors.New("Cannot send transactions with value and calldata") + } + } } return b.eth.syncService.ApplyTransaction(signedTx) } diff --git a/l2geth/internal/ethapi/api.go b/l2geth/internal/ethapi/api.go index 4727489598cdd..da00c20acd505 100644 --- a/l2geth/internal/ethapi/api.go +++ b/l2geth/internal/ethapi/api.go @@ -1748,10 +1748,6 @@ func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encod if err := rlp.DecodeBytes(encodedTx, tx); err != nil { return common.Hash{}, err } - - if new(big.Int).Mod(tx.GasPrice(), big.NewInt(1000000)).Cmp(big.NewInt(0)) != 0 { - return common.Hash{}, errors.New("Gas price must be a multiple of 1,000,000 wei") - } // L1Timestamp and L1BlockNumber will be set right before execution txMeta := types.NewTransactionMeta(nil, 0, nil, types.SighashEIP155, types.QueueOriginSequencer, nil, nil, encodedTx) tx.SetTransactionMeta(txMeta)