| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- // SPDX-License-Identifier: Apache 2
- pragma solidity ^0.8.0;
- contract EntropyStructsV2 {
- 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 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;
- // An address that is authorized to set / withdraw fees on behalf of this provider.
- address feeManager;
- // Maximum number of hashes to record in a request. This should be set according to the maximum gas limit
- // the provider supports for callbacks.
- uint32 maxNumHashes;
- // Default gas limit to use for callbacks.
- uint32 defaultGasLimit;
- }
- 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;
- // Status flag for requests with callbacks. See EntropyConstants for the possible values of this flag.
- uint8 callbackStatus;
- // The gasLimit in units of 10k gas. (i.e., 2 = 20k gas). We're using units of 10k in order to fit this
- // field into the remaining 2 bytes of this storage slot. The dynamic range here is 10k - 655M, which should
- // cover all real-world use cases.
- uint16 gasLimit10k;
- }
- }
|