Investigate (showcase) some design tweaks around Validation/Execution contexts #464
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to: #325
Description
This PR aims to suggest possible ways to refactor ValidationContext/ExecutionContext for improved maintainability and intended to make the design more accessible to implementers.
Overall, two ideas have been incorporated into this PR (applied to some parts as a showcase), each of which could be investigated and implemented separately:
ValidationContext
andExecutionContext
methods under the below traits/groups(note that the exact placement of some methods may need to be discussed)
trait HostContext bonded by Router
Provides a minimal set of interfaces that must be provided by an IBC-enabled blockchain. It contains methods that read or write a host state BUT are not accessible through the IBC path from the key-value store and also includes operational methods.
Note that this trait is very similar to the ADR-5 defined Host-based API
trait ReaderContext bonded by HostContext
Provides methods that enable access to states that can be retrieved from the key-value stores through the IBC path.
trait KeeperContext bonded by ReaderContext
Provides methods that enable setting states in a key-value store and performed via the IBC path.
trait EventLogger & MsgLogger
Provides event emitting and message logging facilities (read & write)
validate
andexecute
methods from the validation/execution context and place them under two distinctpub(crate) ValidationHandler<Msg>
andpub(crate) ExecutionHandler<Msg>
interfaces.These traits have been implemented (Blanket) for each message type for contexts implementing
ReaderContext
andKeeperContext
.PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.