-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Runtime Epoch Split] (2/n) Narrow EpochManagerAdapter error type to …
…EpochError wherever possible. (#8767) As a reminder of the overall goal, we want to split `RuntimeWithEpochManagerAdapter`, so that any code that needs the runtime will use an `Arc<RuntimeAdapter>`, and any code that uses the epoch manager will use the `EpochManagerHandle`. We're doing this refactoring bottom-up, i.e. propagating `RuntimeWithEpochManagerAdapter` around at the top-level, but making some lower-level components use `Arc<RuntimeAdapter>` and/or `EpochManagerHandle`. That means we need to be able to obtain an `Arc<RuntimeAdapter>` and an `EpochManagerHandle` from a `RuntimeWithEpochManagerAdapter`. However, this is not trivial at all: 1. `KeyValueRuntime`, the implementation of `RuntimeWithEpochManagerAdapter` for testing, does not contain an `EpochManager` at all, so it's not possible to extract an `EpochManagerHandle` from it (which is essentially an arc mutex of `EpochManager`). That means instead of using `EpochManagerHandle`, we need to use `Arc<EpochManagerAdapter>` in the meantime. 2. Extracting an `Arc<EpochManagerAdapter>` from a `Arc<RuntimeWithEpochManagerAdapter>` is not trivial. Even though `RuntimeWithEpochManagerAdapter` is a trait that extends `EpochManagerAdapter`, trait upcast is not allowed by Rust in general. So we need to resort to a workaround. This PR addresses an issue arising from (1), that current code that expects an `EpochManagerHandle` uses functions from `EpochManager` which mostly returns `EpochError`. `EpochManagerAdapter`, on the other hand, returns mostly `near_chain_primitive::Error`, so changing to the adapter type breaks existing code. So, in this PR we are changing the error type returned from most of the `EpochManagerAdapter` functions to also be EpochError. This is a pretty painless transition, except in some cases we need to do a two-hop conversion from `EpochError` to chain `Error` and then to some other error (and two-hop conversions cannot be supported by `.into()` in general), so I've defined `.into_chain_error()` to help with the two-hop conversion cases.
- Loading branch information
1 parent
6c1a516
commit dc8f61c
Showing
10 changed files
with
238 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.