Skip to content

Commit

Permalink
fix: revert spec breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
anatolie-ssv committed Oct 17, 2024
1 parent e9441f1 commit 983fec4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
12 changes: 6 additions & 6 deletions protocol/v2/qbft/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@ func NewController(
}

// StartNewInstance will start a new QBFT instance, if can't will return error
func (c *Controller) StartNewInstance(logger *zap.Logger, height specqbft.Height, value []byte) (*instance.Instance, error) {
func (c *Controller) StartNewInstance(logger *zap.Logger, height specqbft.Height, value []byte) error {

if err := c.GetConfig().GetValueCheckF()(value); err != nil {
return nil, errors.Wrap(err, "value invalid")
return errors.Wrap(err, "value invalid")
}

if height < c.Height {
return nil, errors.New("attempting to start an instance with a past height")
return errors.New("attempting to start an instance with a past height")
}

if c.StoredInstances.FindInstance(height) != nil {
return nil, errors.New("instance already running")
return errors.New("instance already running")
}

c.Height = height

newInstance := c.addAndStoreNewInstance()
newInstance.Start(logger, value, height)
c.forceStopAllInstanceExceptCurrent()

return newInstance, nil
return nil
}

func (c *Controller) forceStopAllInstanceExceptCurrent() {
Expand Down
2 changes: 1 addition & 1 deletion protocol/v2/qbft/spectest/controller_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func testBroadcastedDecided(
}

func runInstanceWithData(t *testing.T, logger *zap.Logger, height specqbft.Height, contr *controller.Controller, runData *spectests.RunInstanceData) error {
_, err := contr.StartNewInstance(logger, height, runData.InputValue)
err := contr.StartNewInstance(logger, height, runData.InputValue)
var lastErr error
if err != nil {
lastErr = err
Expand Down
9 changes: 6 additions & 3 deletions protocol/v2/ssv/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,16 @@ func (b *BaseRunner) decide(logger *zap.Logger, runner Runner, slot phase0.Slot,
return errors.Wrap(err, "input data invalid")
}

newInstance, err := runner.GetBaseRunner().QBFTController.StartNewInstance(logger,
if err := runner.GetBaseRunner().QBFTController.StartNewInstance(logger,
specqbft.Height(slot),
byts,
)
if err != nil {
); err != nil {
return errors.Wrap(err, "could not start new QBFT instance")
}
newInstance := runner.GetBaseRunner().QBFTController.StoredInstances.FindInstance(specqbft.Height(slot)) // TODO confirm correctness
if newInstance == nil {
return errors.New("could not find newly created QBFT instance")
}

runner.GetBaseRunner().State.RunningInstance = newInstance

Expand Down

0 comments on commit 983fec4

Please sign in to comment.