Skip to content

Initial work for workflow registry v2: limits #40

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

eutopian
Copy link
Contributor

No description provided.

@eutopian eutopian requested a review from a team as a code owner April 24, 2025 19:44
Copy link
Contributor

github-actions bot commented Apr 24, 2025

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.

@eutopian eutopian force-pushed the DEVSVCS-1014/workflow-registry-limits branch 7 times, most recently from a37a2df to 7a16d99 Compare April 24, 2025 21:32
@@ -56,6 +56,33 @@ WorkflowRegistry_registerWorkflow:test_WhenTheWorkflowInputsAreAllValid() (gas:
WorkflowRegistry_requestForceUpdateSecrets:test_WhenTheCallerIsAnAuthorizedAddress_AndTheWorkflowIsInAnAllowedDON() (gas: 936092)
WorkflowRegistry_requestForceUpdateSecrets:test_WhenTheCallerIsAnAuthorizedAddress_AndTheWorkflowIsNotInAnAllowedDON() (gas: 510822)
WorkflowRegistry_requestForceUpdateSecrets:test_WhenTheCallerIsNotAnAuthorizedAddress() (gas: 509176)
WorkflowRegistry_setDONOverride:test_WhenCallerIsNOTTheOwner() (gas: 120)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if we should set up a new profile for this and possibly also use pragma 0.8.26 if we do, especially as there will be duplicate functions when it comes to things like register

Copy link
Contributor

Choose a reason for hiding this comment

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

For VRF, we set up a different profile for each version to benefit from having a newer Solidity version, so it's certainly possible. In this case, the Foundry profile could be called "workflow_v2".

@eutopian eutopian force-pushed the DEVSVCS-1014/workflow-registry-limits branch 3 times, most recently from 0530b5e to 28b1d42 Compare April 28, 2025 14:16
struct Config {
// Pack three uint32 defaults into a single 96-bit field:
// Layout in bits: [maxUser(0..31) | maxDON(32..63) | maxUserDON(64..95)]
uint96 defaultsPacked;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why pack it like this instead of specifying three separate uint32 fields that will also fit into a single storage slot (uint32 = 4 bytes, storage slot size uint256 = 32 bytes, total of 12 bytes in the slot, so you still have some space left)?

Copy link
Contributor Author

@eutopian eutopian Apr 29, 2025

Choose a reason for hiding this comment

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

its one less SSTORE when you write. we need to check it often so it saves a little. Even though storage slot is packed together accessing them as separate fields is still separate...

maybe it's not worth it :D

Copy link
Contributor Author

@eutopian eutopian Apr 29, 2025

Choose a reason for hiding this comment

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

although... if we have them as separate, we might need separate setters too, otherwise, there's not much gained, and I don't know if this is worth having different setters. otherwise, it's also not worth doing
config.user = a
config.don = b
config.userdon = c each time as that's 3 writes

if (isSet) {
s_cfg.userOverride[user] = Config.Value(limit, true);
} else {
delete s_cfg.userOverride[user];
Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100% sure on this, but generally, deleting elements in mappings/arrays is avoided due to gas costs, so resetting values is more desirable. Since you're already using this isSet field value, maybe you can just set it false? In that case, this code is as simple as:

s_cfg.userOverride[user] = Config.Value(limit, isSet);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

delete is only costly for large structures, but this is one slot size, so delete versus setting this to false cost the same storage write but has the slight benefit of the cleared slot refund. the only benefit potentially in allowing it is record I think.

// Struct to distinguish between unset and explicitly set zero values
struct Value {
uint32 value;
bool isSet;
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also use the uint32 max value or any other arbitrarily large value to have a special meaning, but this is certainly easier to understand!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This looks like it's more complicated but actually not much more as both are small and fits into one storage slot, but much more explicit and readable than using an arbitrary value to get around the falsey zeros

@eutopian eutopian force-pushed the DEVSVCS-1014/workflow-registry-limits branch from 28b1d42 to 5561750 Compare April 29, 2025 13:59
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.

2 participants