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

docs(adr): propose epoch module #19474

Closed
wants to merge 6 commits into from
Closed

docs(adr): propose epoch module #19474

wants to merge 6 commits into from

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Feb 19, 2024

Description

This pr proposes a simple epoch module to allow modules to register logic to be run at intervals.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Documentation
    • Marked ADR 039 on epoched staking as "ABANDONED."
    • Introduced ADR 071, proposing an Epoch Module for improved module coordination and performance in the Cosmos SDK.

Copy link
Contributor

coderabbitai bot commented Feb 19, 2024

Walkthrough

The recent updates involve two significant changes. Firstly, the abandonment of the proposal for epoched staking, marking a shift in development focus or strategy. Secondly, the introduction of a new Epoch Module, aiming to enhance the Cosmos SDK by allowing better coordination and control over module execution timing. This module is designed to improve system performance and block time management by enabling modules to register their logic for execution at predefined intervals.

Changes

File Path Change Summary
.../adr-039-epoched-staking.md Updated the status from "Proposed" to "ABANDONED" as of 19th February 2024.
.../adr-071-epoch-module.md Introduced ADR 071, proposing the creation of an Epoch Module for improved module coordination and performance.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@ValarDragon
Copy link
Contributor

This new API seems better, but happy to move the canonical epochs module from Osmosis to the SDK as well if that helps

@tac0turtle
Copy link
Member Author

This new API seems better, but happy to move the canonical epochs module from Osmosis to the SDK as well if that helps

it was a quick brain dump so if you have ideas lmk

@alexanderbez
Copy link
Contributor

#19355 will depend on this :)

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Lookin' good so far! Eager to see how the design plays out. I think it should be pretty simple.

What I'd love to see in the ADR is a high-level overview of design of:

  • How to register epoch handlers
  • What the handler interface looks like
  • Epoch module storing last execution times

Also, I'm not sure if there's a great need to mention BeginBlock and EndBlock much. IMO these two concepts are somewhat orthogonal and mutually beneficial. Perhaps we mention that epochs can build upon these powerful primitives to give modules "cadence" to certain execution handlers.

docs/architecture/adr-071-epoch-module.md Outdated Show resolved Hide resolved
Comment on lines 41 to 42
RegisterTimeBeginEpochCalls() map[time.seconds]func() error
RegisterTimeEndEpochCalls() map[time.seconds]func() error
Copy link
Contributor

Choose a reason for hiding this comment

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

With time-based epoch calls, assuming PBTS exist, you'll need the epoch module to store or at least know when the last execution occurred, i.e. x >= time.Now() - LastExecution.

@tac0turtle tac0turtle marked this pull request as ready for review March 3, 2024 14:29
@tac0turtle tac0turtle requested a review from a team as a code owner March 3, 2024 14:29
@tac0turtle
Copy link
Member Author

tac0turtle commented Mar 3, 2024

marking this as r4r but also happy to upstream the epochs module from osmosis. It seems that has adoption in the cosmos.

https://github.com/osmosis-labs/osmosis/tree/main/x/epochs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 8

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 4db9838 and a6c3fbe.
Files selected for processing (2)
  • docs/architecture/adr-039-epoched-staking.md (2 hunks)
  • docs/architecture/adr-071-epoch-module.md (1 hunks)


## Abstract

Currently in the Cosmos SDK all modules have the option to execute logic at the start and end of every block. If a module would like to do something at different intervals, but this logic is not exposed to clients. This makes it confusing when to expect things to be done and not. Secondly, if there are many modules that would like to execute logic at intervals coordinating which modules should run at which block can not be done. This can lead to countless modules running at the same block potentially causing issues with the block time.
Copy link
Contributor

Choose a reason for hiding this comment

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

The sentence structure in this section could be improved for clarity. Consider revising to enhance readability and ensure grammatical correctness. For example, "If a module would like to do something at different intervals, but this logic is not exposed to clients." seems incomplete. Additionally, "cannot" is more commonly used than "can not".

- If a module would like to do something at different intervals, but this logic is not exposed to clients.
+ If a module would like to do something at different intervals, this logic is currently not exposed to clients.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Currently in the Cosmos SDK all modules have the option to execute logic at the start and end of every block. If a module would like to do something at different intervals, but this logic is not exposed to clients. This makes it confusing when to expect things to be done and not. Secondly, if there are many modules that would like to execute logic at intervals coordinating which modules should run at which block can not be done. This can lead to countless modules running at the same block potentially causing issues with the block time.
Currently in the Cosmos SDK all modules have the option to execute logic at the start and end of every block. If a module would like to do something at different intervals, this logic is currently not exposed to clients. This makes it confusing when to expect things to be done and not. Secondly, if there are many modules that would like to execute logic at intervals coordinating which modules should run at which block can not be done. This can lead to countless modules running at the same block potentially causing issues with the block time.


Creating a coordination module that will allow modules to register their logic to be executed at different intervals. This will allow for better coordination of modules and allow for better understanding of when things will be executed. This will also allow for better control of the block time and allow for better performance.

The module does not handle storage of logic to be executed at a certain time, instead it is meant to be as stateless as possible. The implemention of module logic should not queue logic as well, it should execute but not return the data to respective location. For example, with staking val set updates should happen during the state transition but the returned value to comet for validator set updates only gets returned when the epoch is called. If the epoch is called at every block it will be the same as today.
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a typo and a missing comma in this section. Also, the sentence structure could be improved for clarity. Consider revising to ensure grammatical correctness and clarity.

- The implemention of module logic should not queue logic as well, it should execute but not return the data to respective location.
+ The implementation of module logic should not queue logic as well; it should execute but not return the data to the respective location.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
The module does not handle storage of logic to be executed at a certain time, instead it is meant to be as stateless as possible. The implemention of module logic should not queue logic as well, it should execute but not return the data to respective location. For example, with staking val set updates should happen during the state transition but the returned value to comet for validator set updates only gets returned when the epoch is called. If the epoch is called at every block it will be the same as today.
The module does not handle storage of logic to be executed at a certain time, instead it is meant to be as stateless as possible. The implementation of module logic should not queue logic as well; it should execute but not return the data to the respective location. For example, with staking val set updates should happen during the state transition but the returned value to comet for validator set updates only gets returned when the epoch is called. If the epoch is called at every block it will be the same as today.


A new epoch module is created that will allow for modules to register their logic to be executed at different intervals. Modules can register specific calls to be called at specified intervals. The epoch module will be responsible for executing the logic at the specified intervals.

This changes the current design in which each module that executes logic in begin and/or end block to the epoch module having a map of calls to make each interval. The epoch module will be responsible for calling the logic and/or passing messages to the respective modules. This does not replace the concept of beginblock and endblock but rather allows for modules to register their logic to be executed at different intervals.
Copy link
Contributor

Choose a reason for hiding this comment

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

There are several spelling mistakes and a possible missing comma in this section. Additionally, the use of "begin" seems incorrect in the context provided. Consider revising for accuracy and clarity.

- This changes the current design in which each module that executes logic in begin and/or end block to the epoch module having a map of calls to make each interval.
+ This changes the current design in which each module that executes logic in begin and/or end block, to the epoch module having a map of calls to make at each interval.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
This changes the current design in which each module that executes logic in begin and/or end block to the epoch module having a map of calls to make each interval. The epoch module will be responsible for calling the logic and/or passing messages to the respective modules. This does not replace the concept of beginblock and endblock but rather allows for modules to register their logic to be executed at different intervals.
This changes the current design in which each module that executes logic in begin and/or end block, to the epoch module having a map of calls to make at each interval. The epoch module will be responsible for calling the logic and/or passing messages to the respective modules. This does not replace the concept of beginblock and endblock but rather allows for modules to register their logic to be executed at different intervals.


This changes the current design in which each module that executes logic in begin and/or end block to the epoch module having a map of calls to make each interval. The epoch module will be responsible for calling the logic and/or passing messages to the respective modules. This does not replace the concept of beginblock and endblock but rather allows for modules to register their logic to be executed at different intervals.

This simplifies the need for their to be ordering in begin/endblock because the new design is around a caller to represent ordering. For example in the current design mint must come before distribution in begin block. With the proposed design mint and distribution would not have anything to register in beginblock and instead mint will only register a call to be made at a specific interval. Mint will then call distribution.
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of "their" seems incorrect, and there are several spelling mistakes and missing commas. Consider revising for grammatical correctness and clarity.

- This simplifies the need for their to be ordering in begin/endblock because the new design is around a caller to represent ordering.
+ This simplifies the need for there to be ordering in begin/end block because the new design revolves around a caller to represent ordering.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
This simplifies the need for their to be ordering in begin/endblock because the new design is around a caller to represent ordering. For example in the current design mint must come before distribution in begin block. With the proposed design mint and distribution would not have anything to register in beginblock and instead mint will only register a call to be made at a specific interval. Mint will then call distribution.
This simplifies the need for there to be ordering in begin/end block because the new design revolves around a caller to represent ordering. For example in the current design mint must come before distribution in begin block. With the proposed design mint and distribution would not have anything to register in beginblock and instead mint will only register a call to be made at a specific interval. Mint will then call distribution.

}
```

A module will write a functions that returns an error to execute the specific logic at an interval. In the future with internal message passing this can be done with a message instead of a function. If a module does want to use a message they can do this as well and avoid the need to write the function on the keeper.
Copy link
Contributor

Choose a reason for hiding this comment

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

The sentence structure in this section could be improved for clarity, and there's a grammatical error regarding the use of "a functions". Consider revising to ensure grammatical correctness and clarity.

- A module will write a functions that returns an error to execute the specific logic at an interval.
+ A module will write functions that return an error to execute the specific logic at an interval.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
A module will write a functions that returns an error to execute the specific logic at an interval. In the future with internal message passing this can be done with a message instead of a function. If a module does want to use a message they can do this as well and avoid the need to write the function on the keeper.
A module will write functions that return an error to execute the specific logic at an interval. In the future with internal message passing this can be done with a message instead of a function. If a module does want to use a message they can do this as well and avoid the need to write the function on the keeper.


## Consequences

* The new modules becomes required for all modules that would allow users to register logic to be executed at different intervals.
Copy link
Contributor

Choose a reason for hiding this comment

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

The verb form 'becomes' does not seem to match the subject 'modules'. Consider revising for grammatical correctness.

- The new modules becomes required for all modules that would allow users to register logic to be executed at different intervals.
+ The new module becomes required for all modules that allow users to register logic to be executed at different intervals.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
* The new modules becomes required for all modules that would allow users to register logic to be executed at different intervals.
* The new module becomes required for all modules that allow users to register logic to be executed at different intervals.


### Negative

* Modules that require that use the epoch module will need to be modified to avoid using the epoch module, if an application developers does not want to use it.
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a grammatical error regarding the use of "an application developers". Consider revising for grammatical correctness.

- Modules that require that use the epoch module will need to be modified to avoid using the epoch module, if an application developers does not want to use it.
+ Modules that require the use of the epoch module will need to be modified to avoid using the epoch module if an application developer does not want to use it.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
* Modules that require that use the epoch module will need to be modified to avoid using the epoch module, if an application developers does not want to use it.
* Modules that require the use of the epoch module will need to be modified to avoid using the epoch module if an application developer does not want to use it.

@@ -11,7 +12,7 @@

## Status

Proposed
ABANDONED
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The status of ADR 039 as "ABANDONED" is correctly reflected in the ADR document itself. However, the README.md file in the docs/architecture directory does not indicate this status change next to the reference to ADR 039. It is recommended to update the README.md file and any other relevant documentation to clearly reflect the "ABANDONED" status of ADR 039 to ensure clarity and consistency across the documentation.

Analysis chain

The status of this ADR has been updated to "ABANDONED". Ensure that all references to this ADR within the Cosmos SDK documentation and any related proposals are updated accordingly to reflect this change.


Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for references to ADR 039 to ensure they reflect the new status.
rg 'ADR 039' docs/

Length of output: 179



Script:

#!/bin/bash
# Check if the README.md file mentions the status "ABANDONED" for ADR 039
rg 'ADR 039' docs/architecture/README.md

# Search for the term "ABANDONED" in relation to ADR 039 across the docs to ensure the status is properly reflected
rg 'ABANDONED' docs/

Length of output: 999

@tac0turtle
Copy link
Member Author

upstreaming osmosis version, closing this adr

@tac0turtle tac0turtle closed this Mar 6, 2024
@tac0turtle tac0turtle deleted the marko/epoch_module_2 branch March 6, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants