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

refactor: approved relays, jobs and selectors #7

Merged
merged 15 commits into from
Jan 4, 2024

Conversation

ashitakah
Copy link
Contributor

No description provided.

Copy link

@ashitakah ashitakah marked this pull request as draft December 21, 2023 13:31
Copy link

Copy link

Copy link
Member

@0xng 0xng left a comment

Choose a reason for hiding this comment

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

Looking good. Some extra comments:

  1. A lot is being managed through constants. This may be prone to error when deploying to multiple chains. I would guess, but not entirely sure, that in different chains the jobs will pay not in ETH for example but in the other chain's native token. Keep3r_V2 will be deployed in another address as well. So, perhaps having names such as ETH and events that are ETHReceived may not be 100% compatible with the idea of multi-chain deployment, as well as fixed addresses.

Consider using immutables to at least have the user think through what parameters he's inputting.

  1. The GelatoRelay is powerful. I mean this in the sense that any AutomationVault is banking on the protocol's reputation to avoid them from calling a bunch of vaults with FeeData == vaultBalance and drain them. Now, one thing we should be extremely careful about is how Gelato itself checks the parameters their own keepers/executors use.

A good question to answer is:

  • What happens when a random user tells Gelato: "Hey I have put some money in 1Balance please call GelatoRelay with these malicious parameters." Do we know what checks they perform? Do we know if they just obey and do it?

}

unchecked {
++_i;
}

// If the relay has no enabled callers, remove it from the list of relays
if (_relayCallers[_relay].length() == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be outside of the for loop, to avoid rechecking on each iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

// Create the new automation vault with the owner
_automationVault = new AutomationVault(_owner);
_automationVault = new AutomationVault{salt: keccak256(abi.encodePacked(msg.sender, _salt))}(_owner);
Copy link
Member

Choose a reason for hiding this comment

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

This add a bit of extra gas cost, so it's optional but when a CREATE2 deployment fails, it returns address(0). You may want to add a check for it to avoid adding address(0) to the automation vaults mapping

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 didnt know nice one 👍

Copy link
Contributor Author

@ashitakah ashitakah Dec 29, 2023

Choose a reason for hiding this comment

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

@0xng are we sure that this happens?, im trying to test this situation and when the deployment fails reverts and not return address (0)

Copy link
Member

Choose a reason for hiding this comment

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

@ashitakah interesting, you may be right, I got this idea from the evm.codes CREATE2 line that says:

Deployment can fail due to:

  • A contract already exists at the destination address.
  • Insufficient value to transfer.
  • Sub context reverted.
  • Insufficient gas to execute the initialisation code.
  • Call depth limit reached.
  • Note that these failures only affect the return value and do not cause the calling context to revert (unlike the error cases below).

But also tested one of these cases (contract already exists at the destination address), and it also reverts. So then we should be good without adding the check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 cool

Copy link

Copy link

github-actions bot commented Jan 2, 2024

Copy link

github-actions bot commented Jan 2, 2024

@ashitakah ashitakah changed the title [DRAFT] Refactor [DO NOT MERGE] refactor: approved relays, jobs and selectors Jan 2, 2024
@ashitakah ashitakah marked this pull request as ready for review January 2, 2024 12:44
Copy link
Member

@0xJabberwock 0xJabberwock left a comment

Choose a reason for hiding this comment

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

Awesome work @ashitakah!

solidity/contracts/AutomationVault.sol Outdated Show resolved Hide resolved
solidity/contracts/AutomationVault.sol Outdated Show resolved Hide resolved
Comment on lines +61 to +62
// Get the list of selectors
_selectors = _relayJobSelectors[_relay][_job].values();
Copy link
Member

Choose a reason for hiding this comment

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

Should there be a method to get a relay's approved jobs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be in the front end part. Ardy can collect all jobs and check if the job is for that relay

solidity/contracts/AutomationVault.sol Outdated Show resolved Hide resolved
Comment on lines 210 to +211
// Create the exec data needed variables
ExecData memory _execDatum;
ExecData memory _dataToExecute;
Copy link
Member

Choose a reason for hiding this comment

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

In views of normalization, I suggest naming this variable _dataInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, the naming was review'd

solidity/interfaces/IAutomationVault.sol Outdated Show resolved Hide resolved
Comment on lines -13 to +15
abstract contract Deploy is Script {
abstract contract DeployNativeETH is Script {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't ETH always native? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you deploy in L2 you can choose another native. I know that at the end of the day is the same, however I think that is better to specify that.

solidity/test/unit/AutomationVault.t.sol Outdated Show resolved Hide resolved
Comment on lines -205 to +223
function relays() external view returns (address[] memory __relays);
function relays() external view returns (address[] memory _listRelays);
Copy link
Member

Choose a reason for hiding this comment

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

_relaysList and _jobsList sounds better to me.

Copy link
Contributor Author

@ashitakah ashitakah Jan 3, 2024

Choose a reason for hiding this comment

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

I changed it because another comments told me that sounds better hahahha

Copy link

github-actions bot commented Jan 3, 2024

Copy link
Member

@0xJabberwock 0xJabberwock left a comment

Choose a reason for hiding this comment

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

🔥

@ashitakah ashitakah merged commit 2848002 into dev Jan 4, 2024
6 checks passed
@ashitakah ashitakah deleted the refactor/relays-selectors branch January 4, 2024 11:10
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.

4 participants