-
Notifications
You must be signed in to change notification settings - Fork 14
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
new clock implementation and tests #1
Conversation
* add `fmt` config * add `fmt` check to CI * formate all contract
bbf151a
to
a05c759
Compare
a05c759
to
3078b14
Compare
I failed to re-enable |
@GCdePaula I made some changes based on our discussion awhile ago. But I don't think I've covered everything. Could you submit your comments/reviews so I can double check? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work! I've left a few comments.
// Dummy | ||
Time.Duration constant COMMITMENT_EFFORT = Time.Duration.wrap(0); | ||
Time.Duration constant CENSORSHIP_TOLERANCE = Time.Duration.wrap(60 * 5); | ||
Time.Duration constant MATCH_EFFORT = Time.Duration.wrap(60 * 2); | ||
|
||
// 4-level tournament | ||
uint64 constant LEVELS = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to update this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, what should it be updated to?
@@ -241,9 +262,42 @@ function HonestStrategy:_react_tournament(state, tournament) | |||
end | |||
end | |||
|
|||
for _, match in ipairs(tournament.matches) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue is that this would only run at the tournaments the player is on.
I propose a different approach. Let's separate the two logics. The player only plays the tournaments and matches. Separate from this, we have a garbage collector, which will scan all the tournaments recursively, calling timeout on all matches.
} | ||
Time.Duration _allowance = | ||
_timeLeft.add(ArbitrationConstants.MATCH_EFFORT); | ||
// TODO: do we need this cap check? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need it.
); | ||
|
||
_clockOne.addValidatorEffort(Time.ZERO_DURATION); | ||
_clockOne.deduct(_clockTwo.timeSinceTimeout()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this. I believe both clocks are running on step in the leaf match. I think if we deduct, we'll be subtracting it twice.
I think we need to pause it too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so a simple setPaused()
should do it here.
/// - if the tournament is finished | ||
/// - the contested parent commitment | ||
/// - the dangling commitment | ||
function innerTournamentWinner() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a mental TODO on how to deal with tournaments where nobody won.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides no one joining, all claims can also time out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to be able to communicate to the caller:
- Tournament not finished;
- Tournament finished, no one won (parent can delete parent match)
- Tournament finished, here's the winner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's open an issue for this. We need to change this function, and also the caller of this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | ||
maximumEnforceableDelay = Time.currentTime().add(_allowance); | ||
} | ||
// TODO: do we need this cap check? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need this check :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the caller should make sure of that instead? I'm not sure.
return true | ||
elseif m1.block_number > m2.block_number then | ||
return false | ||
function CommitmentClock:display(block_time) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the __tostring
metamethod!
assert(handle) | ||
|
||
local ret | ||
local str = handle:read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you read everything instead with *a
? Might simplify this loop.
010fc1a
to
6bfea30
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work :)
/// - if the tournament is finished | ||
/// - the contested parent commitment | ||
/// - the dangling commitment | ||
function innerTournamentWinner() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides no one joining, all claims can also time out!
/// - if the tournament is finished | ||
/// - the contested parent commitment | ||
/// - the dangling commitment | ||
function innerTournamentWinner() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to be able to communicate to the caller:
- Tournament not finished;
- Tournament finished, no one won (parent can delete parent match)
- Tournament finished, here's the winner.
/// - if the tournament is finished | ||
/// - the contested parent commitment | ||
/// - the dangling commitment | ||
function innerTournamentWinner() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's open an issue for this. We need to change this function, and also the caller of this function.
machine
related onesforge fmt --check
andforge test
to CIeliminateMatchByTimeout