Skip to content

Commit 85b9c80

Browse files
authored
[eth] Add Canto mainnet (#751)
* [eth] Add Canto mainnet This deployment also enables contract rewards on canto. Since the changed code is only specific to the Canto network and is used only in initialization, only the diff is added as a file. * Remove ds store * Add some doc to deploying.md
1 parent 71da520 commit 85b9c80

File tree

9 files changed

+102
-2
lines changed

9 files changed

+102
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ tsconfig.tsbuildinfo
1717
*~
1818
*mnemonic*
1919
.envrc
20+
.DS_Store

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
MIGRATIONS_DIR=./migrations/prod-receiver
2+
MIGRATIONS_NETWORK=canto
3+
WORMHOLE_CHAIN_NAME=canto
4+
CLUSTER=mainnet
5+
VALID_TIME_PERIOD_SECONDS=60

target_chains/ethereum/contracts/Deploying.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,12 @@ contract or a new contract do the following steps in addition to the steps descr
204204
5. If you wish to deploy the contract run `npx hardhat deploy-zksync --network <network> --script deploy/zkSyncDeploy` to deploy it to the new network. Otherwise
205205
run `npx hardhat deploy-zksync --network <network> --script deploy/zkSyncDeployNewPythImpl.ts` to get a new implementation address. Then put it in
206206
`.<network>.new_impl` file and run the deployment script to handle the rest of the changes.
207+
208+
# Deploy/Upgrade on Canto
209+
210+
Canto network rewards some percentage of the gas usage to the contracts. To enable the rewards we have modified the contract upon
211+
deployment to register its own address as the receiver of the rewards and also assigned Pyth to received Wormhole Receiver rewards
212+
too. The registration only happens once for contract. The contracts are registered with token id 654. We don't need to register
213+
the contracts upon upgrades because the proxy address doesn't change. The contract changes for registration are stored in
214+
[this diff](./canto-deployment-patch.diff) for future reference. Please note that if we switch to another Wormhole Receiver
215+
(a new address) we will need to register the new contract.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
diff --git a/target_chains/ethereum/contracts/contracts/pyth/PythUpgradable.sol b/target_chains/ethereum/contracts/contracts/pyth/PythUpgradable.sol
2+
index 7f9a2a22..fa04031b 100644
3+
--- a/target_chains/ethereum/contracts/contracts/pyth/PythUpgradable.sol
4+
+++ b/target_chains/ethereum/contracts/contracts/pyth/PythUpgradable.sol
5+
@@ -13,6 +13,10 @@ import "./PythGovernance.sol";
6+
import "./Pyth.sol";
7+
import "@pythnetwork/pyth-sdk-solidity/PythErrors.sol";
8+
9+
+interface ITurnstile {
10+
+ function register(address) external returns(uint256);
11+
+}
12+
+
13+
contract PythUpgradable is
14+
Initializable,
15+
OwnableUpgradeable,
16+
@@ -45,6 +49,10 @@ contract PythUpgradable is
17+
);
18+
19+
renounceOwnership();
20+
+
21+
+ uint256 csrTokenId = ITurnstile(0xEcf044C5B4b867CFda001101c617eCd347095B44)
22+
+ .register(address(this));
23+
+ PythGetters.wormhole().assignCsr(csrTokenId);
24+
}
25+
26+
/// Ensures the contract cannot be uninitialized and taken over.
27+
diff --git a/target_chains/ethereum/contracts/contracts/wormhole-receiver/ReceiverImplementation.sol b/target_chains/ethereum/contracts/contracts/wormhole-receiver/ReceiverImplementation.sol
28+
index 4b2fc3c5..f003c602 100644
29+
--- a/target_chains/ethereum/contracts/contracts/wormhole-receiver/ReceiverImplementation.sol
30+
+++ b/target_chains/ethereum/contracts/contracts/wormhole-receiver/ReceiverImplementation.sol
31+
@@ -8,6 +8,10 @@ import "./ReceiverGovernance.sol";
32+
33+
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol";
34+
35+
+interface ITurnstile {
36+
+ function assign(uint256) external returns(uint256);
37+
+}
38+
+
39+
contract ReceiverImplementation is ReceiverGovernance {
40+
modifier initializer() {
41+
address implementation = ERC1967Upgrade._getImplementation();
42+
@@ -26,4 +30,11 @@ contract ReceiverImplementation is ReceiverGovernance {
43+
receive() external payable {
44+
revert("the Wormhole Receiver contract does not accept assets");
45+
}
46+
+
47+
+ function assignCsr(uint256 tokenId) external {
48+
+ // This call will register the contract with the Turnstile and assign the
49+
+ // given token ID as it's CSR owner. One it is called, it is registered
50+
+ // and subsequent calls will fail.
51+
+ ITurnstile(0xEcf044C5B4b867CFda001101c617eCd347095B44).assign(tokenId);
52+
+ }
53+
}
54+
diff --git a/target_chains/ethereum/contracts/contracts/wormhole/interfaces/IWormhole.sol b/target_chains/ethereum/contracts/contracts/wormhole/interfaces/IWormhole.sol
55+
index 69d60a62..d6230fde 100644
56+
--- a/target_chains/ethereum/contracts/contracts/wormhole/interfaces/IWormhole.sol
57+
+++ b/target_chains/ethereum/contracts/contracts/wormhole/interfaces/IWormhole.sol
58+
@@ -62,4 +62,6 @@ interface IWormhole is Structs {
59+
function governanceContract() external view returns (bytes32);
60+
61+
function messageFee() external view returns (uint256);
62+
+
63+
+ function assignCsr(uint256 tokenId) external;
64+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
{
3+
"contractName": "Migrations",
4+
"address": "0x35a58BeeE77a2Ad547FcDed7e8CB1c6e19746b13"
5+
},
6+
{
7+
"contractName": "WormholeReceiver",
8+
"address": "0x87047526937246727E4869C5f76A347160e08672",
9+
"transactionHash": "0xe5eddf3e86dbbfff23e61bfb5e4abe5371877fd0383d506e5f428ffaaf70425b"
10+
},
11+
{
12+
"contractName": "PythUpgradable",
13+
"address": "0x98046Bd286715D3B0BC227Dd7a956b83D8978603",
14+
"transactionHash": "0x76b646e974d2017101cc65a278cf1c306c401fb85d126eede11703d18c1c86ef"
15+
}
16+
]

target_chains/ethereum/contracts/truffle-config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ module.exports = {
160160
timeoutBlocks: 200,
161161
disableConfirmationListener: true,
162162
},
163+
canto: {
164+
provider: payerProvider(`https://canto.gravitychain.io`),
165+
network_id: 7700,
166+
},
163167
celo: {
164168
provider: payerProvider(`https://forno.celo.org`),
165169
network_id: 42220,

target_chains/ethereum/sdk/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-evm-js",
3-
"version": "1.15.0",
3+
"version": "1.16.0",
44
"description": "Pyth Network EVM Utils in JS",
55
"homepage": "https://pyth.network",
66
"author": {

target_chains/ethereum/sdk/js/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const CONTRACT_ADDR: Record<string, string> = {
4242
neon_devnet: "0x2FF312f50689ad279ABb164dB255Eb568733BD6c",
4343
polygon_zkevm_testnet: "0xd54bf1758b1C932F86B178F8b1D5d1A7e2F62C2E",
4444
polygon_zkevm: "0xC5E56d6b40F3e3B5fbfa266bCd35C37426537c65",
45+
canto: "0x98046Bd286715D3B0BC227Dd7a956b83D8978603",
4546
canto_testnet: "0xA2aa501b19aff244D90cc15a4Cf739D2725B5729",
4647
meter_testnet: "0x5fF5B9039FbD8256864A4460B7EA77093A65B1b5",
4748
meter: "0xbFe3f445653f2136b2FD1e6DdDb5676392E3AF16",

0 commit comments

Comments
 (0)