| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // SPDX-License-Identifier: Apache 2
- pragma solidity ^0.8.0;
- contract EntropyStructs {
- struct ProviderInfo {
- uint128 feeInWei;
- uint128 accruedFeesInWei;
- // The commitment that the provider posted to the blockchain, and the sequence number
- // where they committed to this. This value is not advanced after the provider commits,
- // and instead is stored to help providers track where they are in the hash chain.
- bytes32 originalCommitment;
- uint64 originalCommitmentSequenceNumber;
- // Metadata for the current commitment. Providers may optionally use this field to to help
- // manage rotations (i.e., to pick the sequence number from the correct hash chain).
- bytes commitmentMetadata;
- // Optional URI where clients can retrieve revelations for the provider.
- // Client SDKs can use this field to automatically determine how to retrieve random values for each provider.
- // TODO: specify the API that must be implemented at this URI
- bytes uri;
- // The first sequence number that is *not* included in the current commitment (i.e., an exclusive end index).
- // The contract maintains the invariant that sequenceNumber <= endSequenceNumber.
- // If sequenceNumber == endSequenceNumber, the provider must rotate their commitment to add additional random values.
- uint64 endSequenceNumber;
- // The sequence number that will be assigned to the next inbound user request.
- uint64 sequenceNumber;
- // The current commitment represents an index/value in the provider's hash chain.
- // These values are used to verify requests for future sequence numbers. Note that
- // currentCommitmentSequenceNumber < sequenceNumber.
- //
- // The currentCommitment advances forward through the provider's hash chain as values
- // are revealed on-chain.
- bytes32 currentCommitment;
- uint64 currentCommitmentSequenceNumber;
- }
- struct Request {
- // Storage slot 1 //
- address provider;
- uint64 sequenceNumber;
- // The number of hashes required to verify the provider revelation.
- uint32 numHashes;
- // Storage slot 2 //
- // The commitment is keccak256(userCommitment, providerCommitment). Storing the hash instead of both saves 20k gas by
- // eliminating 1 store.
- bytes32 commitment;
- // Storage slot 3 //
- // The number of the block where this request was created.
- // Note that we're using a uint64 such that we have an additional space for an address and other fields in
- // this storage slot. Although block.number returns a uint256, 64 bits should be plenty to index all of the
- // blocks ever generated.
- uint64 blockNumber;
- // The address that requested this random number.
- address requester;
- // If true, incorporate the blockhash of blockNumber into the generated random value.
- bool useBlockhash;
- // There are 3 remaining bytes of free space in this slot.
- }
- }
|