Skip to content

Commit 1164c06

Browse files
xmariachiamimart
andauthored
Fix reputer/worker window boundaries, tests added (#771)
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺ v ✰ Thanks for creating a PR! You're awesome! ✰ v Please note that maintainers will only review those PRs with a completed PR template. ☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --> ## Purpose of Changes and their Description * Fix: Reputer remainder lag incorrectly computed. * Alignment of inclusiveness (all inclusive, consistent in both reputer and worker windows) so as to remove confusion. * Overflow protection. * Redundant check removed on worker submission window at `EndBlocker`. * Exhaustive unit tests for both windows ## Link(s) to Ticket(s) or Issue(s) resolved by this PR ## Are these changes tested and documented? - [x] If tested, please describe how. If not, why tests are not needed. ✅ Added new unit tests ✅ Ran all tests and integration tests - [x] If documented, please describe where. If not, describe why docs are not needed. -- Added `Data Submission` section to `./README.md`. - [x] Added to `Unreleased` section of `CHANGELOG.md`? --------- Signed-off-by: Diego C <[email protected]> Co-authored-by: Arnaud Mimart <[email protected]>
1 parent e06b011 commit 1164c06

10 files changed

+508
-439
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ test/fuzz/.config.json
5454

5555
allora.log
5656

57+
**/__debug*
58+

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8080
* [#757](https://github.com/allora-network/allora-chain/pull/757) Incoming value limiting
8181
* [#761](https://github.com/allora-network/allora-chain/pull/761) Fix close worker nonce boundaries
8282
* [#760](https://github.com/allora-network/allora-chain/pull/760) Fix topic low-weight inactive topic weight vulnerability
83+
* [#771](https://github.com/allora-network/allora-chain/pull/771) Fix reputer/worker window boundaries
8384

8485
### Security
8586

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,17 @@ ssh -NL 2345:localhost:2345 [email protected]
347347

348348
9- At Cursor, go to the debug pannel, pick "Remote Debug" configuration and start debugging.
349349

350+
## Data Submission Windows
350351

351-
### References
352+
Data is submitted by workers and reputers within the allowed submission windows.
353+
354+
For workers, the submission window is defined at the topic level, as the blocks starting at `nonce.BlockHeight` and ending at `nonce.BlockHeight + topic.WorkerSubmissionWindow`.
355+
356+
For reputers, the submission window starts at `(nonce.BlockHeight + topic.GroundTruthLag)` and it lasts 1 `topic.EpochLength` + any remaining additional lag until end of epoch, only applying when `topic.GroundTruthLag` and `topic.EpochLength` are not multiples, and calculated as `(topic.EpochLength - (topic.GroundTruthLag % topic.EpochLength))`.
357+
358+
Both windows are inclusive of start and end boundaries.
359+
360+
## References
352361

353362
- https://github.com/go-delve/delve/blob/master/Documentation/faq.md#remote
354363
- https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html#attach-to-a-process-on-a-remote-machine

x/emissions/keeper/keeper.go

-14
Original file line numberDiff line numberDiff line change
@@ -3995,20 +3995,6 @@ func (k *Keeper) PruneReputerNonces(ctx context.Context, topicId uint64, blockHe
39953995
return nil
39963996
}
39973997

3998-
// Return true if the nonce is within the worker submission window for the topic
3999-
// Inclusive of the start block height and exclusive of the end block height
4000-
func (k *Keeper) BlockWithinWorkerSubmissionWindowOfNonce(topic types.Topic, nonce types.Nonce, blockHeight int64) bool {
4001-
return nonce.BlockHeight <= blockHeight && blockHeight < topic.WorkerSubmissionWindow+nonce.BlockHeight
4002-
}
4003-
4004-
// Return true if the nonce is within the worker submission window for the topic
4005-
// Inclusive of the start block height and of the end block height
4006-
func (k *Keeper) BlockWithinReputerSubmissionWindowOfNonce(topic types.Topic, nonce types.ReputerRequestNonce, blockHeight int64) bool {
4007-
extraLag := topic.GroundTruthLag % topic.EpochLength
4008-
return nonce.ReputerNonce.BlockHeight+topic.GroundTruthLag <= blockHeight &&
4009-
blockHeight <= nonce.ReputerNonce.BlockHeight+topic.GroundTruthLag+topic.EpochLength+extraLag
4010-
}
4011-
40123998
func (k *Keeper) ValidateStringIsBech32(actor ActorId) error {
40133999
_, err := sdk.AccAddressFromBech32(actor)
40144000
if err != nil {

0 commit comments

Comments
 (0)