From b5881383332b8dc00b7254a447b0bc5c5c377c5d Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Mon, 12 Apr 2021 17:50:15 -0700 Subject: [PATCH] geth: only accept txs with a 0 value --- integration-tests/test/rpc.spec.ts | 11 +++++++++++ l2geth/eth/api_backend.go | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/integration-tests/test/rpc.spec.ts b/integration-tests/test/rpc.spec.ts index 596c7d442ba83..1ba2d209512fc 100644 --- a/integration-tests/test/rpc.spec.ts +++ b/integration-tests/test/rpc.spec.ts @@ -51,6 +51,17 @@ describe('Basic RPC tests', () => { provider.sendTransaction(await wallet.signTransaction(tx)) ).to.be.rejectedWith('Cannot submit unprotected transaction') }) + + it('should not accept a transaction with a value', async () => { + const tx = { + ...DEFAULT_TRANSACTION, + chainId: (await wallet.getChainId()), + value: 100, + } + await expect( + provider.sendTransaction(await wallet.signTransaction(tx)) + ).to.be.rejectedWith('Cannot send transaction with non-zero value. Use WETH.transfer()') + }) }) describe('eth_getTransactionByHash', () => { diff --git a/l2geth/eth/api_backend.go b/l2geth/eth/api_backend.go index bd242e7274cfd..a0889ea433317 100644 --- a/l2geth/eth/api_backend.go +++ b/l2geth/eth/api_backend.go @@ -294,6 +294,11 @@ func (b *EthAPIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscri // a lock can be used around the remotes for when the sequencer is reorganizing. func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error { if b.UsingOVM { + // The value field is not rolled up so it must be set to 0 + if signedTx.Value().Cmp(new(big.Int)) != 0 { + return fmt.Errorf("Cannot send transaction with non-zero value. Use WETH.transfer()") + } + to := signedTx.To() if to != nil { if *to == (common.Address{}) {