Skip to content

Commit

Permalink
[Keystone] Minor fixes (#13493)
Browse files Browse the repository at this point in the history
1. Change type of price in the demo consumer contract to uint224 (CCIP's default)
2. Resize the hardcoded workflow DON to 7
3. Extra logs in write_target.go
  • Loading branch information
bolekk authored Jun 11, 2024
1 parent bb40d51 commit 5e00ab2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions contracts/src/v0.8/keystone/KeystoneFeedsConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import {IReceiver} from "./interfaces/IReceiver.sol";
import {OwnerIsCreator} from "../shared/access/OwnerIsCreator.sol";

contract KeystoneFeedsConsumer is IReceiver, OwnerIsCreator {
event FeedReceived(bytes32 indexed feedId, int192 price, uint32 timestamp);
event FeedReceived(bytes32 indexed feedId, uint224 price, uint32 timestamp);

error UnauthorizedSender(address sender);
error UnauthorizedWorkflowOwner(address workflowOwner);
error UnauthorizedWorkflowName(bytes10 workflowName);

struct ReceivedFeedReport {
bytes32 FeedId;
int192 Price;
uint224 Price;
uint32 Timestamp;
}

struct StoredFeedReport {
int192 Price;
uint224 Price;
uint32 Timestamp;
}

Expand Down Expand Up @@ -93,7 +93,7 @@ contract KeystoneFeedsConsumer is IReceiver, OwnerIsCreator {
}
}

function getPrice(bytes32 feedId) external view returns (int192, uint32) {
function getPrice(bytes32 feedId) external view returns (uint224, uint32) {
StoredFeedReport memory report = s_feedReports[feedId];
return (report.Price, report.Timestamp);
}
Expand Down
5 changes: 4 additions & 1 deletion core/capabilities/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ func NewHardcodedDonNetworkSetup() (HardcodedDonNetworkSetup, error) {
"12D3KooWG1AyvwmCpZ93J8pBQUE1SuzrjDXnT4BeouncHR3jWLCG",
"12D3KooWGeUKZBRMbx27FUTgBwZa9Ap9Ym92mywwpuqkEtz8XWyv",
"12D3KooW9zYWQv3STmDeNDidyzxsJSTxoCTLicafgfeEz9nhwhC4",
"12D3KooWG1AeBnSJH2mdcDusXQVye2jqodZ6pftTH98HH6xvrE97",
"12D3KooWBf3PrkhNoPEmp7iV291YnPuuTsgEDHTscLajxoDvwHGA",
"12D3KooWP3FrMTFXXRU2tBC8aYvEBgUX6qhcH9q2JZCUi9Wvc2GX",
}
result.triggerDonPeers = []string{
"12D3KooWBaiTbbRwwt2fbNifiL7Ew9tn3vds9AJE3Nf3eaVBX36m",
Expand Down Expand Up @@ -301,7 +304,7 @@ func NewHardcodedDonNetworkSetup() (HardcodedDonNetworkSetup, error) {
}
return nil
}
result.WorkflowsDonInfo = capabilities.DON{ID: "workflowDon1", F: 1}
result.WorkflowsDonInfo = capabilities.DON{ID: "workflowDon1", F: 2}
if err := addPeersToDONInfo(result.workflowDonPeers, &result.WorkflowsDonInfo); err != nil {
return HardcodedDonNetworkSetup{}, fmt.Errorf("failed to add peers to workflow DON info: %w", err)
}
Expand Down
7 changes: 3 additions & 4 deletions core/capabilities/targets/write_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ func (cap *WriteTarget) Execute(ctx context.Context, request capabilities.Capabi
cap.lggr.Debugw("Skipping empty report", "request", request)
return success(), nil
}
cap.lggr.Debugw("WriteTarget non-empty report - attempting to push to txmgr", "request", request, "reportLen", len(inputs.Report), "reportContextLen", len(inputs.Context), "nSignatures", len(inputs.Signatures))

// TODO: validate encoded report is prefixed with workflowID and executionID that match the request meta

rawExecutionID, err := hex.DecodeString(request.Metadata.WorkflowExecutionID)
Expand All @@ -118,11 +116,12 @@ func (cap *WriteTarget) Execute(ctx context.Context, request capabilities.Capabi
return nil, err
}
if transmitter != common.HexToAddress("0x0") {
// report already transmitted, early return
cap.lggr.Infow("WriteTarget report already onchain - returning without a tranmission attempt", "executionID", request.Metadata.WorkflowExecutionID)
return success(), nil
}

txID, err := uuid.NewUUID() // TODO(archseer): it seems odd that CW expects us to generate an ID, rather than return one
cap.lggr.Infow("WriteTarget non-empty report - attempting to push to txmgr", "request", request, "reportLen", len(inputs.Report), "reportContextLen", len(inputs.Context), "nSignatures", len(inputs.Signatures), "executionID", request.Metadata.WorkflowExecutionID)
txID, err := uuid.NewUUID() // NOTE: CW expects us to generate an ID, rather than return one
if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions core/services/workflows/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func initializeDONInfo(lggr logger.Logger) (*capabilities.DON, error) {
"12D3KooWG1AyvwmCpZ93J8pBQUE1SuzrjDXnT4BeouncHR3jWLCG",
"12D3KooWGeUKZBRMbx27FUTgBwZa9Ap9Ym92mywwpuqkEtz8XWyv",
"12D3KooW9zYWQv3STmDeNDidyzxsJSTxoCTLicafgfeEz9nhwhC4",
"12D3KooWG1AeBnSJH2mdcDusXQVye2jqodZ6pftTH98HH6xvrE97",
"12D3KooWBf3PrkhNoPEmp7iV291YnPuuTsgEDHTscLajxoDvwHGA",
"12D3KooWP3FrMTFXXRU2tBC8aYvEBgUX6qhcH9q2JZCUi9Wvc2GX",
}

p2pIDs := []p2ptypes.PeerID{}
Expand Down

0 comments on commit 5e00ab2

Please sign in to comment.