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

[ENG-214] Add new epoch types: year, hour #559

Closed
wants to merge 11 commits into from

Conversation

loredanacirstea
Copy link
Contributor

Description

Depends on #553

Add new epoch types: year, hour

  • change default genesis
  • add data migration logic
  • add migration test

Closes: #538


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.

PR review checkboxes:

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • included the correct type prefix in the PR title
  • targeted the correct branch (see PR Targeting)
  • provided a link in the PR description to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all required CI checks have passed

Code maintenance:

I have...

  • written unit and integration tests
  • added relevant godoc and code comments.
  • updated relevant documentation (docs/) or specification (x/<module>/spec/)

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
  • confirmed that this PR does not change production code

- 2 kv stores: identifier => duration, duration => EpochInfo
- duration is parsed for numerical ordering of the kv store values
- IterateEpochInfo returns epochs in descending numerical order or their durations
Default ordering should be consistent with execution order.
Epochs should be executed from smallest to highest. E.g. hourly first, then daily, then weekly, etc.

E.g. inflation runs daily. Incentives run weekly. Incentives are given from inflation rewards, so inflation rewards need to be calculated first.
@linear
Copy link

linear bot commented May 5, 2022

@loredanacirstea loredanacirstea force-pushed the loredana/ENG-214-add-epoch-types branch from 883e89c to 2c6f000 Compare May 5, 2022 12:27
@loredanacirstea loredanacirstea force-pushed the loredana/ENG-214-add-epoch-types branch from 2c6f000 to 31335b9 Compare May 5, 2022 12:37
@@ -13,6 +13,15 @@ func NewGenesisState(epochs []EpochInfo) *GenesisState {
// DefaultGenesisState returns the default epochs genesis state
func DefaultGenesisState() *GenesisState {
epochs := []EpochInfo{
{
Identifier: YearEpochID,
Copy link
Contributor

Choose a reason for hiding this comment

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

@loredanacirstea why do you want to introduce yearly epochs? Considering leap years, the epochs wouldn't be accurate using a Duration of time.Hour * 24 * 365

Copy link
Contributor Author

@loredanacirstea loredanacirstea May 25, 2022

Choose a reason for hiding this comment

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

I added yearly because it is frequent in business contracts. If you open this API to smart contracts (like I showed in the cron precompile demos https://www.youtube.com/watch?v=1whMSUM0JyQ), you can transcribe the business contract into a smart contract.
If the epochs module cannot have yearly, or monthly (also frequently used), maybe we should think about how it can be rewritten, so it can.

Copy link
Contributor

@danburck danburck left a comment

Choose a reason for hiding this comment

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

@loredanacirstea Nice work! Can you reduce this PR to only add hour epochs for now? This PR already holds value because of its improvement on how we store the durations.

As the epoch module is only relevant for other modules on the Evmos protocol right now, we should wait to implement identifiers like month or year until there is a concrete need for another module.

I also suggest to simplify the wording EpochInfo -> Epoch in this PR

}

// GetEpochInfo returns epoch info by duration
func (k Keeper) GetEpoch(ctx sdk.Context, duration []byte) (types.EpochInfo, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would merge GetEpoch with GetEpochInfo, as right now it's confusing to have both and GetEpoch is only called by GetEpochInfo

Copy link
Contributor

Choose a reason for hiding this comment

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

@loredanacirstea what do you think of renaming EpochInfo to Epoch in the proto files? This will make the code less wordy and I don't see the benefit in have Info added.

}

// SetEpochInfo set epoch duration by identifier
func (k Keeper) setEpoch(ctx sdk.Context, epoch types.EpochInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here Epoch and EpochInfo seem mixed

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days-before-close if no further activity occurs.

@github-actions github-actions bot closed this Jul 19, 2022
@0xstepit 0xstepit deleted the loredana/ENG-214-add-epoch-types branch January 26, 2024 14:11
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.

[ENG-214] x/epochs: create an hour type epoch
2 participants