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

Geth v.1.10.8 consensus issue test - filler wanted #935

Closed
holiman opened this issue Sep 1, 2021 · 3 comments · Fixed by #938
Closed

Geth v.1.10.8 consensus issue test - filler wanted #935

holiman opened this issue Sep 1, 2021 · 3 comments · Fixed by #938
Assignees

Comments

@holiman
Copy link
Contributor

holiman commented Sep 1, 2021

The consensus-issue which caused geth versions < 1.10.8 can be hit by this state-test

{
  "trigger-issue": {
    "env": {
      "currentCoinbase": "b94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "currentDifficulty": "0x20000",
      "currentGasLimit": "0x26e1f476fe1e22",
      "currentNumber": "0x1",
      "currentTimestamp": "0x3e8",
      "previousHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
    },
    "pre": {
      "0x00000000000000000000000000000000000000bb": {
        "code": "0x6001600053600260015360036002536004600353600560045360066005536006600260066000600060047f7ef0367e633852132a0ebbf70eb714015dd44bc82e1e55a96ef1389c999c1bcaf13d600060003e596000208055",
        "storage": {},
        "balance": "0x5",
        "nonce": "0x0"
      },
      "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
        "code": "0x",
        "storage": {},
        "balance": "0xffffffff",
        "nonce": "0x0"
      }
    },
    "transaction": {
      "gasPrice": "0x1",
      "nonce": "0x0",
      "to": "0x00000000000000000000000000000000000000bb",
      "data": [
        "0x"
      ],
      "gasLimit": [
        "0x7a1200"
      ],
      "value": [
        "0x01"
      ],
      "secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
    },
    "out": "0x",
    "post": {
      "Berlin": [
        {
          "hash": "2a38a040bab1e1fa499253d98b2fd363e5756ecc52db47dd59af7116c068368c",
          "logs": "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
          "indexes": {
            "data": 0,
            "gas": 0,
            "value": 0
          }
        }
      ]
    }
  }
}

Would be great if we can get this into the reference tests, also with more forks than 'Berlin'. @MariusVanDerWijden can provide more info about how this was generated, so we can make a filler for it.

@holiman holiman changed the title Test wanted Geth v.1.10.8 consensus issue tests - filler wanted Sep 1, 2021
@holiman holiman changed the title Geth v.1.10.8 consensus issue tests - filler wanted Geth v.1.10.8 consensus issue test - filler wanted Sep 1, 2021
@MariusVanDerWijden
Copy link
Member

That's the code I used to generate the state test in goevmlab

	bb.Mstore([]byte{1, 2, 3, 4, 5, 6, 7, 8}, 0)
	bb.Call(gas, precompileAddress, value, 0x0, 0x8, 0x2 0x8)
	bb.Push(6)
	bb.Push(0)
	bb.Push(0)
	bb.Op(ops.RETURNDATACOPY)
	bb.Op(ops.MSIZE)
	bb.Push(0)
	bb.Op(ops.SHA3)
	bb.Op(ops.DUP1)
	bb.Op(ops.SSTORE)
	```
	Basically you call the identity precompile with inOffset 0, inSIze 8, outOffset 2, outSize 8,
	Then Copy the returndata, hash it and store it to the trie (in order to create an invalid state root)

@winsvega
Copy link
Collaborator

winsvega commented Sep 2, 2021

interesting. thanks for the source code
@qbzzt

@qbzzt
Copy link
Collaborator

qbzzt commented Sep 3, 2021

There are three overlapping buffers here:

  1. The input buffer (0-8)
  2. The output buffer (2-10)
  3. The RETURNDATACOPY buffer (0-6)

That's not necessary. It's enough for the first two to overlap, and then we can use RETURNDATACOPY to an unrelated buffer to show it is corrupt.

I created this filler, which I think is simpler. I need to rebuild by Docker with geth 1.10.8 to be able to create the filled versions, but you can already play with it.
memCopySelfFiller.yml.txt

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 a pull request may close this issue.

4 participants