Skip to content

Commit

Permalink
Send keyper config index as part of EonStartVote
Browse files Browse the repository at this point in the history
This replaces the use of the activation block number as part of the message. In
the app we still use the activation block number, but could probably also get
rid of it, since we just use the value from the keyper/batch config.
  • Loading branch information
schmir committed Apr 19, 2022
1 parent ec4f6b6 commit 36f01f4
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 57 deletions.
20 changes: 12 additions & 8 deletions rolling-shutter/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ func LoadShutterAppFromFile(gobpath string) (ShutterApp, error) {
return shapp, nil
}

// getConfig returns the BatchConfig for the given mainchain block number.
func (app *ShutterApp) getConfig(blockNumber uint64) *BatchConfig {
for i := len(app.Configs) - 1; i >= 0; i-- {
if app.Configs[i].ActivationBlockNumber <= blockNumber {
return app.Configs[i]
// getConfigByKeyperConfigIndex returns the BatchConfig with the given keyperConfigIndex.
func (app *ShutterApp) getConfigByKeyperConfigIndex(keyperConfigIndex uint64) (*BatchConfig, bool) {
for _, cfg := range app.Configs {
if cfg.KeyperConfigIndex == keyperConfigIndex {
return cfg, true
}
}
panic("guard element missing")
return nil, false
}

// checkConfig checks if the given BatchConfig could be added.
Expand Down Expand Up @@ -431,12 +431,16 @@ func (app *ShutterApp) deliverBlockSeen(
}

func (app *ShutterApp) deliverEonStartVoteMsg(msg *shmsg.EonStartVote, sender common.Address) abcitypes.ResponseDeliverTx {
config := app.getConfig(msg.ActivationBlockNumber)
config, ok := app.getConfigByKeyperConfigIndex(msg.KeyperConfigIndex)
if !ok {
return makeErrorResponse(fmt.Sprintf(
"config with keyper config index %d not found", msg.KeyperConfigIndex))
}
if !config.IsKeyper(sender) {
return notAKeyper(sender)
}

app.countEonStartVote(sender, config, msg.ActivationBlockNumber)
app.countEonStartVote(sender, config, config.ActivationBlockNumber)
dkg, activationBlockNumber, started := app.maybeStartEon(config)
if !started {
return abcitypes.ResponseDeliverTx{
Expand Down
2 changes: 1 addition & 1 deletion rolling-shutter/keyper/smstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func (st *ShuttermintState) finalizeDKG(
err = scheduleShutterMessage(
ctx, queries,
"requesting DKG restart",
shmsg.NewEonStartVote(uint64(keyperEon.ActivationBlockNumber)),
shmsg.NewEonStartVote(uint64(keyperEon.KeyperConfigIndex)),
)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions rolling-shutter/shmsg/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ func NewPolyEval(eon uint64, receivers []common.Address, encryptedEvals [][]byte
}

// NewEonStartVote creates a new eon start vote message.
func NewEonStartVote(activationBlockNumber uint64) *Message {
func NewEonStartVote(keyperConfigIndex uint64) *Message {
return &Message{
Payload: &Message_EonStartVote{
EonStartVote: &EonStartVote{
ActivationBlockNumber: activationBlockNumber,
KeyperConfigIndex: keyperConfigIndex,
},
},
}
Expand Down
89 changes: 44 additions & 45 deletions rolling-shutter/shmsg/shmsg.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rolling-shutter/shmsg/shmsg.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ message Apology {
}

message EonStartVote {
uint64 activation_block_number = 1;
uint64 keyper_config_index = 2;
}

message Message {
Expand Down

0 comments on commit 36f01f4

Please sign in to comment.