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

feat: Refactor Config out of Runtime #3459

Merged
merged 4 commits into from
Oct 12, 2020
Merged

Conversation

evgenykuzyakov
Copy link
Collaborator

@evgenykuzyakov evgenykuzyakov commented Oct 6, 2020

Move RuntimeConfig from Runtime initialization to ApplyState object.
This makes Runtime completely stateless and allows to execute transitions based on different configs.
It allows to upgrade RuntimeConfig with the new fees based on the protocol version for the current block.

This change should be NOOP and doesn't change the protocol.

NEP: near/NEPs#120
Issue: #3158

Test plan:

@gitpod-io
Copy link

gitpod-io bot commented Oct 6, 2020

@evgenykuzyakov evgenykuzyakov changed the title [WIP] feat: Refactor Config out of Runtime feat: Refactor Config out of Runtime Oct 7, 2020
@evgenykuzyakov evgenykuzyakov marked this pull request as ready for review October 7, 2020 20:47
@@ -113,6 +114,7 @@ impl EpochInfoProvider for SafeEpochManager {
/// TODO: this possibly should be merged with the runtime cargo or at least reconciled on the interfaces.
pub struct NightshadeRuntime {
genesis_config: GenesisConfig,
genesis_runtime_config: Arc<RuntimeConfig>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to do this? runtime config is part of genesis_config

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You'd have to clone it every time to wrap into Arc

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that you could implement it with lifetimes, but Arc is fine

Copy link
Contributor

Choose a reason for hiding this comment

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

Lifetimes tend to poison code. It is better if we first solidify our codebase with smart pointers and then switch to references.

@@ -113,6 +114,7 @@ impl EpochInfoProvider for SafeEpochManager {
/// TODO: this possibly should be merged with the runtime cargo or at least reconciled on the interfaces.
pub struct NightshadeRuntime {
genesis_config: GenesisConfig,
genesis_runtime_config: Arc<RuntimeConfig>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that you could implement it with lifetimes, but Arc is fine

Copy link
Contributor

@MaksymZavershynskyi MaksymZavershynskyi left a comment

Choose a reason for hiding this comment

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

Some nits.
It is unclear what RuntimeConfig::from_protocol_version is for.

core/runtime-configs/src/lib.rs Show resolved Hide resolved
@@ -113,6 +114,7 @@ impl EpochInfoProvider for SafeEpochManager {
/// TODO: this possibly should be merged with the runtime cargo or at least reconciled on the interfaces.
pub struct NightshadeRuntime {
genesis_config: GenesisConfig,
genesis_runtime_config: Arc<RuntimeConfig>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Lifetimes tend to poison code. It is better if we first solidify our codebase with smart pointers and then switch to references.

@evgenykuzyakov evgenykuzyakov merged commit 51de112 into master Oct 12, 2020
@evgenykuzyakov evgenykuzyakov deleted the update-fees-config branch October 12, 2020 17:54
olonho pushed a commit that referenced this pull request Oct 15, 2020
Move `RuntimeConfig` from `Runtime` initialization to `ApplyState` object.
This makes `Runtime` completely stateless and allows to execute transitions based on different configs.
It allows to upgrade `RuntimeConfig` with the new fees based on the protocol version for the current block.

This change should be NOOP and doesn't change the protocol. 

NEP: near/NEPs#120
Issue: #3158

# Test plan:

- [X] CI
- [x] http://nayduck.eastus.cloudapp.azure.com:3000/#/run/553
olonho pushed a commit that referenced this pull request Oct 19, 2020
Move `RuntimeConfig` from `Runtime` initialization to `ApplyState` object.
This makes `Runtime` completely stateless and allows to execute transitions based on different configs.
It allows to upgrade `RuntimeConfig` with the new fees based on the protocol version for the current block.

This change should be NOOP and doesn't change the protocol. 

NEP: near/NEPs#120
Issue: #3158

# Test plan:

- [X] CI
- [x] http://nayduck.eastus.cloudapp.azure.com:3000/#/run/553
chefsale pushed a commit that referenced this pull request Oct 19, 2020
Move `RuntimeConfig` from `Runtime` initialization to `ApplyState` object.
This makes `Runtime` completely stateless and allows to execute transitions based on different configs.
It allows to upgrade `RuntimeConfig` with the new fees based on the protocol version for the current block.

This change should be NOOP and doesn't change the protocol. 

NEP: near/NEPs#120
Issue: #3158

# Test plan:

- [X] CI
- [x] http://nayduck.eastus.cloudapp.azure.com:3000/#/run/553
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.

5 participants