-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KeystoneForwarder: Test basic functionality
- Loading branch information
Showing
6 changed files
with
94 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
KeystoneForwarderTest:test_abi_partial_decoding_works() (gas: 2068) | ||
KeystoneForwarderTest:test_it_works() (gas: 1026676) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// solhint-disable custom-errors | ||
library Utils { | ||
// solhint-disable avoid-low-level-calls, chainlink-solidity/explicit-returns | ||
function splitSignature(bytes memory sig) public pure returns (bytes32 r, bytes32 s, uint8 v) { | ||
require(sig.length == 65, "invalid signature length"); | ||
|
||
assembly { | ||
/* | ||
First 32 bytes stores the length of the signature | ||
add(sig, 32) = pointer of sig + 32 | ||
effectively, skips first 32 bytes of signature | ||
mload(p) loads next 32 bytes starting at the memory address p into memory | ||
*/ | ||
|
||
// first 32 bytes, after the length prefix | ||
r := mload(add(sig, 32)) | ||
// second 32 bytes | ||
s := mload(add(sig, 64)) | ||
// final byte (first byte of the next 32 bytes) | ||
v := byte(0, mload(add(sig, 96))) | ||
} | ||
|
||
// implicitly return (r, s, v) | ||
} | ||
|
||
// solhint-disable avoid-low-level-calls, chainlink-solidity/explicit-returns | ||
function splitReport(bytes memory rawReport) public pure returns (bytes32 workflowId, bytes32 workflowExecutionId) { | ||
require(rawReport.length > 64, "invalid report length"); | ||
assembly { | ||
// skip first 32 bytes, contains length of the report | ||
workflowId := mload(add(rawReport, 32)) | ||
workflowExecutionId := mload(add(rawReport, 64)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters