go-spacemesh
go-spacemesh copied to clipboard
3348 genesis config
Motivation
Closes #3348, #3503, #3504, #3505, #3506, #3507
Changes
[genesis]section in config.toml that is enforced to not change.- Hash of genesis section in config.toml is stored in a
genesis.conffile - GenesisID is calculated from
genesis-timeandgenesis-extradatavalues taken from[genesis]section of config.toml - P2P.NetworkId is set to the Uint32(genesisId)
- Upon startup of node, genesis configuration is loaded from the config file. The node then checks if a
genesis.conffile exists. If it does, the node comparesgenesis.confcontents to the genesis information in the config file. If they are unequal, the node returns an error. If the genesis.conf file does not exist, the node creates the file in readonly mode - The genvm SDK provides an option to be initialized with genesis id:
WithGenesisId - The VM can be initialized with Genesis ID as well
- A lightweight wrapper around EdSigner and EDVerifier has been added, called
GenesisBoundEdSignerandGenesisBoundEdVerifierwhich prepends the genesis Id to the signed message or checks that the first 20 bytes of the message is the correct genesis id, respectively. - GoldenATX is set to Genesis ID and then zero-padded to be type-compatible with the ATX type (GenesisID is 20 bytes, but ATX ID is defined as 32-byte slice)
Test Plan
- [x] Test Genesis config changes
- [ ] Test Signer changes
- [x] Test VM changes
- [ ] Update e2e tests to reflect changes introduced by this PR
TODO
- [x] Complete issue #3505
- [x] Add modified ED signer & verifier
- [x] Remove P2P Network Id & set to genesis id
- [x] Add genesis ID to VM and SDK
- [x] Explain motivation or link existing issue(s)
- [x] Modify GenesisBoundEd[Signer|Verifier] to treat genesis ID as prepended (rather than appended) to msg per #3503
- [x] Modify Verify method in templates per issue #3504
- [ ] Address bullet points 2 and 3 in #3506
- [x] Complete #3507
- [x] Test changes and document test plan
- [ ] Update documentation as needed
DevOps Notes
- [ ] This PR does not require configuration changes (e.g., environment variables, GitHub secrets, VM resources)
- [x] This PR does not affect public APIs
- [x] This PR does not rely on a new version of external services (PoET, elasticsearch, etc.)
- [x] This PR does not make changes to log messages (which monitoring infrastructure may rely on)
this change needs to be splitted before review
implemented elsewhere