Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/state: fix panic in state dumping #22225

Merged
merged 1 commit into from
Jan 26, 2021
Merged

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Jan 24, 2021

@winsvega reported a crash found via retesteth, introduced in commit #ddadc3d2 .

Repro:
alloc.json:

{
  "a94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
    "balance": "0x5ffd4878be161d74",
    "code": "0x",
    "nonce": "0xac",
    "storage": {
      "0x0a": "0x01"
    }
  },
  "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192":{
    "balance": "0xfeedbead",
    "nonce" : "0x00"
  }
}

WIthout this PR:

./evm t8n --input.alloc=./alloc.json --input.txs=./testdata/1/txs.json --input.env=./testdata/1/env.json --output.alloc=stdout
INFO [01-24|13:33:13.295] rejected tx                              index=1 hash="0557ba…18d673" from=0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192 error="nonce too low: address 0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192, tx: 0 state: 1"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x83167e]

goroutine 1 [running]:
github.com/ethereum/go-ethereum/core/state.(*stateObject).getTrie(0xc0001fe690, 0x1052be0, 0xc00021aa60, 0x0, 0x0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/state/state_object.go:162 +0x2fe
github.com/ethereum/go-ethereum/core/state.(*StateDB).DumpToCollector(0xc0003f1040, 0x1045340, 0xc00001b9b0, 0x0, 0x0, 0x0, 0x0, 0xffffffffffffffff, 0x0, 0x0, ...)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/state/dump.go:147 +0x745
github.com/ethereum/go-ethereum/cmd/evm/internal/t8ntool.Main(0xc00015e580, 0x0, 0x0)
	/home/user/go/src/github.com/ethereum/go-ethereum/cmd/evm/internal/t8ntool/transition.go:211 +0x1125
gopkg.in/urfave/cli%2ev1.HandleAction(0xda2c40, 0xf64d98, 0xc00015e580, 0xc0004a3700, 0x0)
	/home/user/go/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/app.go:490 +0x82
gopkg.in/urfave/cli%2ev1.Command.Run(0xefbcf4, 0xa, 0x0, 0x0, 0x1542e00, 0x1, 0x1, 0xf12b95, 0x20, 0x0, ...)
	/home/user/go/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/command.go:210 +0x9fb
gopkg.in/urfave/cli%2ev1.(*App).Run(0xc0003f0340, 0xc000138120, 0x6, 0x6, 0x0, 0x0)
	/home/user/go/pkg/mod/gopkg.in/urfave/cli.v1@v1.20.0/app.go:255 +0x768
main.main()
	/home/user/go/src/github.com/ethereum/go-ethereum/cmd/evm/main.go:200 +0x55

With this PR

 go build . && ./evm t8n --input.alloc=./alloc.json --input.txs=./testdata/1/txs.json --input.env=./testdata/1/env.json --output.alloc=stdout

INFO [01-24|13:31:54.160] rejected tx                              index=1 hash="0557ba…18d673" from=0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192 error="nonce too low: address 0x8A8eAFb1cf62BfBeb1741769DAE1a9dd47996192, tx: 0 state: 1"
{
 "alloc": {
  "0x8a8eafb1cf62bfbeb1741769dae1a9dd47996192": {
   "balance": "0xfeed1a9d",
   "nonce": "0x1"
  },
  "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
   "storage": {
    "0x000000000000000000000000000000000000000000000000000000000000000a": "0x0000000000000000000000000000000000000000000000000000000000000001"
   },
   "balance": "0x5ffd4878be161d74",
   "nonce": "0xac"
  },
  "0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
   "balance": "0xa410"
  }
 }
}

@holiman holiman added this to the 1.10.0 milestone Jan 24, 2021
Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants