Skip to content

Commit

Permalink
Keystone refactoring (#12880)
Browse files Browse the repository at this point in the history
* Try a simple change

* Regenerate keystone wrappers

* Add changesets

* Remove Keystone gas tests

* Remove parenthesis
  • Loading branch information
DeividasK authored Apr 18, 2024
1 parent 6991af2 commit 8337fc8
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-rockets-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#wip Keystone wrapper regenerate
2 changes: 1 addition & 1 deletion .github/workflows/solidity-foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
FOUNDRY_PROFILE: ${{ matrix.product }}

- name: Run Forge snapshot
if: ${{ !contains(fromJson('["vrf"]'), matrix.product) && !contains(fromJson('["automation"]'), matrix.product) && needs.changes.outputs.changes == 'true' }}
if: ${{ !contains(fromJson('["vrf"]'), matrix.product) && !contains(fromJson('["automation"]'), matrix.product) && !contains(fromJson('["keystone"]'), matrix.product) && needs.changes.outputs.changes == 'true' }}
run: |
forge snapshot --nmt "testFuzz_\w{1,}?" --check gas-snapshots/${{ matrix.product }}.gas-snapshot
id: snapshot
Expand Down
5 changes: 5 additions & 0 deletions contracts/.changeset/mean-items-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chainlink/contracts": patch
---

#wip Keystone custom error
2 changes: 0 additions & 2 deletions contracts/gas-snapshots/keystone.gas-snapshot

This file was deleted.

12 changes: 11 additions & 1 deletion contracts/src/v0.8/keystone/KeystoneForwarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import {Utils} from "./libraries/Utils.sol";
contract KeystoneForwarder is IForwarder, ConfirmedOwner, TypeAndVersionInterface {
error ReentrantCall();

/// @notice This error is returned when the data with report is invalid.
/// This can happen if the data is shorter than SELECTOR_LENGTH + REPORT_LENGTH.
/// @param data the data that was received
error InvalidData(bytes data);

uint256 private constant SELECTOR_LENGTH = 4;
uint256 private constant REPORT_LENGTH = 64;

struct HotVars {
bool reentrancyGuard; // guard against reentrancy
}
Expand All @@ -26,7 +34,9 @@ contract KeystoneForwarder is IForwarder, ConfirmedOwner, TypeAndVersionInterfac
bytes calldata data,
bytes[] calldata signatures
) external nonReentrant returns (bool) {
require(data.length > 4 + 64, "invalid data length");
if (data.length < SELECTOR_LENGTH + REPORT_LENGTH) {
revert InvalidData(data);
}

// data is an encoded call with the selector prefixed: (bytes4 selector, bytes report, ...)
// we are able to partially decode just the first param, since we don't know the rest
Expand Down
4 changes: 2 additions & 2 deletions core/gethwrappers/keystone/generated/forwarder/forwarder.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
GETH_VERSION: 1.13.8
forwarder: ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.abi ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.bin 4886b538e1fdc8aaf860901de36269e0c35acfd3e6eb190654d693ff9dbd4b6d
forwarder: ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.abi ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.bin b4c900aae9e022f01abbac7993d41f93912247613ac6270b0c4da4ef6f2016e3
ocr3_capability: ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.bin 9dcbdf55bd5729ba266148da3f17733eb592c871c2108ccca546618628fd9ad2

0 comments on commit 8337fc8

Please sign in to comment.