Skip to content

Commit

Permalink
cmd/evm: handle rlp errors in t9n (ethereum#23771)
Browse files Browse the repository at this point in the history
* cmd/evm: handle rlp errors in t9n

* cmd/evm/testdata: fix readme
  • Loading branch information
holiman authored and jagdeep sidhu committed Oct 27, 2021
1 parent 27334de commit b937525
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/evm/internal/t8ntool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ func Transaction(ctx *cli.Context) error {
}
var results []result
for it.Next() {
if err := it.Err(); err != nil {
return NewError(ErrorIO, err)
}
var tx types.Transaction
err := rlp.DecodeBytes(it.Value(), &tx)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions cmd/evm/t8n_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/docker/docker/pkg/reexec"
"github.com/ethereum/go-ethereum/cmd/evm/internal/t8ntool"
"github.com/ethereum/go-ethereum/internal/cmdtest"
)

Expand Down Expand Up @@ -265,6 +266,14 @@ func TestT9n(t *testing.T) {
},
expOut: "exp.json",
},
{ // Invalid RLP
base: "./testdata/18",
input: t9nInput{
inTxs: "invalid.rlp",
stFork: "London",
},
expExitCode: t8ntool.ErrorIO,
},
} {

args := []string{"t9n"}
Expand Down
9 changes: 9 additions & 0 deletions cmd/evm/testdata/18/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Invalid rlp

This folder contains a sample of invalid RLP, and it's expected
that the t9n handles this properly:

```
$ go run . t9n --input.txs=./testdata/18/invalid.rlp --state.fork=London
ERROR(11): rlp: value size exceeds available input length
```
1 change: 1 addition & 0 deletions cmd/evm/testdata/18/invalid.rlp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"0xf852328001825208870b9331677e6ebf0a801ca098ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4aa03887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"

0 comments on commit b937525

Please sign in to comment.