-
Notifications
You must be signed in to change notification settings - Fork 37
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
ir: Use genesis role designations for autodeploy #2652
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,16 +111,24 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co | |
const validatorsHistoryKey = rootSection + ".validators_history" | ||
if v.IsSet(validatorsHistoryKey) { | ||
c.ValidatorsHistory = make(map[uint32]uint32) | ||
committeeSize := uint64(c.Committee.Len()) | ||
err = parseConfigMap(v, validatorsHistoryKey, "validators history", func(name string, val any) error { | ||
height, err := strconv.ParseUint(name, 10, 32) | ||
if err != nil { | ||
return fmt.Errorf("parse unsigned integer: %w", err) | ||
} | ||
|
||
if height%committeeSize != 0 { | ||
return fmt.Errorf("height %d is not a multiple of the %q size", height, committeeKey) | ||
} | ||
|
||
num, err := cast.ToUint32E(val) | ||
if err != nil { | ||
return err | ||
} else if num > math.MaxInt32 { | ||
} else if num <= 0 { | ||
return fmt.Errorf("value %d is out of allowable range", num) | ||
} else if num > uint32(c.Committee.Len()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don;t quite like these repeating checks. We have https://github.com/nspcc-dev/neo-go/blob/6c0c2a6a98b0799f1e19dfeac8956169f1aa4a7a/pkg/config/protocol_config.go#L80, and if some check is missing there, then create an issue and we'll add more checks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not this issue's point but interesting, moved to #2666 |
||
return fmt.Errorf("value exceeds %q size: %d > %d", committeeKey, num, c.Committee.Len()) | ||
} | ||
c.ValidatorsHistory[uint32(height)] = num | ||
return nil | ||
|
@@ -210,6 +218,11 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co | |
} | ||
} | ||
|
||
c.SetRolesInGenesis, err = parseConfigBool(v, rootSection+".set_roles_in_genesis", "flag to set roles for the committee in the genesis block") | ||
if err != nil && !errors.Is(err, errMissingConfig) { | ||
return c, err | ||
} | ||
|
||
c.Logger = _logger | ||
|
||
return c, nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU, genesis-based roles are planned to be a standard for the network. How about reverting the meaning of this setting so that it can be skipped in default config? E.g. s/
set_roles_in_genesis
/skip_genesis_roles
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
propose this in #2643 pls. To me, we aint ready yet to use genesis roles everywhere by default