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

Philipp #1

Merged
merged 42 commits into from
May 5, 2023
Merged

Philipp #1

merged 42 commits into from
May 5, 2023

Conversation

philipp-zahn
Copy link
Member

Main reporter functionality; state definition; and parts of payout pool

Copy link
Member

@FabrizioRomanoGenovese FabrizioRomanoGenovese left a comment

Choose a reason for hiding this comment

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

Very nice work, I'm super eager to see how Crem fares with modelling the payoutPool functionality!

| registeredProposer == True = [NoPenalty, Penalty Kicked]
| otherwise = [NoPenalty]

-- Submit on-chain report
actionsOnChainReport penalty = [NoReport, SubmitReport Validator, SubmitReport Builder, SubmitReport ValidatorKicked]
actionsOnChainReport penaltyValidator penaltyBuilder penaltyValidatorKicking (_,slot,proposerAddr,builderAddr,_,_) = [NoReport, SubmitReport report1, SubmitReport report2, SubmitReport report3]

Choose a reason for hiding this comment

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

Here three different record for three different types of penalty have been instantiated on the fly, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The general idea is that the reporter before follows a certain logic, where exactly to identify a problem. That ends with a report. After that there is an explicit decision where this can be overruled. The idea being that in this way, we can in principle model different players doing different parts of the reporting. Not needed now but it would be a pain to add this later.

preconditions
:: State -> ProposerAddr -> BuilderAddr -> SlotID -> Bool
preconditions state proposerAddr builderAddr slot
| checkReportInterval state slot == False = False

Choose a reason for hiding this comment

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

I find this syntax a bit difficult to parse, but maybe it's just me!

Copy link
Member

Choose a reason for hiding this comment

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

Looks a bit dirty to me too. We're just checking that checkReportInterval state slot is True

Copy link
Member

Choose a reason for hiding this comment

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

There's several instances of this. I don't know if @philipp-zahn prefers it that way but I can give it a quick pass and commit a cleaner version

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 think I tried to follow the logic in the docs. But if both of you feel this is confusing it is a sign we should do it differently. @dpl0a do you wanna take that over?

| slotInPast == True
&& registeredProposer == True
&& missedPayment == True
&& demand == True = [NoPenalty, Penalty Grieving]
Copy link
Member

@dpl0a dpl0a May 2, 2023

Choose a reason for hiding this comment

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

These == True are redundant (there's several instances of that in the repo), IDK if it makes the code more readable for non-haskell people but let's keep that in mind

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, my intention was to make it more readable. Also: the semantics of these bool conditions is not always clear, I fear. That's why I explicitly commented on them where I defined them.

checkPayment :: State -> SlotID -> BuilderAddr -> Bool
checkPayment (State StateOnChain{..} StatePoNOnChain{..} _) slot builder =
let payment = M.lookup (slot,builder) paidInSlot
in if payment == Nothing
Copy link
Member

Choose a reason for hiding this comment

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

Lots of redundant if's in this module.
e.g. we can substitute this with isJust payment after importing Data.Maybe

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that is a good point. I spend zero time on refactoring. @dpl0a can you take the lead on this?

checkDemand :: State -> SlotID -> Bool
checkDemand (State StateOnChain{..} StatePoNOnChain{..} (_,auction)) slot =
let bids = auction M.! slot
in if bids == []
Copy link
Member

Choose a reason for hiding this comment

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

Another example: here we can use bids /= []

Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above. @dpl0a again, wanna take over here?

@philipp-zahn philipp-zahn merged commit a579921 into main May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants