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] Change provider interface to simplify supporting many chains #1149

Merged
merged 4 commits into from
Nov 27, 2023

Conversation

jayantk
Copy link
Contributor

@jayantk jayantk commented Nov 25, 2023

Currently, the Entropy contract has a single bytes32 field that providers can use to store arbitrary metadata associated with their hash chain. We're using this to store a random seed that the provider can use to regenerate the chain. However, the chain on the server is a function of both the random seed and a chain length parameter (and also a secret which of course isn't on the blockchain). Thus, at the moment, every blockchain must use the exact same chain length. This is brittle and will cause operational problems down the line when we need to manage different chains on many different chains.

This PR changes the field to be bytes and the providers can choose to store however much data they want in there. I also changed fortuna to store both the secret and the chain length.

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 25, 2023 10:30pm
xc-admin-frontend ⬜️ Ignored (Inspect) Visit Preview Nov 25, 2023 10:30pm

@@ -186,7 +186,6 @@ contract Entropy is IEntropy, EntropyState {
req.providerCommitment = providerInfo.currentCommitment;
req.providerCommitmentSequenceNumber = providerInfo
.currentCommitmentSequenceNumber;
req.providerCommitmentMetadata = providerInfo.commitmentMetadata;
Copy link
Contributor Author

@jayantk jayantk Nov 25, 2023

Choose a reason for hiding this comment

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

drive by: I deleted this field from req (it's not needed)

@@ -44,19 +44,14 @@ contract EntropyTest is Test {
random.register(
provider1FeeInWei,
provider1Proofs[0],
bytes32(keccak256(abi.encodePacked(uint256(0x0100)))),
hex"0100",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

drive-by: shorter way to write this

chain_id: &ChainId,
random: [u8; 32],
random: &[u8; 32],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think seed is a better name here.

@@ -1,45 +1,4 @@
[
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why these got deleted? :?

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.

Looks good! I left some minor inline comments.

@jayantk jayantk merged commit b7a089b into main Nov 27, 2023
7 checks passed
@jayantk jayantk deleted the random20_contract_abi_change branch November 27, 2023 15:39
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