Skip to content
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

[entropy] Add a default provider #1150

Merged
merged 7 commits into from
Nov 28, 2023
Merged

[entropy] Add a default provider #1150

merged 7 commits into from
Nov 28, 2023

Conversation

jayantk
Copy link
Contributor

@jayantk jayantk commented Nov 25, 2023

The current interface forces users to pick a provider. This is awkward when there's really only one provider initially. This PR lets governance choose a default and adds some convenience methods for invoking the request/reveal flow with the default. This should simplify things for most users.

Copy link

vercel bot commented Nov 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
example-oracle-amm ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2023 10:26pm
xc-admin-frontend ⬜️ Ignored (Inspect) Visit Preview Nov 27, 2023 10:26pm

@@ -64,7 +65,9 @@ contract EntropyTest is Test {
uint64 startSequenceNumber,
uint64 size
) public pure returns (bytes32[] memory hashChain) {
bytes32 initialValue = keccak256(abi.encodePacked(startSequenceNumber));
bytes32 initialValue = keccak256(
abi.encodePacked(provider, startSequenceNumber)
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 was a bug in previous versions where the hash chains for both providers were exactly the same. turns out i wasn't using provider2's hash chain in any of the other tests though.

Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

While in solidity it is allowed to have multiple functions with same name and different signatures I have found that the explorers (etherscan) and client libraries (ethers, web3) are not good at handling them. For example they struggle to understand which request does contract.methods.request refers to and you need to use something like contract.methods["request(bytes32,bool)"].call.... So I recommend using different function names for the default ones.

@jayantk
Copy link
Contributor Author

jayantk commented Nov 27, 2023

Update to this PR here. I decided it doesn't make sense to create other versions of request/reveal/getFee if they can't share the same name. Instead, people can just call request(getDefaultProvider(), ...) to get the default.

I also added a uri parameter for each provider. The idea here is to let the blockchain serve as the registry that maps providers -> where you can retrieve their random numbers. I have not yet specified the expected API that clients should expect at this URI, but we can do that later when we develop client libraries.

Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

Nice!

@@ -68,6 +80,7 @@ contract EntropyTest is Test {
}

// Test helper method for requesting a random value as user from provider.
// If provider is all-zeros, use the default provider in the contract.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you actually using it? I'm not seeing this be implemented too :?

@jayantk jayantk merged commit a5646bf into main Nov 28, 2023
@jayantk jayantk deleted the random23_other_abi_change branch November 28, 2023 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants