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

Self Serve Token Pool Factory Contract #1410

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e35a529
proof of concept v0 for token pool factory. Untested
jhweintraub Sep 4, 2024
264c483
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 4, 2024
45c205e
cleanup and solhint fixes
jhweintraub Sep 5, 2024
6b06dc7
Checkpoint a successful deployment workflow
jhweintraub Sep 10, 2024
034990c
Check in. Prediction mechanism working tentatively
jhweintraub Sep 11, 2024
986aeed
tests passing. Cleanup, Comments, and better formatting still needed
jhweintraub Sep 11, 2024
47cae4b
Cleanup and additional comments/natspec
jhweintraub Sep 13, 2024
10c5c66
cleanup shared token files
jhweintraub Sep 13, 2024
4b5719c
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 13, 2024
b263cd8
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 13, 2024
f4847a4
snapshot and compilation fix
jhweintraub Sep 13, 2024
05df3b3
update shared snapshot file for burnMintERC20 file
jhweintraub Sep 13, 2024
9e0b93c
linter
jhweintraub Sep 17, 2024
bdccab9
stack cleanup, add Create2, OZ library, comment fixes, etc.
jhweintraub Sep 17, 2024
30eef85
ccip-precommit
jhweintraub Sep 17, 2024
2faa130
add missing vendor files
jhweintraub Sep 17, 2024
9f76e1b
burn mint formatting
jhweintraub Sep 17, 2024
65395df
gas optimizations and formatting cleanup
jhweintraub Sep 18, 2024
58bdf08
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 18, 2024
1e8cbe2
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 20, 2024
8308646
snapshot update
jhweintraub Sep 20, 2024
3301bae
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 23, 2024
ddef2db
quality cleanup
jhweintraub Sep 23, 2024
6dd38d9
linter fix
jhweintraub Sep 23, 2024
f2984cb
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 23, 2024
edc5c27
revert empty parameter flag to the empty byte string
jhweintraub Sep 24, 2024
9c0d776
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 24, 2024
2ee8c29
gas snapshot fix
jhweintraub Sep 24, 2024
0f22eb0
refactor BurnMintERC677 to inherit from BurnMintERC20
jhweintraub Sep 25, 2024
706eb0b
linting
jhweintraub Sep 25, 2024
8c5285e
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 25, 2024
559bfee
fix a weird snapshot issue idek how this happened
jhweintraub Sep 25, 2024
a0982c2
Merge 559bfee2c9a82e1e38437e84de33b0e3820ef8fa into 390ee2334126e313c…
jhweintraub Sep 25, 2024
a997387
Update gethwrappers
app-token-issuer-infra-releng[bot] Sep 25, 2024
729dbb9
snapshotting
jhweintraub Sep 25, 2024
0688f98
formatting
jhweintraub Sep 25, 2024
90ee01d
Revert Changes to shared folders, will be in Chainlink repo
jhweintraub Sep 26, 2024
374b334
Merge 90ee01d2d42b23bc992fc5cd1b861d280761bbdc into 390ee2334126e313c…
jhweintraub Sep 26, 2024
34ac7c6
Update gethwrappers
app-token-issuer-infra-releng[bot] Sep 26, 2024
5c05b9d
remove stateful functions from tokenPoolFactory
jhweintraub Sep 26, 2024
ba1c74c
add support for lock-release pools
jhweintraub Sep 26, 2024
b3dc9c1
add comments and reomve unnec. initArgs parameter
jhweintraub Sep 27, 2024
d69fd9a
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Sep 30, 2024
e78543b
comment cleanup
jhweintraub Sep 30, 2024
bbabb8d
forge fmt
jhweintraub Sep 30, 2024
bf6d75d
CI cleanup
jhweintraub Oct 4, 2024
ae8a3c0
formatting CI is the bane of my existence
jhweintraub Oct 4, 2024
5fda354
fill in end-to-end coverage gaps
jhweintraub Oct 4, 2024
240b70f
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Oct 7, 2024
f03c94d
Merge 240b70f3357127d505ef29b25e2edff7afede58c into f77ff217862989836…
jhweintraub Oct 7, 2024
9f28740
Update gethwrappers
app-token-issuer-infra-releng[bot] Oct 7, 2024
e9da1df
rework lock-release pool deployment to be more stringent
jhweintraub Oct 10, 2024
752c290
when you forget to run the formatter before committing
jhweintraub Oct 10, 2024
a929fed
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Oct 10, 2024
ea77929
gas snapshotting
jhweintraub Oct 10, 2024
7dc40df
remove console log and silence compiler warning
jhweintraub Oct 10, 2024
b1c8c67
another attempt at snapshot fixing
jhweintraub Oct 10, 2024
005861f
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Oct 15, 2024
9355849
snapshot fix after a merge
jhweintraub Oct 15, 2024
7ce7ea7
fix wrapper changes previously
jhweintraub Oct 15, 2024
a8e6726
pragma fix, formatting, and remove unused files
jhweintraub Oct 15, 2024
0bd89b5
more formatting
jhweintraub Oct 15, 2024
ba9c004
formatting and naming fixes
jhweintraub Oct 22, 2024
b198018
Merge branch 'ccip-develop' into feature/selfServeFactory
jhweintraub Oct 22, 2024
d3ab628
*sighs in snapshotting*
jhweintraub Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,12 @@ TokenPoolAndProxy:test_lockOrBurn_lockRelease_Success() (gas: 5793246)
TokenPoolAndProxy:test_setPreviousPool_Success() (gas: 3070731)
TokenPoolAndProxyMigration:test_tokenPoolMigration_Success_1_2() (gas: 6434801)
TokenPoolAndProxyMigration:test_tokenPoolMigration_Success_1_4() (gas: 6634934)
TokenPoolFactoryTests:test_TokenPoolFactory_Constructor_Revert() (gas: 1188046)
TokenPoolFactoryTests:test_createTokenPoolLockRelease_NoExistingToken_predict_Success() (gas: 12420072)
TokenPoolFactoryTests:test_createTokenPool_ExistingRemoteToken_AndPredictPool_Success() (gas: 12434881)
TokenPoolFactoryTests:test_createTokenPool_WithNoExistingRemoteContracts_predict_Success() (gas: 12702418)
TokenPoolFactoryTests:test_createTokenPool_WithNoExistingTokenOnRemoteChain_Success() (gas: 5740593)
TokenPoolFactoryTests:test_createTokenPool_WithRemoteTokenAndRemotePool_Success() (gas: 5880940)
TokenPoolWithAllowList_applyAllowListUpdates:test_AllowListNotEnabled_Revert() (gas: 1979943)
TokenPoolWithAllowList_applyAllowListUpdates:test_OnlyOwner_Revert() (gas: 12113)
TokenPoolWithAllowList_applyAllowListUpdates:test_SetAllowListSkipsZero_Success() (gas: 23476)
Expand Down
14 changes: 7 additions & 7 deletions contracts/gas-snapshots/operatorforwarder.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ FactoryTest:test_DeployNewOperatorAndForwarder_Success() (gas: 4069305)
FactoryTest:test_DeployNewOperator_Success() (gas: 3020464)
ForwarderTest:test_Forward_Success(uint256) (runs: 257, μ: 226979, ~: 227289)
ForwarderTest:test_MultiForward_Success(uint256,uint256) (runs: 257, μ: 258577, ~: 259120)
ForwarderTest:test_OwnerForward_Success() (gas: 30118)
ForwarderTest:test_OwnerForward_Success() (gas: 30096)
ForwarderTest:test_SetAuthorizedSenders_Success() (gas: 160524)
ForwarderTest:test_TransferOwnershipWithMessage_Success() (gas: 35123)
OperatorTest:test_CancelOracleRequest_Success() (gas: 274436)
OperatorTest:test_FulfillOracleRequest_Success() (gas: 330603)
OperatorTest:test_NotAuthorizedSender_Revert() (gas: 246716)
OperatorTest:test_OracleRequest_Success() (gas: 250019)
OperatorTest:test_SendRequestAndCancelRequest_Success(uint96) (runs: 257, μ: 387121, ~: 387124)
OperatorTest:test_SendRequest_Success(uint96) (runs: 257, μ: 303612, ~: 303615)
OperatorTest:test_CancelOracleRequest_Success() (gas: 274295)
OperatorTest:test_FulfillOracleRequest_Success() (gas: 330480)
OperatorTest:test_NotAuthorizedSender_Revert() (gas: 246628)
OperatorTest:test_OracleRequest_Success() (gas: 249843)
OperatorTest:test_SendRequestAndCancelRequest_Success(uint96) (runs: 257, μ: 386787, ~: 386790)
OperatorTest:test_SendRequest_Success(uint96) (runs: 257, μ: 303436, ~: 303439)
14 changes: 14 additions & 0 deletions contracts/src/v0.8/ccip/interfaces/IRegistryModuleOwnerCustom.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.19;
jhweintraub marked this conversation as resolved.
Show resolved Hide resolved

interface IRegistryModuleOwnerCustom {
jhweintraub marked this conversation as resolved.
Show resolved Hide resolved
/// @notice Registers the admin of the token using the `getCCIPAdmin` method.
/// @param token The token to register the admin for.
/// @dev The caller must be the admin returned by the `getCCIPAdmin` method.
function registerAdminViaGetCCIPAdmin(address token) external;

/// @notice Registers the admin of the token using the `owner` method.
/// @param token The token to register the admin for.
/// @dev The caller must be the admin returned by the `owner` method.
function registerAdminViaOwner(address token) external;
}
18 changes: 18 additions & 0 deletions contracts/src/v0.8/ccip/interfaces/ITokenAdminRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,22 @@ interface ITokenAdminRegistry {
/// @param localToken The token to register the administrator for.
/// @param administrator The administrator to register.
function proposeAdministrator(address localToken, address administrator) external;

/// @notice Accepts the administrator role for a token.
/// @param localToken The token to accept the administrator role for.
/// @dev This function can only be called by the pending administrator.
function acceptAdminRole(address localToken) external;

/// @notice Sets the pool for a token. Setting the pool to address(0) effectively delists the token
/// from CCIP. Setting the pool to any other address enables the token on CCIP.
/// @param localToken The token to set the pool for.
/// @param pool The pool to set for the token.
function setPool(address localToken, address pool) external;

/// @notice Transfers the administrator role for a token to a new address with a 2-step process.
/// @param localToken The token to transfer the administrator role for.
/// @param newAdmin The address to transfer the administrator role to. Can be address(0) to cancel
/// a pending transfer.
/// @dev The new admin must call `acceptAdminRole` to accept the role.
function transferAdminRole(address localToken, address newAdmin) external;
}
76 changes: 58 additions & 18 deletions contracts/src/v0.8/ccip/test/legacy/TokenPoolAndProxy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,12 @@ contract TokenPoolAndProxy is EVM2EVMOnRampSetup {
}

function test_lockOrBurn_burnWithFromMint_Success() public {
s_pool =
new BurnWithFromMintTokenPoolAndProxy(s_token, new address[](0), address(s_mockRMN), address(s_sourceRouter));
s_pool = new BurnWithFromMintTokenPoolAndProxy(
jhweintraub marked this conversation as resolved.
Show resolved Hide resolved
s_token,
new address[](0),
address(s_mockRMN),
address(s_sourceRouter)
);
_configurePool();
_deployOldPool();
_assertLockOrBurnCorrect();
Expand All @@ -374,8 +378,13 @@ contract TokenPoolAndProxy is EVM2EVMOnRampSetup {
}

function test_lockOrBurn_lockRelease_Success() public {
s_pool =
new LockReleaseTokenPoolAndProxy(s_token, new address[](0), address(s_mockRMN), false, address(s_sourceRouter));
s_pool = new LockReleaseTokenPoolAndProxy(
s_token,
new address[](0),
address(s_mockRMN),
false,
address(s_sourceRouter)
);
_configurePool();
_deployOldPool();
_assertLockOrBurnCorrect();
Expand All @@ -391,11 +400,17 @@ contract TokenPoolAndProxy is EVM2EVMOnRampSetup {
s_token.grantMintAndBurnRoles(address(s_legacyPool));

TokenPool1_2.RampUpdate[] memory onRampUpdates = new TokenPool1_2.RampUpdate[](1);
onRampUpdates[0] =
TokenPool1_2.RampUpdate({ramp: address(s_pool), allowed: true, rateLimiterConfig: _getInboundRateLimiterConfig()});
onRampUpdates[0] = TokenPool1_2.RampUpdate({
ramp: address(s_pool),
allowed: true,
rateLimiterConfig: _getInboundRateLimiterConfig()
});
TokenPool1_2.RampUpdate[] memory offRampUpdates = new TokenPool1_2.RampUpdate[](1);
offRampUpdates[0] =
TokenPool1_2.RampUpdate({ramp: address(s_pool), allowed: true, rateLimiterConfig: _getInboundRateLimiterConfig()});
offRampUpdates[0] = TokenPool1_2.RampUpdate({
ramp: address(s_pool),
allowed: true,
rateLimiterConfig: _getInboundRateLimiterConfig()
});
BurnMintTokenPool1_2(address(s_legacyPool)).applyRampUpdates(onRampUpdates, offRampUpdates);
}

Expand Down Expand Up @@ -506,8 +521,13 @@ contract TokenPoolAndProxy is EVM2EVMOnRampSetup {
}

function test_setPreviousPool_Success() public {
LockReleaseTokenPoolAndProxy pool =
new LockReleaseTokenPoolAndProxy(s_token, new address[](0), address(s_mockRMN), true, address(s_sourceRouter));
LockReleaseTokenPoolAndProxy pool = new LockReleaseTokenPoolAndProxy(
s_token,
new address[](0),
address(s_mockRMN),
true,
address(s_sourceRouter)
);

assertEq(pool.getPreviousPool(), address(0));

Expand Down Expand Up @@ -539,13 +559,23 @@ contract LockReleaseTokenPoolAndProxySetup is RouterSetup {
RouterSetup.setUp();
s_token = new BurnMintERC677("LINK", "LNK", 18, 0);
deal(address(s_token), OWNER, type(uint256).max);
s_lockReleaseTokenPoolAndProxy =
new LockReleaseTokenPoolAndProxy(s_token, new address[](0), address(s_mockRMN), true, address(s_sourceRouter));
s_lockReleaseTokenPoolAndProxy = new LockReleaseTokenPoolAndProxy(
s_token,
new address[](0),
address(s_mockRMN),
true,
address(s_sourceRouter)
);

s_allowedList.push(USER_1);
s_allowedList.push(DUMMY_CONTRACT_ADDRESS);
s_lockReleaseTokenPoolAndProxyWithAllowList =
new LockReleaseTokenPoolAndProxy(s_token, s_allowedList, address(s_mockRMN), true, address(s_sourceRouter));
s_lockReleaseTokenPoolAndProxyWithAllowList = new LockReleaseTokenPoolAndProxy(
s_token,
s_allowedList,
address(s_mockRMN),
true,
address(s_sourceRouter)
);

TokenPool.ChainUpdate[] memory chainUpdate = new TokenPool.ChainUpdate[](1);
chainUpdate[0] = TokenPool.ChainUpdate({
Expand Down Expand Up @@ -588,8 +618,13 @@ contract LockReleaseTokenPoolPoolAndProxy_canAcceptLiquidity is LockReleaseToken
function test_CanAcceptLiquidity_Success() public {
assertEq(true, s_lockReleaseTokenPoolAndProxy.canAcceptLiquidity());

s_lockReleaseTokenPoolAndProxy =
new LockReleaseTokenPoolAndProxy(s_token, new address[](0), address(s_mockRMN), false, address(s_sourceRouter));
s_lockReleaseTokenPoolAndProxy = new LockReleaseTokenPoolAndProxy(
s_token,
new address[](0),
address(s_mockRMN),
false,
address(s_sourceRouter)
);
assertEq(false, s_lockReleaseTokenPoolAndProxy.canAcceptLiquidity());
}
}
Expand Down Expand Up @@ -621,8 +656,13 @@ contract LockReleaseTokenPoolPoolAndProxy_provideLiquidity is LockReleaseTokenPo
}

function test_LiquidityNotAccepted_Revert() public {
s_lockReleaseTokenPoolAndProxy =
new LockReleaseTokenPoolAndProxy(s_token, new address[](0), address(s_mockRMN), false, address(s_sourceRouter));
s_lockReleaseTokenPoolAndProxy = new LockReleaseTokenPoolAndProxy(
s_token,
new address[](0),
address(s_mockRMN),
false,
address(s_sourceRouter)
);

vm.expectRevert(LockReleaseTokenPoolAndProxy.LiquidityNotAccepted.selector);
s_lockReleaseTokenPoolAndProxy.provideLiquidity(1);
Expand Down
Loading
Loading