Skip to content
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

test(mbt): MBT for round state machine #120

Merged
merged 77 commits into from
Dec 19, 2023
Merged

test(mbt): MBT for round state machine #120

merged 77 commits into from
Dec 19, 2023

Conversation

hvanz
Copy link
Member

@hvanz hvanz commented Dec 13, 2023

Closes #45

state.toSkipRoundOutput(state.round + 1)
state
// CHECK: setting the step to NewRound was added to match the code behavior
.with("step", NewRoundStep)
Copy link
Member Author

@hvanz hvanz Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josef-widder Please check if this makes sense, together with the new conditions in NewRoundProposerCInput and NewRoundCInput.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josef-widder I am wondering if we can remove the NoStep step and merge it with NewRoundStep? (now called UnstartedStep)

Copy link
Member

@josef-widder josef-widder Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NoStep actually is used to record that the last consensus action did not change the step variable. See

    pure def recordStepChange(old: DriverState, new: DriverState) : DriverState =
        if (old.cs.step == new.cs.step)
            { ...new, pendingStepChange: NoStep }
        else
            { ...new, pendingStepChange: new.cs.step}

So we shouldn't merge it. But perhaps it eventually makes sense to rename it to NoStepChange.

But perhaps inside the consensus state, it makes sense to initialize to NewRoundStep. I just realized that the step variable seems not to be initialized properly in the arXiv paper, so we should think about it before we change anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josef-widder Please check if this makes sense, together with the new conditions in NewRoundProposerCInput and NewRoundCInput.

It think it is OK, as there is also a new condition in RoundSkipCInput(r)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried removing NoStep and using a sum type for pendingStepChange:

type StepChange =
  | NoStepChange
  | SomeStepChange(Step)

// ...

pendingStepChange: StepChange

// ...

pure def recordStepChange(old: DriverState, new: DriverState) : DriverState =
    if (old.cs.step == new.cs.step)
        { ...new, pendingStepChange: NoStepChange }
    else
        { ...new, pendingStepChange: SomeStepChange(new.cs.step) }

which works fine but then I could not get the MBT tests to work properly, and I don't want to mess too much with them right now.

So let's leave it like that for now.

@hvanz hvanz requested a review from josef-widder December 14, 2023 23:48
@hvanz hvanz marked this pull request as ready for review December 15, 2023 11:59
@hvanz hvanz removed the work in progress Work in progress label Dec 15, 2023
Comment on lines +242 to +243
// TODO: We need to manually feed `ProposeValue` to the round state
// machine here, and then check the emitted proposal.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the issue is that the spec does two steps at once here, whereas the round state machine needs whoever is driving it to feed it back a value to propose.

I am a bit surprised that the whole test even goes through given that we never do so in the test runner, need to dig in further.

@hvanz Do you have an idea for why that is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why. I think it's related to my comment above about the proposal value not used https://github.com/informalsystems/malachite/pull/120/files#r1428373893

@romac romac changed the title test(mbt): consensus module (spec) / round state machine (code) test(mbt): MBT for round state machine Dec 19, 2023
@romac romac merged commit 22fe845 into main Dec 19, 2023
8 checks passed
@romac romac deleted the mbt-consensus branch December 19, 2023 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mbt Model-Based Testing test Testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test: MBT for round state machine
4 participants