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

New deployment management #1893

Merged
merged 12 commits into from
May 15, 2024
Merged

Conversation

DmytroNazarenko
Copy link
Collaborator

@DmytroNazarenko DmytroNazarenko commented May 10, 2024

Description

This feature enhances the flexibility of contract deployment management. Previously, during contract creation, skaled invoked the ConfigController smart contract by passing only msg.sender as an argument to check whether address is able to deploy contracts:

ConfigController.isAddressWhitelisted(address sender) -> bool

With the new version, if the feature is enabled, skaled will pass two parameters - tx.origin and msg.sender into the call to check whether address is able to deploy:

ConfigController.isDeploymentAllowedCallData(address origin, address sender) -> bool

Patch

The feature is enabled by the FlexibleDeploymentPatchTimestamp.

Tests

A unit test has been added: JsonRpcSuite/deployment_control_v2.

Integration test

Tested on devnet

  1. Update ConfigController contract to the v2 version on chain A
  2. Set FlexibleDeploymentPatchTimestamp to the current timestamp for chain A
  3. Update skaled version
  4. Whitelist deployer address X
  5. Deploy ContractFactory from address X
  6. Try to deploy contract using ContractFactory from address Y -> fail
  7. Whitelist address Y as allowed origin for ContractFactory
  8. Try to deploy contract using ContractFactory from address Y -> success
  9. Try to deploy contract using ContractFactory from address X -> success
  10. Try to deploy contract using ContractFactory from address Z -> fail

Contracts for testing:

// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.24;

contract Factory {
    event ContractAddress(address contractAddress);
    // Returns the address of the newly deployed contract
    function deploy(address _owner, uint256 _foo, bytes32 _salt)
        public
        returns (address)
    {
        // This syntax is a newer way to invoke create2 without assembly, you just need to pass salt
        // https://docs.soliditylang.org/en/latest/control-structures.html#salted-contract-creations-create2
        address testContract = address(new TestContract{salt: _salt}(_owner, _foo));
        emit ContractAddress(testContract);
        return testContract;
    }
}


contract TestContract {
    address public owner;
    uint256 public foo;

    constructor(address _owner, uint256 _foo) {
        owner = _owner;
        foo = _foo;
    }

    function getBalance() public view returns (uint256) {
        return address(this).balance;
    }
}

Performance Impact

This feature introduces an additional parameter in the ConfigController call, with no significant impact on performance.

@DmytroNazarenko DmytroNazarenko linked an issue May 10, 2024 that may be closed by this pull request
@DmytroNazarenko DmytroNazarenko marked this pull request as ready for review May 13, 2024 19:50
@DmytroNazarenko DmytroNazarenko merged commit e1f053a into v3.19.0 May 15, 2024
5 checks passed
@DmytroNazarenko DmytroNazarenko deleted the enhancement/new-deploy-management branch May 15, 2024 11:48
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flexible deployment permissions
3 participants