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

Fetch block time from chain #1384

Merged
merged 4 commits into from
Sep 23, 2024
Merged

Fetch block time from chain #1384

merged 4 commits into from
Sep 23, 2024

Conversation

bobo-k2
Copy link
Contributor

@bobo-k2 bobo-k2 commented Sep 16, 2024

Pull Request Summary

  • fetch block time from a chain
  • remove hardcoded block time values in code

Check list

  • contains breaking changes
  • adds new feature
  • modifies existing feature (bug fix or improvements)
  • relies on other tasks
  • documentation changes
  • tested on mobile devices

@bobo-k2 bobo-k2 changed the title Block time Fetch block time from chain Sep 16, 2024
Copy link

github-actions bot commented Sep 16, 2024

Visit the preview URL for this PR (updated for commit 56fc92c):

https://astar-apps--pr1384-fix-block-time-gqakk6p2.web.app

(expires Mon, 23 Sep 2024 11:02:13 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: dd76fe72958fe2910fef9d53f0b4539b82b849db

const secsOneYear = 365 * 24 * 60 * 60;
const periodLength =
eraLength.standardErasPerBuildAndEarnPeriod + eraLength.standardErasPerVotingPeriod;

const eraPerCycle = periodLength * eraLength.periodsPerCycle;
const blocksStandardEraLength = eraLength.standardEraLength;
const blockPerCycle = blocksStandardEraLength * eraPerCycle;
const cyclePerYear = secsOneYear / secBlockProductionRate / blockPerCycle;
const cyclePerYear = secsOneYear / blockTimeInSeconds / blockPerCycle;
console.log('cyclePerYear', cyclePerYear);
Copy link
Contributor

Choose a reason for hiding this comment

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

Log left on purpose?

@@ -111,6 +112,7 @@ function state(): GeneralStateInterface {
currentBlock: 0,
activeInflationConfiguration: undefined,
inflationParameters: undefined,
blockTimeInSeconds: 12,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is default?
Can it be uninitialised until fetched from api?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can :)

@bobo-k2 bobo-k2 changed the base branch from main to release-hotfix September 19, 2024 12:37
@bobo-k2 bobo-k2 merged commit 10fc492 into release-hotfix Sep 23, 2024
8 of 9 checks passed
@bobo-k2 bobo-k2 deleted the fix/block-time branch September 23, 2024 09:41
impelcrypto pushed a commit that referenced this pull request Sep 30, 2024
* Remove Age of Chronos promotion (#1386)

* Fetch block time from chain (#1384)

* Fetch block time to store

* Apr calculation fix

* Type fix

* PR comments fix and code cleanup

* Fix/selected dapp index (#1387)

* Voting wizard search bug fix

* Keep selected dApps while switching categories

* APR calculation fix to use block time for a given block (#1389)

* APR calculation fix to use block time for a given block

* Small fix
impelcrypto pushed a commit that referenced this pull request Oct 1, 2024
* Remove Age of Chronos promotion (#1386)

* Fetch block time from chain (#1384)

* Fetch block time to store

* Apr calculation fix

* Type fix

* PR comments fix and code cleanup

* Fix/selected dapp index (#1387)

* Voting wizard search bug fix

* Keep selected dApps while switching categories

* APR calculation fix to use block time for a given block (#1389)

* APR calculation fix to use block time for a given block

* Small fix

* Fix for re-staking on unregistered dApps (#1392)
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.

4 participants