-
Notifications
You must be signed in to change notification settings - Fork 83
Register in Random Beacon's Sortition Pool #3028
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
Conversation
0182690 to
688277b
Compare
fb2ae37 to
05c030f
Compare
We export Ethereum Chain handle to use in other packages as we are aiming for packages structure refactoring and we expect to use the common chain handle in multiple modules. We also renamed the struct to `Chain` as it's defined in `ethereum` pacakge and will be used externally as `ethereum.Chain`, which is better than `ethereum.EthereumChain`.
We need getters for chain handle properites to be able to use them in other packages raleted to chain integration.
Implemented chain handle for Random Beacon's Sortition Pool contract.
The interface should be used by the beacon and ecdsa handles to run sortition pool related functions.
Implement functions for sortition pool in the random beacon's handle.
If we need to fetch the config for V2 we need to implement this function again.
We need to update the code for V2
The code is based on keep-ecdsa register.go code, with some improvements. We want the operator to join the sortition pool if it's eligible and the operator is registered by a staking provider.
Start sortition pool registration once a client starts.
05c030f to
cf474f0
Compare
This is a common package that will be used by beacon and ecdsa modules.
902ab51 to
d31e60a
Compare
When pool is locked operators cannot join it.
| // "is correct and it has KEEP tokens delegated and the operator " + | ||
| // "contract has been authorized to operate on the stake", | ||
| // ) | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove it. It is hard to say what we should wait for here - stake, authorization, or maybe staking provider<>operator mapping?
| chainProvider, | ||
| netProvider, | ||
| persistence, | ||
| beaconChainHandle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing it as a separate parameter, I would replace ThresholdRelay() in chain.Handle with this interface. In case it is too complicated to replace ThresholdRelay() now, I would introduce it next to ThresholdRelay() and deprecated ThresholdRelay() use.
| @@ -1 +1 @@ | |||
| This directory contains legacy code from V1. It should be removed. | |||
| This directory contains legacy code from V1. It should be moved to fit the new directories structure. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would clear up this directory and remove everything that is not needed for v2, assuming there is a way to make the compilation pass.
| ec := ðereumChain{ | ||
| config: config, | ||
| c := &Chain{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two questions:
- Why not keep it as
ethereumChainand haveethereumBeaconChainandethereumEcdsaChain? I think it's easier to navigate through implementation files when it's implicitly denoted this is Ethereum implementation. - Why do we export it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was exported as it's used under random beacon's ethereum handle:
https://github.com/keep-network/keep-core/blob/fcc72bc88d90c714564caec45d60fe0e2b43b984/pkg/chain/random-beacon/ethereum.go#L23-L24
I'm open to other approaches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was made in the initial implementation approach I've taken for this PR to reuse common Ethereum chain implementation in the random beacon and ecdsa packages, along with keeping it functional for the legacy code.
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.Chain` handle 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.Address` type based on `string` is 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 in `Signing` interface, but `string` seems easier to use in most cases. Last but not least, a local implementation of `sortition.Chain` handle 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.
|
I'm a bit lost with the chain package structure we aim for. Especially, I don't understand the point of declaring upfront interfaces in the same package as the implementation of that interface. That seems to match more the Java-style than the Go-style interfaces. There are also some issues with that approach, for example:
That said, I'm wondering whether we shouldn't go with something like:
What are your thoughts guys? |
|
I think your proposal makes sense but I also see some advantages of keeping chain implementations per module. I think we need to do some more experimentation and then discuss one more time before we decide to go this way or another. A couple of quick thoughts: Yes, keeping In my opinion, the problem with On the other hand, I think that instantiating one handle and then passing it everywhere is easier than instantiating multiple per-module handles that can even depend on each other. Also, using a set of common functions should be easier with a single handle, as you say. Regardless of the decision here, I think keeping |
Closes: #3006
Depends on: #3016
In this PR we register an operator in the Random Beacon's Sortition Pool.
We introduced a
sortitionpackage that defines a function for registration in the sortition pool. The package defines an interface for sortition pool-related functions that should be implemented by the contract handle (in this case RandomBeacon, but later we will have to do the same for WalletRegistry).