Skip to content

Commit

Permalink
[ETHEREUM-CONTRACTS] New web3-operations path for SuperTokenFactory (#…
Browse files Browse the repository at this point in the history
…1276)

* add new updateLogicContracts

* add sanity check test

- add mock contract
- add test to ensure new code is being run

* forge install: forge-std

v1.3.0

* SuperTokenFactory deploy test

* fix framework test

* forge install: forge-std

v1.3.0

* fix redundant naming

* Ops flow cleanup

- delete updateLogicContracts() function
- delete SuperTokenFactoryHelper
- delete _updateSuperTokenLogic function (future updates will no longer follow this path)
- use SuperTokenDeployerLibrary.deploySuperTokenLogic to deploy non upgradeable super token
- fix breaking tests
- create some abstracted functions for deploy external library and linking

* cleanup

* fork baseline

- add fork baseline tests file
- rename fork super token factory upgrade test file

* fork baseline wip

- refactor ForkBaseline: it is responsible for loading the forked framework
- add more tests in ForkBaseline
- do not run fork tests in the CI

* Update CHANGELOG.md

* deprecate non upgradeable deploy

* fix broken build

* Address CI env naming comment

#1276 (comment)

* address merge "deployers/*.sol" comment

#1276 (comment)

* use consistent immutable var naming

#1276 (comment)

* address documentation comment

#1276 (comment)

* address scripts artifacts naming

change from scripts -> ops-scripts as the test/ops-scripts are testing ops-scripts

* address baseline comment

#1276 (comment)

* address missing context naming comment

#1276 (comment)

* cleanup

- change hot-fuzz to match new file format
- remove unused UUPSProxy import

* duplicate keys makes no sense

ty Miao
  • Loading branch information
0xdavinchee committed Feb 13, 2023
1 parent 33aef62 commit 6220f66
Show file tree
Hide file tree
Showing 30 changed files with 1,290 additions and 425 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ jobs:
- name: Test ethereum-contracts
run: |
yarn workspace @superfluid-finance/ethereum-contracts test
env:
# NOTE: This is currently unset and fork tests are not being run
POLYGON_MAINNET_ARCHIVE_PROVIDER_URL: ${{ secrets.POLYGON_MAINNET_ARCHIVE_PROVIDER_URL }}

coverage-ethereum-contracts:
name: Build and test coverage of ethereum-contracts (Feature Branch)
Expand Down
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.3.0
6 changes: 6 additions & 0 deletions packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Added
- bump solc to 0.8.18
### Breaking
- `SuperTokenFactory` contract no longer takes `SuperTokenHelper` contract in its constructor
- Migration: Pass in a deployed `SuperToken` (logic) contract address to `SuperTokenFactory` constructor instead

### Changed
- `_superTokenLogic` field in `SuperTokenFactory` contract is now a public immutable field and the previous storage variable is removed

### [v1.5.0] - 2022-12-19
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ abstract contract SuperfluidGovernanceBase is ISuperfluidGovernance
emit AppFactoryAuthorizationChanged(host, factory, false);
}

// NOTE: we currently don't check anything with host in
// SuperfluidGovernanceII and only assert that the host passed
// is the correct host in TestGovernance
modifier onlyAuthorized(ISuperfluid host) {
_requireAuthorised(host);
_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ interface ISuperTokenFactory {
/**************************************************************************
* Errors
*************************************************************************/
error SUPER_TOKEN_FACTORY_ALREADY_EXISTS(); // 0x91d67972
error SUPER_TOKEN_FACTORY_DOES_NOT_EXIST(); // 0x872cac48
error SUPER_TOKEN_FACTORY_UNINITIALIZED(); // 0x1b39b9b4
error SUPER_TOKEN_FACTORY_ONLY_HOST(); // 0x478b8e83
error SUPER_TOKEN_FACTORY_ZERO_ADDRESS(); // 0x305c9e82
error SUPER_TOKEN_FACTORY_ALREADY_EXISTS(); // 0x91d67972
error SUPER_TOKEN_FACTORY_DOES_NOT_EXIST(); // 0x872cac48
error SUPER_TOKEN_FACTORY_UNINITIALIZED(); // 0x1b39b9b4
error SUPER_TOKEN_FACTORY_ONLY_HOST(); // 0x478b8e83
error SUPER_TOKEN_FACTORY_NON_UPGRADEABLE_IS_DEPRECATED(); // 0x478b8e83
error SUPER_TOKEN_FACTORY_ZERO_ADDRESS(); // 0x305c9e82

/**
* @dev Get superfluid host contract address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ pragma solidity 0.8.18;

import { SuperTokenMock } from "./SuperTokenMock.sol";
import {
SuperTokenFactoryBase,
ISuperfluid
ISuperfluid,
ISuperToken,
SuperToken,
SuperTokenFactoryBase
} from "../superfluid/SuperTokenFactory.sol";

contract SuperTokenFactoryStorageLayoutTester is SuperTokenFactoryBase {

constructor(
ISuperfluid host
ISuperfluid host,
ISuperToken superTokenLogic
)
SuperTokenFactoryBase(host)
// solhint-disable-next-line no-empty-blocks
SuperTokenFactoryBase(host, superTokenLogic)
// solhint-disable-next-line no-empty-blocks
{

}

// @dev Make sure the storage layout never change over the course of the development
Expand All @@ -24,73 +27,72 @@ contract SuperTokenFactoryStorageLayoutTester is SuperTokenFactoryBase {

// Initializable bool _initialized and bool _initialized

assembly { slot:= _superTokenLogic.slot offset := _superTokenLogic.offset }
require (slot == 0 && offset == 2, "_superTokenLogic changed location");
assembly { slot:= _superTokenLogicDeprecated.slot offset := _superTokenLogicDeprecated.offset }
require (slot == 0 && offset == 2, "_superTokenLogicDeprecated changed location");

assembly { slot := _canonicalWrapperSuperTokens.slot offset := _canonicalWrapperSuperTokens.offset }
require(slot == 1 && offset == 0, "_canonicalWrapperSuperTokens changed location");
}

// dummy impl
function createSuperTokenLogic(ISuperfluid)
external pure override
returns (address)
{
return address(0);
function createSuperTokenLogic(
ISuperfluid // host
) external override returns (address) {
return address(_SUPER_TOKEN_LOGIC);
}
}

// spliting this off because the contract is getting bigger
contract SuperTokenFactoryMockHelper {
function create(ISuperfluid host, uint256 waterMark)
external
returns (address logic)
contract SuperTokenFactoryUpdateLogicContractsTester is SuperTokenFactoryBase {
uint256 public newVariable;

constructor(
ISuperfluid host,
ISuperToken superTokenLogic
)
SuperTokenFactoryBase(host, superTokenLogic)
// solhint-disable-next-line no-empty-blocks
{
SuperTokenMock superToken = new SuperTokenMock(host, waterMark);
return address(superToken);

}
}

contract SuperTokenFactoryMock is SuperTokenFactoryBase
{
SuperTokenFactoryMockHelper immutable private _helper;
function createSuperTokenLogic(
ISuperfluid // host
) external override returns (address) {
return address(_SUPER_TOKEN_LOGIC);
}
}

contract SuperTokenFactoryMock is SuperTokenFactoryBase {
constructor(
ISuperfluid host,
SuperTokenFactoryMockHelper helper
ISuperToken superTokenLogic
)
SuperTokenFactoryBase(host)
SuperTokenFactoryBase(host, superTokenLogic)
// solhint-disable-next-line no-empty-blocks
{
_helper = helper;

}

function createSuperTokenLogic(ISuperfluid host)
external override
returns (address logic)
{
return _helper.create(host, 0);
function createSuperTokenLogic(
ISuperfluid // host
) external override returns (address) {
return address(_SUPER_TOKEN_LOGIC);
}
}

contract SuperTokenFactoryMock42 is SuperTokenFactoryBase
{

SuperTokenFactoryMockHelper immutable private _helper;

contract SuperTokenFactoryMock42 is SuperTokenFactoryBase {
constructor(
ISuperfluid host,
SuperTokenFactoryMockHelper helper
ISuperToken superTokenLogic
)
SuperTokenFactoryBase(host)
SuperTokenFactoryBase(host, superTokenLogic)
// solhint-disable-next-line no-empty-blocks
{
_helper = helper;
}

function createSuperTokenLogic(ISuperfluid host)
external override
returns (address logic)
{
return _helper.create(host, 42);
}

function createSuperTokenLogic(
ISuperfluid // host
) external override returns (address) {
return address(_SUPER_TOKEN_LOGIC);
}
}
Loading

0 comments on commit 6220f66

Please sign in to comment.