Interface and local implementation for sortition chain #3056
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.
Refs #3006
This change is greatly inspired by the work of @nkuba in #3028 but it is just a subset of the original work with some changes introduced.
First,
sortition.Chainhandle interface is introduced. In opposite to v1 approach, where we had a global chain handle, the new proposed approach is to keep a chain handle per module. This should make the chain code less complicated and allow introducing custom behavior to functions, if needed be the logic of the given module.Second,
chain.Addresstype based onstringis introduced. We need a chain-agnostic implementation of a chain address to use in interfaces. So far, it's been an array of bytes, as presented inSigninginterface, butstringseems easier to use in most cases.Last but not least, a local implementation of
sortition.Chainhandle is introduced.Also, a set of simple test utils for assertions is added. Most of the time, such simple assertions are all we need, and having them extracted to a single place lets us avoid the assertion error message formatting boilerplate in test files. Long-term, if needed, we may use some more sophisticated assertion library.