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

[RFC][draft only] add billing token and config #12295

Closed
wants to merge 6 commits into from

Conversation

shileiwill
Copy link
Contributor

@shileiwill shileiwill commented Mar 5, 2024

AUTO-9111

Putting this up to get some early feedback on the structure.
hardhat tests need to be fixed.

Copy link
Contributor

github-actions bot commented Mar 5, 2024

I see that you haven't updated any README files. Would it make sense to do so?

@shileiwill shileiwill changed the title add billing token and config [RFC][draft only] add billing token and config Mar 5, 2024
// set billing configs
for (uint256 idx = 0; idx < billingTokens.length; idx++) {
setBillingConfig(billingTokens[idx], billingConfigs[idx]);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have this logic here in setConfig instead of setConfigTypeSafe to avoid stack too deep issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need this in setConfigTypeSafe() - we'll have to find another way around the stack too deep issues

@@ -103,6 +103,9 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
mapping(uint256 => bytes) internal s_upkeepOffchainConfig; // general config set by users for each upkeep
mapping(uint256 => bytes) internal s_upkeepPrivilegeConfig; // general config set by an administrative role for an upkeep
mapping(address => bytes) internal s_adminPrivilegeConfig; // general config set by an administrative role for an admin
// billing
mapping(address => BillingConfig) internal s_billingConfigs; // billing configurations for different tokens
address[] internal s_billingTokens; // list of billing tokens
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To quickly get the list of billing tokens, I have this address list. would like to hear if there is better solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is perfect!

Copy link
Contributor

github-actions bot commented Mar 5, 2024

Go solidity wrappers are out-of-date, regenerate them via the make wrappers-all command

jmank88 and others added 4 commits March 5, 2024 14:21
* fix arb gas info vendor and arb module

* linting

* fix cancel upkeep by owner

* fix tests

* tidy up cancelUpkeep

* update
…error messages when typical configuration is missing (#12298)
* fix: remove unused references for grafana cloud

* fix: grafana internal for golangci-lint

* chore: other grafana internal credentials
// set billing configs
for (uint256 idx = 0; idx < billingTokens.length; idx++) {
setBillingConfig(billingTokens[idx], billingConfigs[idx]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need this in setConfigTypeSafe() - we'll have to find another way around the stack too deep issues

@@ -103,6 +103,9 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
mapping(uint256 => bytes) internal s_upkeepOffchainConfig; // general config set by users for each upkeep
mapping(uint256 => bytes) internal s_upkeepPrivilegeConfig; // general config set by an administrative role for an upkeep
mapping(address => bytes) internal s_adminPrivilegeConfig; // general config set by an administrative role for an admin
// billing
mapping(address => BillingConfig) internal s_billingConfigs; // billing configurations for different tokens
address[] internal s_billingTokens; // list of billing tokens
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is perfect!

@@ -103,6 +103,9 @@ abstract contract AutomationRegistryBase2_3 is ConfirmedOwner {
mapping(uint256 => bytes) internal s_upkeepOffchainConfig; // general config set by users for each upkeep
mapping(uint256 => bytes) internal s_upkeepPrivilegeConfig; // general config set by an administrative role for an upkeep
mapping(address => bytes) internal s_adminPrivilegeConfig; // general config set by an administrative role for an admin
// billing
mapping(address => BillingConfig) internal s_billingConfigs; // billing configurations for different tokens
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're migrating towards named mappings, so something like:

mapping(address billingToken => BillingConfig config) internal s_billingConfigs;

);
if (billingTokens.length != billingConfigs.length) revert IncorrectBillingTokenConfigLength();
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick, but I think we already have a generic "length" error: ParameterLengthError - could we use this intead?

Comment on lines 262 to 264
for (uint256 idx = 0; idx < billingTokens.length; idx++) {
setBillingConfig(billingTokens[idx], billingConfigs[idx]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to make sure we delete any of the old billing tokens!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before we set new billing configs, we empty the mapping and list first? so every time is new, not append?

* @param token the address of the token
* @param config the config for the token
*/
function setBillingConfig(address token, BillingConfig memory config) internal {
Copy link
Contributor

Choose a reason for hiding this comment

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

internal / private functions usually start with an underscore :)

Copy link
Contributor

Choose a reason for hiding this comment

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

also, all internal functions should live on AutomationRegistryBase :) we try to only put public / external functions on the Root / Logic contracts

* @param config the config for the token
*/
function setBillingConfig(address token, BillingConfig memory config) internal {
require(token != address(0), "Token address cannot be zero address");
Copy link
Contributor

Choose a reason for hiding this comment

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

we try to never use error strings, because they take up precious contract space! custom errors are preferred!

Comment on lines 404 to 406
if (!tokenExists(token)) {
s_billingTokens.push(token);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we check to see if the BillingConfig exists already instead of doing a nested loop?

* @param token the address of the token
* @param config the config for the token
*/
function setBillingConfig(address token, BillingConfig memory config) internal {
Copy link
Contributor

Choose a reason for hiding this comment

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

small nitpick, but it might help with the stack too deep error, if we make this function plural, like...

function setBillingConfigs(address[] memory tokens, BillingConfig[] memory configs) {...}

and then do the loop inside this function

Copy link
Contributor

github-actions bot commented Mar 6, 2024

Go solidity wrappers are out-of-date, regenerate them via the make wrappers-all command

@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
0.0% Duplication on New Code

See analysis details on SonarQube

Copy link
Contributor

github-actions bot commented Mar 6, 2024

Go solidity wrappers are out-of-date, regenerate them via the make wrappers-all command

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.

6 participants