-
Notifications
You must be signed in to change notification settings - Fork 290
feat(entropy): Event V2 spec #2621
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,10 @@ abstract contract Entropy is IEntropy, EntropyState { | |
|
||
provider.sequenceNumber += 1; | ||
|
||
emit Registered(EntropyStructConverter.toV1ProviderInfo(provider)); | ||
emit EntropyEvents.Registered( | ||
EntropyStructConverter.toV1ProviderInfo(provider) | ||
); | ||
emit EntropyEventsV2.Registered(msg.sender, bytes("")); | ||
} | ||
|
||
// Withdraw a portion of the accumulated fees for the provider msg.sender. | ||
|
@@ -172,7 +175,13 @@ abstract contract Entropy is IEntropy, EntropyState { | |
(bool sent, ) = msg.sender.call{value: amount}(""); | ||
require(sent, "withdrawal to msg.sender failed"); | ||
|
||
emit Withdrawal(msg.sender, msg.sender, amount); | ||
emit EntropyEvents.Withdrawal(msg.sender, msg.sender, amount); | ||
emit EntropyEventsV2.Withdrawal( | ||
msg.sender, | ||
msg.sender, | ||
amount, | ||
bytes("") | ||
); | ||
} | ||
|
||
function withdrawAsFeeManager( | ||
|
@@ -202,7 +211,13 @@ abstract contract Entropy is IEntropy, EntropyState { | |
(bool sent, ) = msg.sender.call{value: amount}(""); | ||
require(sent, "withdrawal to msg.sender failed"); | ||
|
||
emit Withdrawal(provider, msg.sender, amount); | ||
emit EntropyEvents.Withdrawal(provider, msg.sender, amount); | ||
emit EntropyEventsV2.Withdrawal( | ||
provider, | ||
msg.sender, | ||
amount, | ||
bytes("") | ||
); | ||
} | ||
|
||
// requestHelper allocates and returns a new request for the given provider. | ||
|
@@ -349,6 +364,13 @@ abstract contract Entropy is IEntropy, EntropyState { | |
userRandomNumber, | ||
EntropyStructConverter.toV1Request(req) | ||
); | ||
emit EntropyEventsV2.Requested( | ||
provider, | ||
req.requester, | ||
req.sequenceNumber, | ||
userRandomNumber, | ||
bytes("") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we include more info like gasLimit from the getgo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a follow up with this (and actual gas usage) ready to go after this is merged. |
||
); | ||
return req.sequenceNumber; | ||
} | ||
|
||
|
@@ -570,6 +592,15 @@ abstract contract Entropy is IEntropy, EntropyState { | |
providerRevelation, | ||
randomNumber | ||
); | ||
emit EntropyEventsV2.Revealed( | ||
provider, | ||
req.requester, | ||
req.sequenceNumber, | ||
randomNumber, | ||
false, | ||
ret, | ||
bytes("") | ||
); | ||
clearRequest(provider, sequenceNumber); | ||
} else if ( | ||
ret.length > 0 || | ||
|
@@ -590,6 +621,15 @@ abstract contract Entropy is IEntropy, EntropyState { | |
randomNumber, | ||
ret | ||
); | ||
emit EntropyEventsV2.Revealed( | ||
provider, | ||
req.requester, | ||
sequenceNumber, | ||
randomNumber, | ||
true, | ||
ret, | ||
bytes("") | ||
); | ||
req.callbackStatus = EntropyStatusConstants.CALLBACK_FAILED; | ||
} else { | ||
// Callback reverted by (potentially) running out of gas, but the calling context did not have enough gas | ||
|
@@ -608,6 +648,15 @@ abstract contract Entropy is IEntropy, EntropyState { | |
providerRevelation, | ||
randomNumber | ||
); | ||
emit EntropyEventsV2.Revealed( | ||
provider, | ||
req.requester, | ||
req.sequenceNumber, | ||
randomNumber, | ||
false, | ||
bytes(""), | ||
bytes("") | ||
); | ||
|
||
clearRequest(provider, sequenceNumber); | ||
|
||
|
@@ -732,6 +781,12 @@ abstract contract Entropy is IEntropy, EntropyState { | |
uint128 oldFeeInWei = provider.feeInWei; | ||
provider.feeInWei = newFeeInWei; | ||
emit ProviderFeeUpdated(msg.sender, oldFeeInWei, newFeeInWei); | ||
emit EntropyEventsV2.ProviderFeeUpdated( | ||
msg.sender, | ||
oldFeeInWei, | ||
newFeeInWei, | ||
bytes("") | ||
); | ||
} | ||
|
||
function setProviderFeeAsFeeManager( | ||
|
@@ -754,6 +809,12 @@ abstract contract Entropy is IEntropy, EntropyState { | |
providerInfo.feeInWei = newFeeInWei; | ||
|
||
emit ProviderFeeUpdated(provider, oldFeeInWei, newFeeInWei); | ||
emit EntropyEventsV2.ProviderFeeUpdated( | ||
provider, | ||
oldFeeInWei, | ||
newFeeInWei, | ||
bytes("") | ||
); | ||
} | ||
|
||
// Set provider uri. It will revert if provider is not registered. | ||
|
@@ -767,6 +828,12 @@ abstract contract Entropy is IEntropy, EntropyState { | |
bytes memory oldUri = provider.uri; | ||
provider.uri = newUri; | ||
emit ProviderUriUpdated(msg.sender, oldUri, newUri); | ||
emit EntropyEventsV2.ProviderUriUpdated( | ||
msg.sender, | ||
oldUri, | ||
newUri, | ||
bytes("") | ||
); | ||
} | ||
|
||
function setFeeManager(address manager) external override { | ||
|
@@ -780,6 +847,12 @@ abstract contract Entropy is IEntropy, EntropyState { | |
address oldFeeManager = provider.feeManager; | ||
provider.feeManager = manager; | ||
emit ProviderFeeManagerUpdated(msg.sender, oldFeeManager, manager); | ||
emit EntropyEventsV2.ProviderFeeManagerUpdated( | ||
msg.sender, | ||
oldFeeManager, | ||
manager, | ||
bytes("") | ||
); | ||
} | ||
|
||
// Set the maximum number of hashes to record in a request. This should be set according to the maximum gas limit | ||
|
@@ -799,6 +872,12 @@ abstract contract Entropy is IEntropy, EntropyState { | |
oldMaxNumHashes, | ||
maxNumHashes | ||
); | ||
emit EntropyEventsV2.ProviderMaxNumHashesAdvanced( | ||
msg.sender, | ||
oldMaxNumHashes, | ||
maxNumHashes, | ||
bytes("") | ||
); | ||
} | ||
|
||
// Set the default gas limit for a request. | ||
|
@@ -817,6 +896,12 @@ abstract contract Entropy is IEntropy, EntropyState { | |
uint32 oldGasLimit = provider.defaultGasLimit; | ||
provider.defaultGasLimit = gasLimit; | ||
emit ProviderDefaultGasLimitUpdated(msg.sender, oldGasLimit, gasLimit); | ||
emit EntropyEventsV2.ProviderDefaultGasLimitUpdated( | ||
msg.sender, | ||
oldGasLimit, | ||
gasLimit, | ||
bytes("") | ||
); | ||
} | ||
|
||
function constructUserCommitment( | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
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 naming system seems a bit brittle (I think it's based on the order of the events in the file) but (1) the ABI ordering seems stable and (2) it's temporary anyway so i think it's fine.