Skip to content

Commit ed13073

Browse files
holimanzzyalbert
authored andcommitted
cmd/evm: handle rlp errors in t9n (ethereum#23771)
* cmd/evm: handle rlp errors in t9n * cmd/evm/testdata: fix readme
1 parent a7d4318 commit ed13073

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

cmd/evm/internal/t8ntool/transaction.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ func Transaction(ctx *cli.Context) error {
121121
}
122122
var results []result
123123
for it.Next() {
124+
if err := it.Err(); err != nil {
125+
return NewError(ErrorIO, err)
126+
}
124127
var tx types.Transaction
125128
err := rlp.DecodeBytes(it.Value(), &tx)
126129
if err != nil {

cmd/evm/t8n_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010

1111
"github.com/docker/docker/pkg/reexec"
12+
"github.com/ethereum/go-ethereum/cmd/evm/internal/t8ntool"
1213
"github.com/ethereum/go-ethereum/internal/cmdtest"
1314
)
1415

@@ -265,6 +266,14 @@ func TestT9n(t *testing.T) {
265266
},
266267
expOut: "exp.json",
267268
},
269+
{ // Invalid RLP
270+
base: "./testdata/18",
271+
input: t9nInput{
272+
inTxs: "invalid.rlp",
273+
stFork: "London",
274+
},
275+
expExitCode: t8ntool.ErrorIO,
276+
},
268277
} {
269278

270279
args := []string{"t9n"}

cmd/evm/testdata/18/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Invalid rlp
2+
3+
This folder contains a sample of invalid RLP, and it's expected
4+
that the t9n handles this properly:
5+
6+
```
7+
$ go run . t9n --input.txs=./testdata/18/invalid.rlp --state.fork=London
8+
ERROR(11): rlp: value size exceeds available input length
9+
```

cmd/evm/testdata/18/invalid.rlp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"0xf852328001825208870b9331677e6ebf0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa03887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"

0 commit comments

Comments
 (0)