Skip to content

Commit

Permalink
Decouple rootchain contracts deployment from development environment (#…
Browse files Browse the repository at this point in the history
…1005)

* Rootchain init contracts read validators from the genesis configuration.
Introduce manifest.json.

* Introduce admin-key flag to the rootchain init-contracts

* Revert polybft params changes

* Fix comment

* Populate rootchain admin address to manifest

* Update Manifest struct and adapt init-contracts workflow

* Remove sidechain smart contract addresses from genesis spec

* Update genesis command and cleanup genesis from unnecessary parameters

* Remove rootchain contracts hardcoded addresses

* Decouple emit command from contant StateSender address

* Manifest command

* Polybft manifest command

* Adapt e2e tests workflow

* Update comment

* Adapt cluster script and change flags descriptions in manifest command

* Comments

* Adapt TestE2E_CheckpointSubmission

* Remove manifest.json in cluster script

* Initial version of polybft readme

* Update readme with a precondition step

* Address comments (part 1)

* Update manifest command short help

* Comments

* Use sidechain addresses from the polybft config in fsm UTs

* Minimize changes

* Merge fix

Co-authored-by: Goran Rojovic <goran.rojovic@ethernal.tech>
  • Loading branch information
Stefan-Ethernal and goran-ethernal authored Dec 16, 2022
1 parent a8ff39c commit e993b3b
Show file tree
Hide file tree
Showing 27 changed files with 846 additions and 478 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
peers.json
genesis.json
manifest.json
secretsManagerConfig.json
*-packr.go
config*.json
Expand Down
33 changes: 13 additions & 20 deletions command/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,56 +150,49 @@ func setFlags(cmd *cobra.Command) {

// PolyBFT
{
cmd.Flags().StringVar(
&params.manifestPath,
manifestPathFlag,
defaultManifestPath,
"the manifest file path, which contains genesis metadata",
)

cmd.Flags().IntVar(
&params.validatorSetSize,
validatorSetSizeFlag,
defaultValidatorSetSize,
"the total number of validators",
)
cmd.Flags().StringVar(
&params.polyBftValidatorPrefixPath,
polyBftValidatorPrefixPathFlag,
defaultPolyBftValidatorPrefixPath,
"prefix path for polybft validator folder directory",
)

cmd.Flags().Uint64Var(
&params.sprintSize,
sprintSizeFlag,
defaultSprintSize,
"the number of block included into a sprint",
)

cmd.Flags().DurationVar(
&params.blockTime,
blockTimeFlag,
defaultBlockTime,
"the predefined period which determines block creation frequency",
)
cmd.Flags().StringArrayVar(
&params.validators,
validatorsFlag,
[]string{},
"validators defined by user throughout a parameter (format: <address>:<blskey>)",
)
cmd.Flags().StringVar(
&params.premineValidators,
premineValidatorsFlag,
command.DefaultPremineBalance,
"the amount which will be premined to all the validators",
)

cmd.Flags().StringVar(
&params.smartContractsRootPath,
smartContractsRootPathFlag,
contracts.ContractsRootFolder,
"the smart contracts folder",
)

cmd.Flags().StringVar(
&params.bridgeJSONRPCAddr,
bridgeFlag,
"",
"the rootchain JSON RPC IP address. If present, node is running in bridge mode.",
)

cmd.Flags().Lookup(bridgeFlag).NoOptDefVal = "http://127.0.0.1:8545"
cmd.MarkFlagsMutuallyExclusive(validatorsFlag, premineValidatorsFlag)
}
}

Expand Down Expand Up @@ -234,7 +227,7 @@ func runCommand(cmd *cobra.Command, _ []string) {
var err error

if params.isPolyBFTConsensus() {
err = params.generatePolyBftGenesis()
err = params.generatePolyBftChainConfig()
} else {
err = params.generateGenesis()
}
Expand Down
25 changes: 10 additions & 15 deletions command/genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,12 @@ type genesisParams struct {
genesisConfig *chain.Chain

// PolyBFT
validatorSetSize int
sprintSize uint64
blockTime time.Duration
validators []string

polyBftValidatorPrefixPath string
premineValidators string
smartContractsRootPath string
bridgeJSONRPCAddr string
manifestPath string
smartContractsRootPath string
validatorSetSize int
sprintSize uint64
blockTime time.Duration
bridgeJSONRPCAddr string
}

func (p *genesisParams) validateFlags() error {
Expand Down Expand Up @@ -336,19 +333,17 @@ func (p *genesisParams) initGenesisConfig() error {
chainConfig.Genesis.Alloc[staking.AddrStakingContract] = stakingAccount
}

premineInfos := make([]*premineInfo, len(p.premine))

for i, premineRaw := range p.premine {
for _, premineRaw := range p.premine {
premineInfo, err := parsePremineInfo(premineRaw)
if err != nil {
return err
}

premineInfos[i] = premineInfo
chainConfig.Genesis.Alloc[premineInfo.address] = &chain.GenesisAccount{
Balance: premineInfo.balance,
}
}

fillPremineMap(chainConfig.Genesis.Alloc, premineInfos)

p.genesisConfig = chainConfig

return nil
Expand Down
Loading

0 comments on commit e993b3b

Please sign in to comment.