-
Notifications
You must be signed in to change notification settings - Fork 628
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
Figure out what to do with EpochManager medium-term #6910
Comments
Note: while we probably want struct Chain {
em: EpochManager
} this probably won't work right of the bat, as today we use separte chains but shared em for view client and client. So we should start with struct Chain {
em: Arc<Mutex<EpochManager>>,
} Getting to end-state would require redesigning our client/view-client split. |
More specific plan:
nearcore/nearcore/src/runtime/mod.rs Lines 80 to 91 in 161bf79
At this stage, we should reach the situation where runtime, view client and clinet all have separate At this point, we are done. Runtime (as in NighthsadeRuntime & RuntimeAdapter) doesn't have access to EpochManager. Clinet and ViewCLient share the same EpcohManager object, just like they used to before refactor Future steps:
|
The mechanical change here is rather small: rename SafeEpochManager to EpochManagerHandle, and move it from nearcore to epoch_manager crate. The architectural implications are rather large in contrast. What I aim to do eventually is to remove EpochManager from RuntimeAdapter trait and instead force everyone who needs em to hold EpochManagerHandle, rather than dyn RuntimeAdapter. That way, the RuntimeAdapter would become essentially stateless, and the shared mutable state of epoch manager would be explicitly accounted for. work towards near#6910
The mechanical change here is rather small: rename SafeEpochManager to EpochManagerHandle, and move it from nearcore to epoch_manager crate. The architectural implications are rather large in contrast. What I aim to do eventually is to remove EpochManager from RuntimeAdapter trait and instead force everyone who needs em to hold EpochManagerHandle, rather than dyn RuntimeAdapter. That way, the RuntimeAdapter would become essentially stateless, and the shared mutable state of epoch manager would be explicitly accounted for. work towards near#6910
The mechanical change here is rather small: rename SafeEpochManager to EpochManagerHandle, and move it from nearcore to epoch_manager crate. The architectural implications are rather large in contrast. What I aim to do eventually is to remove EpochManager from RuntimeAdapter trait and instead force everyone who needs em to hold EpochManagerHandle, rather than dyn RuntimeAdapter. That way, the RuntimeAdapter would become essentially stateless, and the shared mutable state of epoch manager would be explicitly accounted for. work towards near#6910
The mechanical change here is rather small: rename SafeEpochManager to EpochManagerHandle, and move it from nearcore to epoch_manager crate. The architectural implications are rather large in contrast. What I aim to do eventually is to remove EpochManager from RuntimeAdapter trait and instead force everyone who needs em to hold EpochManagerHandle, rather than dyn RuntimeAdapter. That way, the RuntimeAdapter would become essentially stateless, and the shared mutable state of epoch manager would be explicitly accounted for. work towards #6910
We want `chain` to depend on epoch_manager, and, besides, `ValidatorInfoIdentifier` is a very stupid reason to have such a dep. context: near#6910
We want `chain` to depend on epoch_manager, and, besides, `ValidatorInfoIdentifier` is a very stupid reason to have such a dep. context: near#6910
We want `chain` to depend on epoch_manager, and, besides, `ValidatorInfoIdentifier` is a very stupid reason to have such a dep. context: near#6910
We want `chain` to depend on epoch_manager, and, besides, `ValidatorInfoIdentifier` is a very stupid reason to have such a dep. context: near#6910
We want `chain` to depend on epoch_manager, and, besides, `ValidatorInfoIdentifier` is a very stupid reason to have such a dep. context: near#6910
We want `chain` to depend on epoch_manager, and, besides, `ValidatorInfoIdentifier` is a very stupid reason to have such a dep. context: near#6910
TODOs for potential follow up:
|
We want `chain` to depend on epoch_manager, and, besides, `ValidatorInfoIdentifier` is a very stupid reason to have such a dep. Best reviewed by commit. context: #6910
Part of near#6910 The grand plan is to separate EpochManager out of NightshadeRuntime. As a first step, I want to separate the *types* of runtime and epoch manager, while keeping them in the same object. I want to do this via the following series of steps: ``` trait RuntimeAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter: EpochManagerAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter {} ``` This PR introduces the EpochManagerAdapter infra.
Part of near#6910 The grand plan is to separate EpochManager out of NightshadeRuntime. As a first step, I want to separate the *types* of runtime and epoch manager, while keeping them in the same object. I want to do this via the following series of steps: ``` trait RuntimeAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter: EpochManagerAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter {} ``` This PR introduces the EpochManagerAdapter infra. You can see the rough idea of the plan in near#7606
Part of near#6910 The grand plan is to separate EpochManager out of NightshadeRuntime. As a first step, I want to separate the *types* of runtime and epoch manager, while keeping them in the same object. I want to do this via the following series of steps: ``` trait RuntimeAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter: EpochManagerAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter {} ``` This PR introduces the EpochManagerAdapter infra. You can see the rough idea of the plan in near#7606
Part of near#6910 The grand plan is to separate EpochManager out of NightshadeRuntime. As a first step, I want to separate the *types* of runtime and epoch manager, while keeping them in the same object. I want to do this via the following series of steps: ``` trait RuntimeAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter: EpochManagerAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter {} ``` This PR introduces the EpochManagerAdapter infra. You can see the rough idea of the plan in near#7606
Part of near#6910 The grand plan is to separate EpochManager out of NightshadeRuntime. As a first step, I want to separate the *types* of runtime and epoch manager, while keeping them in the same object. I want to do this via the following series of steps: ``` trait RuntimeAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter: EpochManagerAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter {} ``` This PR introduces the EpochManagerAdapter infra. You can see the rough idea of the plan in near#7606
We want `chain` to depend on epoch_manager, and, besides, `ValidatorInfoIdentifier` is a very stupid reason to have such a dep. Best reviewed by commit. context: #6910
Part of #6910 The grand plan is to separate EpochManager out of NightshadeRuntime. As a first step, I want to separate the *types* of runtime and epoch manager, while keeping them in the same object. I want to do this via the following series of steps: ``` trait RuntimeAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter: EpochManagerAdapter {} ``` ``` trait EpochManagerAdapter {} trait RuntimeAdapter {} ``` This PR introduces the EpochManagerAdapter infra. You can see the rough idea of the plan in #7606
Today, we store EpochManager in NightshadeRuntie and access it via RuntimeAdapter.
This is awkward – EpochManager is very stateful, while runtime ideally shouldn't be. It also logically doesn't feel right – runtime should not care about evolution of epoch, it should exist within scope of one chunk.
The historical context is that we had plans to move EpochManager on chain (#2745).
I think we should just move EpochManager to chain:
that is, even if epoch manager lives on chain, runtime shouldn't know specifics of it, it should expose just a general hook to run arbitrary contract. It would be up to Chain to run that and interpret inputs/outputs as borsh-encoded epoch data.
There's additional, deep reason to move epoch manager to Chain – testing. Today, Chain is separated from Runtime via RuntimeAdapter. For testing purposes, it uses KeyValueRuntime, a simplistic runtime which can only process transfer transactions. However, as KeyValueRuntime lacks a true EpochManager, epoch-dependent tests have to be integration and have to use NightshadeRuntime.
Current status:
We now have EpochManagerAdapter which contains almost all of the stuff that EpcohManager does. At the moment, we still have
RuntimeAdapter: EpochManagerAdapter
. The next step is to remove that super-trait bound! that means that initiallyChain
would get awhich initially would point at the same object in memory.
The text was updated successfully, but these errors were encountered: