-
Notifications
You must be signed in to change notification settings - Fork 76
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
Upgradeable contract components implementation #773
Conversation
First step as part of the refactoring this contract as immutable back-end for the random beacon. Removing getters for the constants since these are now auto-generated from public variables.
4e39d06
to
46b0618
Compare
Backend contract should not track beacon entries and only needs to hold the last entry used as a selection seed for the next group selection run.
This is useful in case of using specific stub contracts in tests.
Use 'before' instead of 'beforeEach' where possible.
This contract is not used by the Keep client, CLI for relay requests has been implemented with truffle scripts and located in `contract/scripts`.
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.
Thanks for going through all of the infra config files.
Based on what I'm seeing here once this is merged keep-dev
should get provisioned properly. I'll fire a relay request once I see this deployment go out.
For keep-test
we'll need to be a bit more careful on rolling this out since external parties have as-is configuration files. Once keep-dev is proven to be kosher I'll make the arrangements for keep-test
.
Did not mean to add that label - sorry. |
It may be worth running a |
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.
@ngrinkevich I think I accepted the fact of the existence of separate request counters, especially that I can't propose any better alternative, not counting a separate counter contract which I am not sure if is any better. 😉
Let's work on naming a little - use requestId
everywhere consistently in the service contract and have signingId
in the operator contract just like you proposed. I also think we should avoid duplicating the state about the number of groups between service and operator contract as it always hurts long-term and I do not see any security reason for doing it. Other than that, I think some events can be removed.
I left a lot of comments but most of them are about proposed renames. I think we are really close to merging it.
// to trigger the creation of the first group. Requests are removed on successful | ||
// entries so genesis entry can only be called once. | ||
requestCounter++; | ||
requests[requestCounter] = Request(0, 0, _genesisGroupPubKey, _serviceContract); |
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.
Shouldn't we use 1
instead of 0
for requestID
? Service contract increses the counter before calling sign
so if we were sending this request through the service contract, we'd start with 1
.
An alternative could be to store this request under signingId = 0
, that is, to do not increment requestCounter
in the previous line. It could make sense since it's a special - seed - request and we may want to differentiate it as such.
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.
Still not addressed.
We have decided to query operator contracts instead to avoid duplicated storage.
Setting new group size should only be possible in the event of contract upgrade.
Using <noun><action> naming for consistency.
emit RelayEntryGenerated(requestId, entry); | ||
|
||
if (_callbacks[requestId].callbackContract != address(0)) { | ||
_callbacks[requestId].callbackContract.call(abi.encodeWithSignature(_callbacks[requestId].callbackMethod, entry)); |
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.
/Users/piotr/go/src/github.com/keep-network/keep-core/contracts/solidity/contracts/KeepRandomBeaconServiceImplV1.sol:144:13: Warning: Return value of low-level calls not used.
_callbacks[requestId].callbackContract.call(abi.encodeWithSignature(_callbacks[requestId].callbackMethod, entry));
^---------------------------------------------------------------------------------------------------------------^
Tested
Tested relay request with no callback, works as expected:
Tested relay request with callback, works as expected:
|
Things that still need to be addressed in separate PRs:
|
I left some comments but they are all non-blocking. I'll try to address some of them in a separate PR today. |
Refs #802
Implements RFC5 upgradeable contract components scheme. Adds minor refactoring to reduce the amount of repeated code.
Further additions required to fully match RFC5, saving these for a separate PR:
createGroup()
method on Operator contractrequestRelayEntry()