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

[DEVSVCS-518] Workflow Registry Contract #14990

Merged
merged 22 commits into from
Nov 16, 2024

Conversation

eutopian
Copy link
Contributor

@eutopian eutopian commented Oct 28, 2024

Initial dev portion of the workflow registry contract ported from dev-platform

@eutopian eutopian force-pushed the workflow-registry-contract-draft branch from 1e373da to ea6b7ff Compare October 28, 2024 21:29
Copy link
Contributor

github-actions bot commented Oct 28, 2024

Static analysis results are available

Hey @eutopian, you can view Slither reports in the job summary here or download them as artifact here.
Please check them before merging and make sure you have addressed all issues.

Copy link
Contributor

github-actions bot commented Oct 29, 2024

AER Report: CI Core ran successfully ✅

aer_workflow , commit

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

@eutopian eutopian force-pushed the workflow-registry-contract-draft branch from af3a3ae to 8cc5835 Compare October 31, 2024 02:13
@cl-sonarqube-production
Copy link

@eutopian eutopian marked this pull request as ready for review October 31, 2024 12:30
@eutopian eutopian requested review from a team as code owners October 31, 2024 12:30
@eutopian eutopian requested a review from chudilka1 October 31, 2024 12:30
@eutopian eutopian changed the title workflow registry contract draft workflow registry contract Oct 31, 2024
@eutopian eutopian force-pushed the workflow-registry-contract-draft branch from 653d06d to 8f37a80 Compare November 1, 2024 14:22
@eutopian eutopian force-pushed the workflow-registry-contract-draft branch 3 times, most recently from 3ea3eab to 40023d2 Compare November 8, 2024 20:02
shileiwill
shileiwill previously approved these changes Nov 8, 2024
contracts/.prettierignore Show resolved Hide resolved
@eutopian eutopian changed the title workflow registry contract [DEVSVCS-518] Workflow Registry Contract Nov 8, 2024
chainchad
chainchad previously approved these changes Nov 8, 2024
@@ -132,6 +132,19 @@ let config = {
version: '0.8.19',
settings: COMPILER_SETTINGS,
},
'src/v0.8/workflow/dev/WorkflowRegistry.sol': {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the hardhat exclusion isn't working and we need it for the ir compile

contracts/src/v0.8/workflow/dev/DONAccessControl.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/workflow/dev/DONAccessControl.sol Outdated Show resolved Hide resolved
contracts/src/v0.8/workflow/dev/DONAccessControl.sol Outdated Show resolved Hide resolved
.github/workflows/solidity-foundry.yml Outdated Show resolved Hide resolved
contracts/src/v0.8/workflow/test/WorkflowRegistry.t.sol Outdated Show resolved Hide resolved
@RensR
Copy link
Contributor

RensR commented Nov 11, 2024

The PR isn't forge formatted but also adds its code to prettierignore. This means there is no formatting which is not allowed

@eutopian eutopian dismissed stale reviews from chainchad and shileiwill via 98992ac November 13, 2024 17:51
@eutopian eutopian force-pushed the workflow-registry-contract-draft branch 4 times, most recently from ed80b5c to 0ec55e3 Compare November 15, 2024 15:11
@eutopian eutopian force-pushed the workflow-registry-contract-draft branch from 9804fe8 to d833b24 Compare November 15, 2024 15:54
@eutopian eutopian force-pushed the workflow-registry-contract-draft branch 2 times, most recently from a0e852c to 903f65d Compare November 15, 2024 17:37
@eutopian eutopian force-pushed the workflow-registry-contract-draft branch from 903f65d to cd0b041 Compare November 15, 2024 17:43
@eutopian eutopian requested review from RensR and chainchad November 15, 2024 17:59
@ibrajer ibrajer removed the request for review from chudilka1 November 15, 2024 18:24
@eutopian eutopian removed the request for review from RensR November 15, 2024 18:26

/// @notice Maps a combination of address and chain ID to the version number.
/// @dev This mapping allows for lookup of the version number for a given address and chain ID.
mapping(bytes32 => uint32) private s_versionNumberByAddressAndChainID;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: ideally we wanna group mappings to facilitate packing of non-256bit storage vars

limit = MAX_PAGINATION_LIMIT;
}

uint32 end = (start + limit - 1 > totalVersions) ? totalVersions : start + limit - 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, would this be more readable:

 uint32 end = start + limit - 1 > totalVersions;
if (end > totalVersions) {
    end = totalVersions;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What you have is the default go-minded thinking in me as well. Without considerations for readability, the ternary is supposedly "slightly" more efficient?

Readability is subjective. Maybe just add a rule for no nested ternaries period.

// Remove the old secrets hash if secretsURL is not empty
if (bytes(workflow.secretsURL).length > 0) {
// Using keccak256 instead of _computeOwnerAndStringFieldHashKey as currentSecretsURL is memory
bytes32 oldSecretsHash = keccak256(abi.encodePacked(msg.sender, workflow.secretsURL));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: abi.encodePacked is being considered for deprecation, is there a reason not to use abi.encode given you are hashing it to bytes32 anyway? Same for many other cases

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 didn't know encodePacked is being considered for depreciation, I guess it was chosen for a few reasons here

  1. there's multiple inputs and this is more packed/ efficient than encode.
  2. encode is "safer" and better because the order matters, but in most of the cases in the registry contract it's not computed directly but instead with a helper function where the two params have different types so there's no way to mix them up and in that sense the order is already pre-determined.

But I guess to your point in this version tracker contract without the helper encode itself could totally work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But interesting.... seems like for these specific use cases of hashing addresses with something else in particular encodePacked is the best usecase ethereum/solidity#11593 (comment) kind of a bummer about the removal?

/// new workflows for a removed DON.
/// @param donIDs The list of unique identifiers for Workflow DONs.
/// @param allowed True if they should be added to the allowlist, false to remove them.
function updateAllowedDONs(uint32[] calldata donIDs, bool allowed) external onlyOwner registryNotLocked {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can consider 2 params uint32[] calldata donIDsToAdd, uint32[] calldata donIDsToRemove so updates can be done in single tx, ditto for funcs below

bool sameConfigURL = Strings.equal(workflow.configURL, configURL);
bool sameSecretsURL = Strings.equal(workflow.secretsURL, secretsURL);
if (sameBinaryURL && sameConfigURL && sameSecretsURL) {
revert WorkflowContentNotUpdated();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: does it conflict with If the value should remain unchanged, provide the same value as before.?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I don't think so in that one of the three must change. So it's possible for 2 of the 3 to remain unchanged but if no change is the desire the user would have to provide the same value as what is already in storage instead of leaving it out of the params

@eutopian eutopian enabled auto-merge November 15, 2024 23:29
@eutopian eutopian added this pull request to the merge queue Nov 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 15, 2024
@eutopian eutopian added this pull request to the merge queue Nov 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 16, 2024
@eutopian eutopian added this pull request to the merge queue Nov 16, 2024
Merged via the queue into develop with commit c686783 Nov 16, 2024
160 of 162 checks passed
@eutopian eutopian deleted the workflow-registry-contract-draft branch November 16, 2024 01:21
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.

8 participants