Skip to content

Commit 889c38f

Browse files
authored
evm: modernize upgrade path (#79)
Co-authored-by: gator-boi <gator-boi@users.noreply.github.com>
1 parent 12e0896 commit 889c38f

28 files changed

+904
-412
lines changed

evm/Makefile

-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ all: build
88
unit-test: build
99
forge test --fork-url ${AVAX_RPC} -vv
1010

11-
#integration-test: ts/tests/.env build
1211
.PHONY: integration-test
1312
integration-test: node_modules ts/tests/.env
1413
bash ts/tests/run_integration_test.sh
@@ -36,9 +35,3 @@ clean:
3635

3736
node_modules:
3837
npm ci
39-
40-
# lib/forge-std:
41-
# forge install foundry-rs/forge-std@v1.6.1 --no-git --no-commit
42-
43-
# lib/openzeppelin-contracts:
44-
# forge install openzeppelin/openzeppelin-contracts@v4.8.1 --no-git --no-commit

evm/env/localnet/avalanche.env

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ export RELEASE_FEE_RECIPIENT_ADDRESS=0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6E
4343

4444

4545
### Token Router Proxy (evm address)
46-
export RELEASE_TOKEN_ROUTER_ADDRESS=0x438fDf069b811b871280AECd130D58ab6EC5c0Bc
46+
export RELEASE_TOKEN_ROUTER_ADDRESS=0x2adf8B30d4Dd24a05Ccd9aFbDc06A5b49C9c758d
4747

4848

4949
############################### Matching Engine ###############################
5050

5151

5252
### Matching Engine Proxy (universal evm address)
5353
export RELEASE_MATCHING_ENGINE_CHAIN=6
54-
export RELEASE_MATCHING_ENGINE_ADDRESS=0x000000000000000000000000B9c90045934D8AdBc665BC5D77c5F8C112F2a2ca
55-
export RELEASE_MATCHING_ENGINE_MINT_RECIPIENT=0x000000000000000000000000B9c90045934D8AdBc665BC5D77c5F8C112F2a2ca
54+
export RELEASE_MATCHING_ENGINE_ADDRESS=0x00000000000000000000000027D44c7337ce4D67b7cd573e9c36bDEED2b2162a
55+
export RELEASE_MATCHING_ENGINE_MINT_RECIPIENT=0x00000000000000000000000027D44c7337ce4D67b7cd573e9c36bDEED2b2162a
5656
export RELEASE_MATCHING_ENGINE_DOMAIN=1
5757

5858

evm/env/localnet/base.env

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ export RELEASE_OWNER_ASSISTANT_ADDRESS=0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6
3636

3737

3838
### Token Router Proxy (evm address)
39-
export RELEASE_TOKEN_ROUTER_ADDRESS=0xB9c90045934D8AdBc665BC5D77c5F8C112F2a2ca
39+
export RELEASE_TOKEN_ROUTER_ADDRESS=0x27D44c7337ce4D67b7cd573e9c36bDEED2b2162a
4040

4141

4242
############################### Matching Engine ###############################
4343

4444

4545
### Matching Engine Proxy (universal evm address)
4646
export RELEASE_MATCHING_ENGINE_CHAIN=6
47-
export RELEASE_MATCHING_ENGINE_ADDRESS=0x000000000000000000000000B9c90045934D8AdBc665BC5D77c5F8C112F2a2ca
48-
export RELEASE_MATCHING_ENGINE_MINT_RECIPIENT=0x000000000000000000000000B9c90045934D8AdBc665BC5D77c5F8C112F2a2ca
47+
export RELEASE_MATCHING_ENGINE_ADDRESS=0x00000000000000000000000027D44c7337ce4D67b7cd573e9c36bDEED2b2162a
48+
export RELEASE_MATCHING_ENGINE_MINT_RECIPIENT=0x00000000000000000000000027D44c7337ce4D67b7cd573e9c36bDEED2b2162a
4949
export RELEASE_MATCHING_ENGINE_DOMAIN=1

evm/env/localnet/ethereum.env

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ export RELEASE_OWNER_ASSISTANT_ADDRESS=0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6
3636

3737

3838
### Token Router Proxy (evm address)
39-
export RELEASE_TOKEN_ROUTER_ADDRESS=0xd98bfe6915cE92D4915149941246d36504125501
39+
export RELEASE_TOKEN_ROUTER_ADDRESS=0xEeB3A6143B71b9eBc867479f2cf57DB0bE4604C2
4040

4141

4242
############################### Matching Engine ###############################
4343

4444

4545
### Matching Engine Proxy (universal evm address)
4646
export RELEASE_MATCHING_ENGINE_CHAIN=6
47-
export RELEASE_MATCHING_ENGINE_ADDRESS=0x000000000000000000000000B9c90045934D8AdBc665BC5D77c5F8C112F2a2ca
48-
export RELEASE_MATCHING_ENGINE_MINT_RECIPIENT=0x000000000000000000000000B9c90045934D8AdBc665BC5D77c5F8C112F2a2ca
47+
export RELEASE_MATCHING_ENGINE_ADDRESS=0x00000000000000000000000027D44c7337ce4D67b7cd573e9c36bDEED2b2162a
48+
export RELEASE_MATCHING_ENGINE_MINT_RECIPIENT=0x00000000000000000000000027D44c7337ce4D67b7cd573e9c36bDEED2b2162a
4949
export RELEASE_MATCHING_ENGINE_DOMAIN=1

evm/forge/scripts/DeployMatchingEngineContract.s.sol

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import "forge-std/console2.sol";
77

88
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
99

10-
import {MatchingEngineSetup} from "src/MatchingEngine/MatchingEngineSetup.sol";
11-
import {MatchingEngineImplementation} from
12-
"src/MatchingEngine/MatchingEngineImplementation.sol";
10+
import {MatchingEngine} from
11+
"src/MatchingEngine/MatchingEngine.sol";
1312

1413
import {CheckWormholeContracts} from "./helpers/CheckWormholeContracts.sol";
1514

@@ -29,10 +28,10 @@ contract DeployMatchingEngineContracts is CheckWormholeContracts, Script {
2928
uint8 immutable _auctionGracePeriod = uint8(vm.envUint("RELEASE_GRACE_PERIOD"));
3029
uint8 immutable _auctionPenaltyBlocks = uint8(vm.envUint("RELEASE_PENALTY_BLOCKS"));
3130

32-
function deploy() public {
31+
function deployAndConfigure() public {
3332
requireValidChain(_chainId, _wormhole);
3433

35-
MatchingEngineImplementation implementation = new MatchingEngineImplementation(
34+
MatchingEngine implementation = new MatchingEngine(
3635
_token,
3736
_wormhole,
3837
_cctpTokenMessenger,
@@ -43,19 +42,20 @@ contract DeployMatchingEngineContracts is CheckWormholeContracts, Script {
4342
_auctionPenaltyBlocks
4443
);
4544

46-
MatchingEngineSetup setup = new MatchingEngineSetup();
47-
address proxy =
48-
setup.deployProxy(address(implementation), _ownerAssistantAddress, _feeRecipientAddress);
45+
MatchingEngine proxy =
46+
MatchingEngine(address(new ERC1967Proxy(address(implementation), "")));
4947

50-
console2.log("Deployed MatchingEngine (chain=%s): %s", _chainId, proxy);
48+
proxy.initialize(abi.encodePacked(_ownerAssistantAddress, _feeRecipientAddress));
49+
50+
console2.log("Deployed MatchingEngine (chain=%s): %s", _chainId, address(proxy));
5151
}
5252

5353
function run() public {
5454
// Begin sending transactions.
5555
vm.startBroadcast();
5656

57-
// Deploy setup, implementation and erc1967 proxy.
58-
deploy();
57+
// Deploy proxy and initialize.
58+
deployAndConfigure();
5959

6060
// Done.
6161
vm.stopBroadcast();

evm/forge/scripts/DeployTokenRouterContracts.s.sol

+10-9
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import "forge-std/console2.sol";
77

88
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
99

10-
import {TokenRouterSetup} from "src/TokenRouter/TokenRouterSetup.sol";
11-
import {TokenRouterImplementation} from "src/TokenRouter/TokenRouterImplementation.sol";
10+
import {TokenRouter} from "src/TokenRouter/TokenRouter.sol";
1211

1312
import {CheckWormholeContracts} from "./helpers/CheckWormholeContracts.sol";
1413

@@ -29,10 +28,10 @@ contract DeployTokenRouterContracts is CheckWormholeContracts, Script {
2928
uint16 immutable _matchingEngineChain = uint16(vm.envUint("RELEASE_MATCHING_ENGINE_CHAIN"));
3029
uint32 immutable _matchingEngineDomain = uint32(vm.envUint("RELEASE_MATCHING_ENGINE_DOMAIN"));
3130

32-
function deploy() public {
31+
function deployAndConfigure() public {
3332
requireValidChain(_chainId, _wormhole);
3433

35-
TokenRouterImplementation implementation = new TokenRouterImplementation(
34+
TokenRouter implementation = new TokenRouter(
3635
_token,
3736
_wormhole,
3837
_cctpTokenMessenger,
@@ -42,18 +41,20 @@ contract DeployTokenRouterContracts is CheckWormholeContracts, Script {
4241
_matchingEngineDomain
4342
);
4443

45-
TokenRouterSetup setup = new TokenRouterSetup();
46-
address proxy = setup.deployProxy(address(implementation), _ownerAssistantAddress);
44+
TokenRouter proxy =
45+
TokenRouter(address(new ERC1967Proxy(address(implementation), "")));
4746

48-
console2.log("Deployed TokenRouter (chain=%s): %s", _chainId, proxy);
47+
proxy.initialize(abi.encodePacked(_ownerAssistantAddress));
48+
49+
console2.log("Deployed TokenRouter (chain=%s): %s", _chainId, address(proxy));
4950
}
5051

5152
function run() public {
5253
// Begin sending transactions.
5354
vm.startBroadcast();
5455

55-
// Deploy setup, implementation and erc1967 proxy.
56-
deploy();
56+
// Deploy proxy and initialize.
57+
deployAndConfigure();
5758

5859
// Done.
5960
vm.stopBroadcast();

evm/forge/scripts/UpgradeMatchingEngine.s.sol

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import "forge-std/console2.sol";
88
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
99
import {IMatchingEngine} from "src/interfaces/IMatchingEngine.sol";
1010

11-
import {MatchingEngineSetup} from "src/MatchingEngine/MatchingEngineSetup.sol";
12-
import {MatchingEngineImplementation} from
13-
"src/MatchingEngine/MatchingEngineImplementation.sol";
11+
import {MatchingEngine} from
12+
"src/MatchingEngine/MatchingEngine.sol";
1413

1514
import {CheckWormholeContracts} from "./helpers/CheckWormholeContracts.sol";
1615

@@ -36,7 +35,7 @@ contract UpgradeMatchingEngine is CheckWormholeContracts, Script {
3635
function upgrade() public {
3736
requireValidChain(_chainId, _wormhole);
3837

39-
MatchingEngineImplementation implementation = new MatchingEngineImplementation(
38+
MatchingEngine implementation = new MatchingEngine(
4039
_token,
4140
_wormhole,
4241
_cctpTokenMessenger,

evm/forge/scripts/UpgradeTokenRouter.s.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pragma solidity ^0.8.19;
55
import "forge-std/Script.sol";
66
import "forge-std/console2.sol";
77

8-
import {TokenRouterImplementation} from "src/TokenRouter/TokenRouterImplementation.sol";
8+
import {TokenRouter} from "src/TokenRouter/TokenRouter.sol";
99
import {ITokenRouter} from "src/interfaces/ITokenRouter.sol";
1010

1111
import {CheckWormholeContracts} from "./helpers/CheckWormholeContracts.sol";
@@ -30,7 +30,7 @@ contract UpgradeTokenRouter is CheckWormholeContracts, Script {
3030
function upgrade() public {
3131
requireValidChain(_chainId, _wormhole);
3232

33-
TokenRouterImplementation implementation = new TokenRouterImplementation(
33+
TokenRouter implementation = new TokenRouter(
3434
_token,
3535
_wormhole,
3636
_cctpTokenMessenger,

0 commit comments

Comments
 (0)