ethereum / retesteth

testeth via RPC. Test run, generation by t8ntool protocol
http://retesteth.ethdevops.io/
GNU General Public License v3.0
114 stars 75 forks source link

Automatic nonce increments even when the transaction is invalid #132

Closed qbzzt closed 3 years ago

qbzzt commented 3 years ago

This test fails because it thinks the transaction in the second block should have a nonce of 2, whereas it really should have 1 (because the previous one is invalid). The solution is for nonce: auto to not increment the nonce when you have invalid: 1 in the transaction.

prob:
  genesisBlockHeader:
    bloom: '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000$
    coinbase: '0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba'
    difficulty: '131072'
    extraData: '0x42'
    gasUsed: '0'
    mixHash: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
    nonce: '0x0102030405060708'
    number: '0'
    parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000'
    receiptTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
    stateRoot: '0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a'
    timestamp: '0x03b6'
    transactionsTrie: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
    uncleHash: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
    gasLimit: 4000000  # 4m gas
    baseFee: 1
  sealEngine: NoProof

  pre:
    0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b:
      balance: 0x10000000000
      code: ''
      nonce: 1
      storage: {}

    0xd02d72E067e77158444ef2020Ff2d325f929B363:
      balance: 0x1000000000000
      nonce: 1
      code: ''
      storage: {}

    # Spend all the gas you can
    # (that is the result of a call with an illegal opcode)
    0x1111111111111111111111111111111111111111:
      balance: 0x10000000000
      nonce: 1
      code: :raw 0xfe
      storage: {}

  blocks:

  # Gas used can't be more than the block's gasLimit
  - blockHeader:
      gasLimit: 4000000  # 4m gas
    transactions:
    - data: ''
      invalid: 1
      accessList: []
      gasLimit: 4000001
      tip: 0x00
      feeCap: 4000
      nonce: auto
      secretKey: 41f6e321b31e72173f8ff2e292359e1862f24fba42fe6f97efaf641980eff298
      to: 0x1111111111111111111111111111111111111111
      value: 0x0

  - blockHeader:
      gasLimit: 4000000  # 4m gas
    transactions:
    - data: ''
      accessList: []
      gasLimit: 4000000
      tip: 0x00
      feeCap: 4000
      nonce: auto
      secretKey: 41f6e321b31e72173f8ff2e292359e1862f24fba42fe6f97efaf641980eff298
      to: 0x1111111111111111111111111111111111111111
      value: 0x0

  expect:
  - network:
    - ">=London"
    # No real result, this test is based on whether transactions are 
    # considered valid or not
    result: {}

The error message shows that the failure is due to nonce=2:

WARNING: TestBlockchain::mineBlock transaction has unexpectedly failed to be mined (see logs --verbosity 6): 
{
    "data" : "0x",
    "gasLimit" : "0x3d0900",
    "nonce" : "0x02",
    "to" : "0x1111111111111111111111111111111111111111",
    "value" : "0x00",
    "v" : "0x01",
    "r" : "0x36fbe076f61f588cf183c99582fb2cc1cc64de54fb2fbdae4e837b277448b44e",
    "s" : "0x07abb0e1249c11fcbe9749022c3cdb5eef05557072bd0129bdadf94ec387fc31",
    "chainId" : "0x01",
    "type" : "0x02",
    "feeCap" : "0x0fa0",
    "tip" : "0x00",
    "accessList" : [
    ]
}
winsvega commented 3 years ago

this is difficult. nonce auto replacement happens on a pre processing time when we don't know the transaction status. besides one transaction can be valid and invalid depending on the fork.