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

cmd/puppeth: implement chainspec converters #18172

Merged
merged 2 commits into from
Dec 4, 2018

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Nov 24, 2018

This PR updates puppeth with the most recent changes to the parity and aleth chain specifications. It also adds a feature to convert from a geth genesis to a parity chainspec.

It also contains a testcase which compares the generated stureby chainspecs with the 'official' stureby chainspecs, according to https://gist.github.com/5chdn/baf0eb40cbaff5a90befc52815d6950b.

I did not touch harmony, which currently uses the exact same format as geth. @mkalinin, is that correct?
Also, pyethereum is deprecated, @pipermerriam have trinity now implemented chainspecs?

Example output

[user@work go-ethereum]$ build/bin/puppeth convert stureby.json 
INFO [11-24|23:25:09.312] saved chainspec                          client=aleth filename=stureby-aleth.json
INFO [11-24|23:25:09.313] saved chainspec                          client=parity filename=stureby-parity.json
INFO [11-24|23:25:09.313] saved chainspec                          client=harmony filename=stureby-harmony.json

The stureby.json file is this one. Resulting parity spec:

{
  "name": "stureby",
  "dataDir": "stureby",
  "engine": {
    "Ethash": {
      "params": {
        "minimumDifficulty": "0x20000",
        "difficultyBoundDivisor": "0x800",
        "durationLimit": "0xd",
        "blockReward": {
          "0x0": "0x4563918244f40000",
          "0x7530": "0x29a2241af62c0000",
          "0x9c40": "0x1bc16d674ec80000"
        },
        "difficultyBombDelays": {
          "0x7530": "0x2dc6c0",
          "0x9c40": "0x1e8480"
        },
        "homesteadTransition": "0x2710",
        "eip100bTransition": "0x7530"
      }
    }
  },
  "params": {
    "accountStartNonce": "0x0",
    "maximumExtraDataSize": "0x20",
    "minGasLimit": "0x1388",
    "gasLimitBoundDivisor": "0x400",
    "networkID": "0x4cb2e",
    "chainID": "0x4cb2e",
    "maxCodeSize": "0x6000",
    "maxCodeSizeTransition": "0x0",
    "eip98Transition": "0x7fffffffffffffff",
    "eip150Transition": "0x3a98",
    "eip160Transition": "0x59d8",
    "eip161abcTransition": "0x59d8",
    "eip161dTransition": "0x59d8",
    "eip155Transition": "0x59d8",
    "eip140Transition": "0x7530",
    "eip211Transition": "0x7530",
    "eip214Transition": "0x7530",
    "eip658Transition": "0x7530",
    "eip145Transition": "0x9c40",
    "eip1014Transition": "0x9c40",
    "eip1052Transition": "0x9c40",
    "eip1283Transition": "0x9c40"
  },
  "genesis": {
    "seal": {
      "ethereum": {
        "nonce": "0x0000000000000000",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
      }
    },
    "difficulty": "0x20000",
    "author": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x59a4e76d",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x0000000000000000000000000000000000000000000000000000000b4dc0ffee",
    "gasLimit": "0x47b760"
  },
  "nodes": [],
  "accounts": {
    "0000000000000000000000000000000000000001": {
      "balance": "0x1",
      "builtin": {
        "name": "ecrecover",
        "pricing": {
          "linear": {
            "base": 3000,
            "word": 0
          }
        }
      }
    },
    "0000000000000000000000000000000000000002": {
      "balance": "0x1",
      "builtin": {
        "name": "sha256",
        "pricing": {
          "linear": {
            "base": 60,
            "word": 12
          }
        }
      }
    },
    "0000000000000000000000000000000000000003": {
      "balance": "0x1",
      "builtin": {
        "name": "ripemd160",
        "pricing": {
          "linear": {
            "base": 600,
            "word": 120
          }
        }
      }
    },
    "0000000000000000000000000000000000000004": {
      "balance": "0x1",
      "builtin": {
        "name": "identity",
        "pricing": {
          "linear": {
            "base": 15,
            "word": 3
          }
        }
      }
    },
    "0000000000000000000000000000000000000005": {
      "balance": "0x1",
      "builtin": {
        "name": "modexp",
        "activate_at": "0x7530",
        "pricing": {
          "modexp": {
            "divisor": 20
          }
        }
      }
    },
    "0000000000000000000000000000000000000006": {
      "balance": "0x1",
      "builtin": {
        "name": "alt_bn128_add",
        "activate_at": "0x7530",
        "pricing": {
          "linear": {
            "base": 500,
            "word": 0
          }
        }
      }
    },
    "0000000000000000000000000000000000000007": {
      "balance": "0x1",
      "builtin": {
        "name": "alt_bn128_mul",
        "activate_at": "0x7530",
        "pricing": {
          "linear": {
            "base": 40000,
            "word": 0
          }
        }
      }
    },
    "0000000000000000000000000000000000000008": {
      "balance": "0x1",
      "builtin": {
        "name": "alt_bn128_pairing",
        "activate_at": "0x7530",
        "pricing": {
          "alt_bn128_pairing": {
            "base": 100000,
            "pair": 80000
          }
        }
      }
    }
  }
}

And for aleth:

{
  "sealEngine": "Ethash",
  "params": {
    "accountStartNonce": "0x0",
    "maximumExtraDataSize": "0x20",
    "homesteadForkBlock": "0x2710",
    "daoHardforkBlock": "0x0",
    "EIP150ForkBlock": "0x3a98",
    "EIP158ForkBlock": "0x59d8",
    "byzantiumForkBlock": "0x7530",
    "constantinopleForkBlock": "0x9c40",
    "minGasLimit": "0x1388",
    "maxGasLimit": "0x7fffffffffffffff",
    "tieBreakingGas": false,
    "gasLimitBoundDivisor": "0x400",
    "minimumDifficulty": "0x20000",
    "difficultyBoundDivisor": "0x800",
    "durationLimit": "0xd",
    "blockReward": "0x4563918244f40000",
    "networkID": "0x4cb2e",
    "chainID": "0x4cb2e",
    "allowFutureBlocks": false
  },
  "genesis": {
    "nonce": "0x0000000000000000",
    "difficulty": "0x20000",
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "author": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x59a4e76d",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x0000000000000000000000000000000000000000000000000000000b4dc0ffee",
    "gasLimit": "0x47b760"
  },
  "accounts": {
    "0000000000000000000000000000000000000001": {
      "balance": "0x1",
      "precompiled": {
        "name": "ecrecover",
        "linear": {
          "base": 3000,
          "word": 0
        }
      }
    },
    "0000000000000000000000000000000000000002": {
      "balance": "0x1",
      "precompiled": {
        "name": "sha256",
        "linear": {
          "base": 60,
          "word": 12
        }
      }
    },
    "0000000000000000000000000000000000000003": {
      "balance": "0x1",
      "precompiled": {
        "name": "ripemd160",
        "linear": {
          "base": 600,
          "word": 120
        }
      }
    },
    "0000000000000000000000000000000000000004": {
      "balance": "0x1",
      "precompiled": {
        "name": "identity",
        "linear": {
          "base": 15,
          "word": 3
        }
      }
    },
    "0000000000000000000000000000000000000005": {
      "balance": "0x1",
      "precompiled": {
        "name": "modexp",
        "startingBlock": "0x7530"
      }
    },
    "0000000000000000000000000000000000000006": {
      "balance": "0x1",
      "precompiled": {
        "name": "alt_bn128_G1_add",
        "startingBlock": "0x7530",
        "linear": {
          "base": 500,
          "word": 0
        }
      }
    },
    "0000000000000000000000000000000000000007": {
      "balance": "0x1",
      "precompiled": {
        "name": "alt_bn128_G1_mul",
        "startingBlock": "0x7530",
        "linear": {
          "base": 40000,
          "word": 0
        }
      }
    },
    "0000000000000000000000000000000000000008": {
      "balance": "0x1",
      "precompiled": {
        "name": "alt_bn128_pairing_product",
        "startingBlock": "0x7530"
      }
    }
  }
}

@veox
Copy link
Contributor

veox commented Nov 24, 2018

Also, pyethereum is deprecated, @pipermerriam have trinity now implemented chainspecs?

trinity has implemented genesis files (some draft version of EIP-1085) in ethereum/py-evm#1299, but not a complete chainspec (with bootnodes and stuff). AFAIK.

@holiman
Copy link
Contributor Author

holiman commented Nov 24, 2018

@ghost
Copy link

ghost commented Nov 25, 2018

@holiman Can you add support for single server deploy with multiple nodes & services? For example deploying bootnodes, ethstats, & explorer at a one instance.

Also I would like to know is it possible to support clique engine on parity since they are adding them soon

@holiman
Copy link
Contributor Author

holiman commented Nov 25, 2018

@naikmyeong I thought single-server deploy was already suppprted? File a ticket otherwise. It won't be part of this PR.

Re Clique, sure, good idea. Do you have a reference chainspec to base it off?

@veox
Copy link
Contributor

veox commented Nov 25, 2018

The parity-ethereum (mainline) PR for Clique support is openethereum/parity-ethereum#9845 - containing this chainspec JSON file for Rinkeby (but read on!).

The PR was merged in https://github.com/goerli/parity-goerli instead, and bugs fixed in this revision. Assume most up-to-date version will also be in that repo.


EDIT: I'm not sure how "stable" this is to be considered.

@holiman holiman changed the title puppeth: update parity chainspec, implement converter Puppeth converter from Geth to Parity/Aleth chain specs Nov 26, 2018
@mkalinin
Copy link
Contributor

I did not touch harmony, which currently uses the exact same format as geth. @mkalinin, is that correct?

@holiman it was the same at least an year ago and we changed nothing since that time. If there were no changes in geth either then they are still the same.

@holiman
Copy link
Contributor Author

holiman commented Nov 26, 2018

If there were no changes in geth either then they are still the same.

Not to the format per se, but constantinopleBlock was added of course

@holiman
Copy link
Contributor Author

holiman commented Nov 26, 2018

Oh, what we should do is not add a specific trinity config, but instead an EIP1085 formatted output type (which trinity would use). Not for this PR, though.

@holiman
Copy link
Contributor Author

holiman commented Nov 26, 2018

rebased to get rid of test fails, and formatted to get rid of linting errors

@karalabe
Copy link
Member

karalabe commented Dec 3, 2018

I've reworked the converters so they are part of the wizard. I know it may be a bit more annoying than having a shortcut cli tool, but it's important for me that puppeth behaves uniformly independent of what operation it's expected of it.

I've also added support to import existing (geth/native) genesis specs from a file, or http(s) urls (i.e. I can directly pull the Rinkeby genesis from its website). Export wise it reads a destination folder now and pushes into folder/networkname-clientname.json. There's really no reason to read alternative file names, the network name is unique enough. This keeps the code a lot cleaner and simpler, from a usability perspective too.

@holiman PTAL

@karalabe karalabe added this to the 1.8.20 milestone Dec 3, 2018
Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

I'm happy with the current code, if @holiman agrees with my followup changes, we can merge.

Copy link
Contributor Author

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM aside from a minor nitpick. Not allowed to approve the PR though, since I'm the author

cmd/puppeth/wizard.go Outdated Show resolved Hide resolved
@karalabe karalabe changed the title Puppeth converter from Geth to Parity/Aleth chain specs cmd/puppeth: implement chainspec converters Dec 4, 2018
@karalabe karalabe merged commit f74077b into ethereum:master Dec 4, 2018
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.

5 participants