Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/fortuna/src/chain/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<T: JsonRpcClient + 'static + Clone> SignablePythContractInner<T> {
{
// Extract Log from TransactionReceipt.
let l: RawLog = r.logs[0].clone().into();
if let PythRandomEvents::RequestedFilter(r) = PythRandomEvents::decode_log(&l)? {
Copy link
Contributor Author

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.

if let PythRandomEvents::Requested1Filter(r) = PythRandomEvents::decode_log(&l)? {
Ok(r.request.sequence_number)
} else {
Err(anyhow!("No log with sequence number"))
Expand Down Expand Up @@ -147,7 +147,7 @@ impl<T: JsonRpcClient + 'static + Clone> SignablePythContractInner<T> {
.await?
.await?
{
if let PythRandomEvents::RevealedFilter(r) =
if let PythRandomEvents::Revealed1Filter(r) =
PythRandomEvents::decode_log(&r.logs[0].clone().into())?
{
Ok(r.random_number)
Expand Down
91 changes: 88 additions & 3 deletions target_chains/ethereum/contracts/contracts/entropy/Entropy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -349,6 +364,13 @@ abstract contract Entropy is IEntropy, EntropyState {
userRandomNumber,
EntropyStructConverter.toV1Request(req)
);
emit EntropyEventsV2.Requested(
provider,
req.requester,
req.sequenceNumber,
userRandomNumber,
bytes("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we include more info like gasLimit from the getgo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
}

Expand Down Expand Up @@ -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 ||
Expand All @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -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(
Expand All @@ -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.
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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(
Expand Down
Loading
Loading