Skip to content
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

KS-204: Add config count to DON struct #13193

Conversation

cds95
Copy link
Contributor

@cds95 cds95 commented May 14, 2024

PR to add a configCount in the DON struct. This does not change anything functionally but is only used so that we can easily replace an existing config by incrementing the configCount and populating a new EnumerableSet.

@cds95 cds95 force-pushed the KS-204/track-config-count-DON-struct branch from 847cea4 to fe863be Compare May 14, 2024 11:44
/// @notice Mapping from hashed capability IDs to configs
mapping(bytes32 capabilityId => bytes config) capabilityConfigs;
/// @notice Mapping of config counts to configurations
mapping(uint32 configCount => DONNodeCapabilityConfig donConfig) nodeCapabilityConfigs;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking that it may also make sense to have separate configCounts for the different configs so that we don't have to repopulate everything when updating.

Comment on lines 531 to 532
if (s_dons[id].nodeCapabilityConfigs[configCount].nodes.contains(nodeP2PId))
revert DuplicateDONNode(id, nodeP2PId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably do this validation in memory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can load this into memory as we have a nested mapping

@cds95 cds95 force-pushed the KS-204/track-config-count-DON-struct branch from bd56ef1 to 1e2ca8d Compare May 15, 2024 07:45
/// @notice Mapping from hashed capability IDs to configs
mapping(bytes32 capabilityId => bytes config) capabilityConfigs;
/// @notice Mapping of config counts to configurations
mapping(uint32 configCount => DONCapabilityConfig donConfig) capabilityConfigs;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mapping(uint32 configCount => DONCapabilityConfig donConfig) capabilityConfigs;
mapping(uint32 configCount => DONCapabilityConfig donConfig) config;

WDYT, given that it's not just capability config now but also includes nodes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me

/// @notice DON (Decentralized Oracle Network) is a grouping of nodes that support
// the same capabilities.
struct DON {
/// @notice Computed. Auto-increment.
uint32 id;
/// @notice The number of times the DON's capability was configured
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// @notice The number of times the DON's capability was configured
/// @notice The number of times the DON was configured

@@ -516,11 +523,15 @@ contract CapabilityRegistry is OwnerIsCreator, TypeAndVersionInterface {
s_dons[id].id = id;
s_dons[id].isPublic = isPublic;

uint32 configCount = 1;

DONCapabilityConfig storage donCapabilityConfig = s_dons[id].config[configCount];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DONCapabilityConfig storage donCapabilityConfig = s_dons[id].config[configCount];
DONCapabilityConfig storage donConfig = s_dons[id].config[configCount];

@cl-sonarqube-production
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@cds95 cds95 merged commit 97b84d0 into use-encode-instead-of-encode-packed-capability-id May 15, 2024
117 checks passed
@cds95 cds95 deleted the KS-204/track-config-count-DON-struct branch May 15, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants