feat(DVM) Add arbitrary data to price requests#2229
Conversation
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
| { t: "int", v: request.salt }, | ||
| { t: "address", v: request.account }, | ||
| { t: "uint", v: request.time }, | ||
| { t: "bytes", v: "0x" }, |
There was a problem hiding this comment.
This change makes all downstream usages of EncryptionHelper work be default; with nothing other than this blank ancillary data.
There was a problem hiding this comment.
For now, we will simply not support ancillary data in the voter dapp.
| OracleAncillaryInterface, | ||
| VotingInterface, | ||
| VotingAncillaryInterface | ||
| { |
There was a problem hiding this comment.
the Voting contract now considers the two new interfaces that define the Ancillary voting data.
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
…/protocol into chrismaree/arbitary-dvm-data
|
|
||
| async function decodeAllActiveGovernorProposals(artifacts, web3) { | ||
| const Voting = artifacts.require("Voting"); | ||
| const voting = await Voting.deployed(); |
There was a problem hiding this comment.
This is basically the ripple change throughout the repo to force Truffle to use the overloaded methods (without the ancillary data prop).
To remove this we need to make all downstream tests and infrastructure consider only the ancillary methods and then we can desperate the overloaded method. This will enable us to roll back these test changes.
| * @return roundId defined as a function of the currentTime and `phaseLength` from `data`. | ||
| */ | ||
| function computeCurrentRoundId(Data storage data, uint256 currentTime) internal view returns (uint256) { | ||
| uint256 roundLength = data.phaseLength.mul(uint256(VotingInterface.Phase.NUM_PHASES_PLACEHOLDER)); |
There was a problem hiding this comment.
Unfortunately, some state had to move to the VotingAncillaryInterface to get the inheritance tree to compile correctly with truffle.
| * @param commits array of structs that encapsulate an `identifier`, `time`, `hash` and optional `encryptedVote`. | ||
| */ | ||
| function batchCommit(Commitment[] calldata commits) external virtual; | ||
| function batchCommit(Commitment[] memory commits) public virtual; |
There was a problem hiding this comment.
this needed to become public to enable calling internally for the override method.
| ***********************************/ | ||
|
|
||
| console.log("0. SETUP PHASE"); | ||
| const voting = await Voting.deployed(); |
There was a problem hiding this comment.
this was not added to the umip upgrade scripts clearly but is added to the vote related ones.
| ); | ||
| } | ||
|
|
||
| function computeVoteHashAncillary(request) { |
There was a problem hiding this comment.
however, I did add a method and tests to verify the behavior works as expected.
mrice32
left a comment
There was a problem hiding this comment.
@chrismaree, this is awesome! Big +1. Contracts/prod code all look great! I left a few pretty minor comments -- more as just mental notes for us to think about down the road.
Will move on to the tests, etc.
| // The index in the `pendingPriceRequests` that references this PriceRequest. A value of UINT_MAX means that | ||
| // this PriceRequest is resolved and has been cleaned up from `pendingPriceRequests`. | ||
| uint256 index; | ||
| bytes ancillaryData; |
There was a problem hiding this comment.
In some later version, we should probably think about ways to redesign our DVM to not rely on any of this being stored on chain, and instead only using an initial event emission + hash stored on chain.
There was a problem hiding this comment.
I agree. ideally, emit the ancillaryData and just refer to a hash of it on-chain. This is a complexity trade-off that I think we leave for later though.
| * @param reveals array of the Reveal struct which contains an identifier, time, price and salt. | ||
| */ | ||
| function batchReveal(Reveal[] calldata reveals) external override { | ||
| function batchReveal(RevealAncillary[] memory reveals) public override { |
There was a problem hiding this comment.
Wow, I forgot about all of these methods.
| ); | ||
| } | ||
|
|
||
| function computeVoteHashAncillary(request) { |
| { t: "int", v: request.salt }, | ||
| { t: "address", v: request.account }, | ||
| { t: "uint", v: request.time }, | ||
| { t: "bytes", v: "0x" }, |
| { t: "int", v: request.salt }, | ||
| { t: "address", v: request.account }, | ||
| { t: "uint", v: request.time }, | ||
| { t: "bytes", v: "0x" }, |
There was a problem hiding this comment.
Do the following hashes match?
// pseudocode
sha3(uint(5), uint(6));
sha3(uint(5), byes(0), uint(6));
If not, we need to be careful about releasing the common package as it will likely break compatibility with the current voting contract, right?
There was a problem hiding this comment.
Update: they do seem to match (although someone else should verify :)). Very cool. In that case, is the "0x" element here basically just documentation to show that we're not leaving the value out?
There was a problem hiding this comment.
yup, it shows we are leaving it out. it also mimics exactly how the hash is generated on-chain in revealVote(identifier, time, price, "", salt); with the blank string for the bytes type. When decoded this "" translates to 0x
There was a problem hiding this comment.
It's really really nice that a 0 length data is perfectly backwards compatible when doing tight packing 👌
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
mrice32
left a comment
There was a problem hiding this comment.
Tests look awesome. A few very minor comments/nits
| const identifier2 = web3.utils.utf8ToHex("request-retrieval2"); | ||
| const time2 = "2000"; | ||
| const ancillaryData2 = web3.utils.utf8ToHex(`callerAddress:${account4}`); // ancillary data should be able to store addresses |
There was a problem hiding this comment.
nit: I think it would make this test slightly better if we made the identifier and timestamp match between both requests and only have the data differ. Then, this test would verify that the DVM correctly differentiates.
Thoughts? I think it would only require us to set identifier2 and time2 to identifier1 and time1 on these lines.
There was a problem hiding this comment.
good call. Have updated the tests accordingly and added a comment to explain why.
Co-authored-by: Matt Rice <matthewcrice32@gmail.com>
Signed-off-by: Christopher Maree <christopher.maree@gmail.com>
Motivation
issue: #2234
This PR adds the ability for the DVM to accept any arbitrary data as part of a price request.
Summary
Briefly summarize what changes were made to accomplish the motivation above.
Details
This is done by accepting an
bytes ancillaryDatainto the dvm price requests.Issue(s)
Fixes 2234