-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: merkle verification and changes implemented #59
feat: merkle verification and changes implemented #59
Conversation
✅ Deploy Preview for razor-bridge-mainnet canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes requested
bytes memory signature | ||
) external onlyRole(FORWARDER_ROLE) returns (uint256, int8, uint256) { | ||
if (result.lastUpdatedTimestamp > _collectionResults[result.name].lastUpdatedTimestamp) { | ||
bytes memory resultBytes = abi.encode(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required
if (result.lastUpdatedTimestamp > _collectionResults[result.name].lastUpdatedTimestamp) { | ||
bytes memory resultBytes = abi.encode(result); | ||
bytes32 messageHash = keccak256( | ||
abi.encodePacked(merkleRoot, resultBytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just sign merkle root
) != signerAddress) revert InvalidSignature(); | ||
|
||
bytes32 leaf = keccak256( | ||
bytes.concat(keccak256(abi.encode(resultBytes))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result not resultbytes
emit ResultUpdated(result); | ||
} | ||
|
||
return _getResult(result.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In future optimization, add multiproof support.
|
||
emit BlockReceived(messageBlock); | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code repetition.
@@ -3,80 +3,31 @@ pragma solidity ^0.8.0; | |||
|
|||
interface IDelegator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change name to iforwarder
Problem statement:
The current implementation requires the signed Oracle block to be sent to the result manager to update collection values. This is not scalable and updating will become expensive as we add more collections to the Razor Oracle.
Solution:
We will be shifting to a Merkle tree implementation for updation in which the Merkle leaves will hold the result of each collection and the clients will receive signed result, Merkle root, and Merkle proof along with the signature for each collection depending on the collection data they require
To update the values of each collection, clients will need to query the Merkle tree for each collection off-chain which will be exposed through an API, and send the data received through their contracts to update the values. The clients will only need to update the collections they require for their application.
The functions exposed to clients will be:
fetchResult()
:- this function is responsible for updating the collection data and receiving the latest collection result. The result will only be updated if thelastUpdatedTimestamp
for a particular collection in the contracts precedes the one that is being sent over, else the result won't be updated and the client will receive the stored result in the contractsgetResult()
:- this is a view function where you will just receive the collection data stored in the contracts. It does not deal with updation and the results retrieved may be stalevalidateResult()
: this is a view function that allows people to validate whether the data they are receiving from the API is valid or not