Consensys / quorum

A permissioned implementation of Ethereum supporting data privacy
https://www.goquorum.com/
GNU Lesser General Public License v3.0
4.68k stars 1.29k forks source link

Error migrating from legacy maxCodeSizeConfig to Transitions.contractsizelimit #1622

Open vdamle opened 1 year ago

vdamle commented 1 year ago

System information

Geth version: Geth/v1.10.3-stable-e73afc9b(quorum-v22.7.6)/linux-amd64/go1.19.6 OS & Version: Linux Commit hash : N/A

Expected behaviour

A migration of genesis config MaxCodeSizeConfig to Transitions.ContractSizeLimit should be allowed via a re-initialization of the genesis config, after an update of the genesis file. There is a log as well which tells users to migrate their genesis config since MaxCodeSizeConfig is deprecated, reference: https://github.com/ConsenSys/quorum/pull/1376

WARN [03-09|19:20:03.005] WARNING: The attribute config.maxCodeSizeConfig is deprecated and will be removed in the future, please use config.transitions.contractsizelimit on genesis file

Actual behaviour

During an upgrade from Quorum v22.4.4 to v22.7.6, we applied the below change to the genesis file and executed a geth init, to re-initialize the chain configuration. The command throws the error shows below.

INFO [03-09|21:11:49.374] Running with private transaction manager disabled - quorum private transactions will not be supported
INFO [03-09|21:11:49.376] Maximum peer count                       ETH=50 LES=0 total=50
INFO [03-09|21:11:49.376] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [03-09|21:11:49.468] Enabling recording of key preimages since archive mode is used
INFO [03-09|21:11:49.468] Set global gas cap                       cap=25,000,000
INFO [03-09|21:11:49.472] Allocated cache and file handles         database=/qdata/ethereum/chaindata-bk/geth/chaindata cache=16.00MiB handles=16
INFO [03-09|21:11:49.737] Persisted trie from memory database      nodes=1 size=151.00B time="10.4µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
Fatal: Failed to write genesis block: mismatching genesis file missing max code size information in database (have 1211, want 1211, rewindto 1210)

Steps to reproduce the behaviour

It appears that isMaxCodeSizeConfigCompatible() was not updated in https://github.com/ConsenSys/quorum/pull/1376 to handle the case where the old genesis contained maxCodeSizeConfig and the new genesis contains the new style config.transitions.contractsizelimit: https://github.com/ConsenSys/quorum/blob/master/params/config.go#L790-L803

Old Genesis file
{
  "alloc": {
    "c3190225b07f62a25e2919d9099e6c9573ba5354": {
      "balance": "1000000000000000000000000000"
    }
  },
  "coinbase": "0x0000000000000000000000000000000000000000",
  "config": {
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "isQuorum": true,
    "maxCodeSizeConfig": [
      {
        "block": 0,
        "size": 128
      }
    ],
    "istanbul": {
      "epoch": 30000,
      "policy": 0,
      "ceil2Nby3Block": 0
    },
    "chainId": 701348146
  },
  "difficulty": "0x1",
  "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f85ad5943a053c2a9af1bef5b55e1b4b03d18f9e0069a99ab8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0",
  "gasLimit": "0x2FEFD800",
  "mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
  "nonce": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x00"
}
New Genesis file
{
  "alloc": {
    "c3190225b07f62a25e2919d9099e6c9573ba5354": {
      "balance": "1000000000000000000000000000"
    }
  },
  "coinbase": "0x0000000000000000000000000000000000000000",
  "config": {
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "isQuorum": true,
    "chainId": 701348146,
    "transitions": [
      {
        "block": 0,
        "contractSizeLimit": 128
      },
      {
        "block": 0,
        "transactionSizeLimit": 128
      }
    ],
    "ibft": {
      "policy": 0,
      "ceil2Nby3Block": 0,
      "epochlength": 30000,
      "blockperiodseconds": 10,
      "requesttimeoutseconds": 20
    }
  },
  "difficulty": "0x1",
  "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f85ad5943a053c2a9af1bef5b55e1b4b03d18f9e0069a99ab8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0",
  "gasLimit": "0x2FEFD800",
  "mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
  "nonce": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x00"
}

Backtrace

N/A

antonydenyer commented 1 year ago

Good spot! Should probably fix this before deprecating the maxCodeSizeConfig 😉