Skip to content

Commit 36f01f4

Browse files
committed
Send keyper config index as part of EonStartVote
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.
1 parent ec4f6b6 commit 36f01f4

File tree

5 files changed

+60
-57
lines changed

5 files changed

+60
-57
lines changed

rolling-shutter/app/app.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ func LoadShutterAppFromFile(gobpath string) (ShutterApp, error) {
113113
return shapp, nil
114114
}
115115

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

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

433433
func (app *ShutterApp) deliverEonStartVoteMsg(msg *shmsg.EonStartVote, sender common.Address) abcitypes.ResponseDeliverTx {
434-
config := app.getConfig(msg.ActivationBlockNumber)
434+
config, ok := app.getConfigByKeyperConfigIndex(msg.KeyperConfigIndex)
435+
if !ok {
436+
return makeErrorResponse(fmt.Sprintf(
437+
"config with keyper config index %d not found", msg.KeyperConfigIndex))
438+
}
435439
if !config.IsKeyper(sender) {
436440
return notAKeyper(sender)
437441
}
438442

439-
app.countEonStartVote(sender, config, msg.ActivationBlockNumber)
443+
app.countEonStartVote(sender, config, config.ActivationBlockNumber)
440444
dkg, activationBlockNumber, started := app.maybeStartEon(config)
441445
if !started {
442446
return abcitypes.ResponseDeliverTx{

rolling-shutter/keyper/smstate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func (st *ShuttermintState) finalizeDKG(
484484
err = scheduleShutterMessage(
485485
ctx, queries,
486486
"requesting DKG restart",
487-
shmsg.NewEonStartVote(uint64(keyperEon.ActivationBlockNumber)),
487+
shmsg.NewEonStartVote(uint64(keyperEon.KeyperConfigIndex)),
488488
)
489489
if err != nil {
490490
return err

rolling-shutter/shmsg/messages.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ func NewPolyEval(eon uint64, receivers []common.Address, encryptedEvals [][]byte
284284
}
285285

286286
// NewEonStartVote creates a new eon start vote message.
287-
func NewEonStartVote(activationBlockNumber uint64) *Message {
287+
func NewEonStartVote(keyperConfigIndex uint64) *Message {
288288
return &Message{
289289
Payload: &Message_EonStartVote{
290290
EonStartVote: &EonStartVote{
291-
ActivationBlockNumber: activationBlockNumber,
291+
KeyperConfigIndex: keyperConfigIndex,
292292
},
293293
},
294294
}

rolling-shutter/shmsg/shmsg.pb.go

Lines changed: 44 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rolling-shutter/shmsg/shmsg.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ message Apology {
4747
}
4848

4949
message EonStartVote {
50-
uint64 activation_block_number = 1;
50+
uint64 keyper_config_index = 2;
5151
}
5252

5353
message Message {

0 commit comments

Comments
 (0)