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

add readonly address #11906

Merged
merged 2 commits into from
Feb 7, 2024
Merged

add readonly address #11906

merged 2 commits into from
Feb 7, 2024

Conversation

shileiwill
Copy link
Contributor

@shileiwill shileiwill commented Jan 26, 2024

AUTO-8803

  • yarn prettier:write
  • yarn hardhat size-contracts
  • pnpm hardhat test test/v0.8/automation/AutomationRegistry2_2.test.ts all tests passed.
  • pnpm ts-node ./scripts/generate-automation-master-interface.ts nothing changed.
  • go generate core/gethwrappers/go_generate.go some wrappers regenerated.
  • forge test --match-path "*/AutomationRegistry2_2.t.sol" all foundry tests pass.

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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

@shileiwill shileiwill force-pushed the AUTO-8803-configurable branch from e2ed701 to 5eab36a Compare January 26, 2024 17:50
@shileiwill shileiwill marked this pull request as ready for review January 26, 2024 17:51
@shileiwill shileiwill requested a review from a team as a code owner January 26, 2024 17:51
@@ -13,6 +13,7 @@ contract AutomationRegistry2_2_SetUp is BaseTest {
address internal constant LINK_ETH_FEED = 0x1111111111111111111111111111111111111110;
address internal constant FAST_GAS_FEED = 0x1111111111111111111111111111111111111112;
address internal constant LINK_TOKEN = 0x1111111111111111111111111111111111111113;
address internal constant ZERO_ADDRESS = 0x0000000000000000000000000000000000000000;
Copy link
Contributor

Choose a reason for hiding this comment

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

try address(0)

Copy link
Contributor

Choose a reason for hiding this comment

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

let's add a test here to expect a revert if someone sends a eth_call with different tx.origin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do. @FelixFan1992 can you elaborate a bit more on someone sends a eth_call? Trying to see what is the best way to cover this scenario. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

the reason we add this new address is to restrict which address can call checkUpkeep, simulatePerformUpkeep etc. only eth_call from this address is allowed. so we can add a simple testcase for this. maybe just for checkUpkeep

@shileiwill shileiwill force-pushed the AUTO-8803-configurable branch from 5eab36a to 2bbb646 Compare January 27, 2024 05:09
@shileiwill shileiwill changed the title add readonly address [RFC][NO_MERGE] add readonly address Jan 27, 2024
@shileiwill shileiwill force-pushed the AUTO-8803-configurable branch from 2bbb646 to eb6f030 Compare January 27, 2024 05:11
);

// Expect the call to revert with "OnlySimulatedBackend" error
require(!success, "Expected eth_call to revert for not allowed address");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this test. Not sure if I am doing it the right way. Looking for comments.

@shileiwill shileiwill marked this pull request as draft February 5, 2024 21:26
@shileiwill shileiwill force-pushed the AUTO-8803-configurable branch from eb6f030 to e731482 Compare February 5, 2024 21:30
Copy link
Contributor

github-actions bot commented Feb 5, 2024

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

Copy link
Contributor

github-actions bot commented Feb 6, 2024

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

@shileiwill shileiwill force-pushed the AUTO-8803-configurable branch from c9c970c to 60da2bd Compare February 6, 2024 22:35
Copy link
Contributor

github-actions bot commented Feb 7, 2024

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

@shileiwill shileiwill force-pushed the AUTO-8803-configurable branch from 8226d04 to 8e38687 Compare February 7, 2024 02:04
@shileiwill shileiwill marked this pull request as ready for review February 7, 2024 02:37
@shileiwill shileiwill requested a review from a team as a code owner February 7, 2024 02:37
@shileiwill shileiwill changed the title [RFC][NO_MERGE] add readonly address add readonly address Feb 7, 2024
returns (bool upkeepNeeded, bytes memory performData, UpkeepFailureReason upkeepFailureReason, uint256 gasUsed)
{
_preventExecution();
Copy link
Contributor

Choose a reason for hiding this comment

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

this one is unnecessary because checkCallback() calls executeCallback(), which already has the modifier :)

function testPreventExecutionOnCheckUpkeep() public {
IAutomationRegistryMaster registry = IAutomationRegistryMaster(
address(deployRegistry2_2(AutomationRegistryBase2_2.Mode(0)))
);

uint256 id = 1;
bytes memory triggerData = abi.encodePacked("trigger_data");

// The tx.origin is the default DEFAULT_SENDER (0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38) of foundry
// Expecting a revert since the tx.origin is not address(0)
vm.expectRevert(abi.encodeWithSelector(IAutomationRegistryMaster.OnlySimulatedBackend.selector));
registry.checkUpkeep(id, triggerData);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this test is currently inside of the AutomationRegistry2_2_SetConfig contract (aka a "test block" in foundry world). I think our plan to organize tests is that each test goes inside a test block for that particular function. So the layout should look like...

contract AutomationRegistry2_2_SetConfig is AutomationRegistry2_2_SetUp {
  // all of the setConfig() tests
}

contract AutomationRegistry2_2_CheckUpkeep is AutomationRegistry2_2_SetUp {
  // all of the checkUpkeep() tests
}

@cl-sonarqube-production
Copy link

SonarQube Quality Gate

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@RyanRHall RyanRHall added this pull request to the merge queue Feb 7, 2024
Merged via the queue into develop with commit 7eb5600 Feb 7, 2024
105 checks passed
@RyanRHall RyanRHall deleted the AUTO-8803-configurable branch February 7, 2024 18:00
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.

3 participants