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

redeploying contracts #55

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resolution = true
skip-lint = true

[programs.localnet]
token_bridge_relayer = "AttbEYJMSsnVRDcKY4AcX1GBcdPy9FzHcxTbKaMGGuLs"
token_bridge_relayer = "ATT7enfWTMV4dDTe2NQ2yBaTByuXXwrYRznsioQEUW6r"

[[test.genesis]]
address = "ATqjh2vkjogyVUUNmXQssQZNSFGgSA7Tm6P1UzEUg85s" # Mainnet in lib.rs
Expand Down
5 changes: 4 additions & 1 deletion deployment/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.env*
.env*

[aA][tT][bB]*.json
[aA][tT][tT]*.json
38 changes: 30 additions & 8 deletions deployment/config/testnet/contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,41 @@
},
{
"chainId": 10005,
"address": "0xc8D48E0D4AcdDdfd33273d1D37C41DcAcD1674E8",
"address": "0x8899B06745dDF4E6A8244884adA36C88529513Cd",
"constructorArgs": [
"0x000000000022D473030F116dDEE9F6B43aC78BA3",
"0x99737Ec4B815d816c49A385943baf0380e75c0Ac",
"0x82EA95b20845D3766830182952851B19FDA08f00",
"0x28AE4263188569050bf07be244096caa5Df1a79A",
"0x4200000000000000000000000000000000000006",
true
]
},
{
"chainId": 10004,
"address": "0x166dbA9e12400DbbC4Df49087D2c360D6d3BA83c",
"address": "0x515E26B32f3EFb16D40b00b4317CB1D2e9B4D18E",
"constructorArgs": [
"0x000000000022D473030F116dDEE9F6B43aC78BA3",
"0x86F55A04690fd7815A3D802bD587e83eA888B239",
"0xB1bde3578517ff5D704c6fFb4c1475047505aa17",
"0xbeA923D6693Ca71889Dec69946F450F00E1a868a",
"0x4200000000000000000000000000000000000006",
true
]
},
{
"chainId": 1,
"address": "AttbEYJMSsnVRDcKY4AcX1GBcdPy9FzHcxTbKaMGGuLs",
"address": "ATT7enfWTMV4dDTe2NQ2yBaTByuXXwrYRznsioQEUW6r",
"constructorArgs": []
},
{
"chainId": 14,
"address": "0x5b5dfD8781A83314196DC458329d4d0525Cd10d4",
"constructorArgs": [
"0x000000000022D473030F116dDEE9F6B43aC78BA3",
"0x05ca6037eC51F8b712eD2E6Fa72219FEaE74E153",
"0x1EA112f9bE384F19D11c883732150De6Bf718E03",
"0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9",
true
]
}
],
"TbrV3Proxies": [
Expand All @@ -47,12 +58,23 @@
},
{
"chainId": 10005,
"address": "0xb620f38B1211bDB96684576017F66bA9871eb6be",
"constructorArgs": []
"address": "0x7057447A58b92e2C68A46548B6992203233e92eC",
"constructorArgs": [
"0x8899B06745dDF4E6A8244884adA36C88529513Cd",
"0x6f9b66c711a46d9c37706396ec8444bf6c8e7b176f9b66c711a46d9c37706396ec8444bf6c8e7b176f9b66c711a46d9c37706396ec8444bf6c8e7b17"
]
},
{
"chainId": 10004,
"address": "0x3ddc4d19D05Caf86F70BcF55BdDA5B683E56b2Ae",
"address": "0xFe8dE1cf8893f0D928F007E787fD072660EAc06B",
"constructorArgs": [
"0x515E26B32f3EFb16D40b00b4317CB1D2e9B4D18E",
"0x6f9b66c711a46d9c37706396ec8444bf6c8e7b176f9b66c711a46d9c37706396ec8444bf6c8e7b176f9b66c711a46d9c37706396ec8444bf6c8e7b17"
]
},
{
"chainId": 14,
"address": "0xdbe75EfF77dF67524B13c38e07d2451456098DC7",
"constructorArgs": []
}
]
Expand Down
12 changes: 9 additions & 3 deletions deployment/config/testnet/dependencies.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
[
{
"chainId": 14,
"permit2": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"oracle": "0x1EA112f9bE384F19D11c883732150De6Bf718E03",
"initGasToken": "0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9"
},
{
"chainId": 10002,
"permit2": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"oracle": "0x466B4Daf328DE4C8b46b78a62867341ECBfA7bc6",
"oracle": "0xC26b5b530F001e00F67ad7B4f7c33003fA72C65b",
"initGasToken": "0x7b79995e5f793a07bc00c21412e50ecae098e7f9"
},
{
Expand All @@ -14,13 +20,13 @@
{
"chainId": 10004,
"permit2": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"oracle": "0xB1bde3578517ff5D704c6fFb4c1475047505aa17",
"oracle": "0xbeA923D6693Ca71889Dec69946F450F00E1a868a",
"initGasToken": "0x4200000000000000000000000000000000000006"
},
{
"chainId": 10005,
"permit2": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"oracle": "0x82EA95b20845D3766830182952851B19FDA08f00",
"oracle": "0x28AE4263188569050bf07be244096caa5Df1a79A",
"initGasToken": "0x4200000000000000000000000000000000000006"
},
{
Expand Down
10 changes: 9 additions & 1 deletion deployment/config/testnet/ecosystem.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"operatingChains": [1, 10002],
"operatingChains": [1, 14, 10004, 10005],
"evm": {
"networks": [
{
"name": "Celo",
"externalId": 44787,
"chainId": 14,
"rpc": "https://alfajores-forno.celo-testnet.org",
"network": "Testnet",
"wormholeAddress": "0x88505117CA88e7dd2eC6EA1E13f0948db2D50D56"
},
{
"name": "Sepolia",
"externalId": 11155111,
Expand Down
7 changes: 7 additions & 0 deletions deployment/config/testnet/tbr-v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
"evmTransactionSize": "1000",
"evmTransactionGas": "1000"
},
{
"chainId": 14,
"initGasErc20TokenizationIsExplicit": false,
"relayFee": 1,
"maxGasDropoff": 0.1,
"txSizeSensitive": true
},
{
"chainId": 10002,
"initGasErc20TokenizationIsExplicit": true,
Expand Down
3 changes: 2 additions & 1 deletion deployment/evm/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "../helpers";
import { EvmTbrV3Config } from "../config/config.types";
import { ethers } from "ethers";
import { encoding } from "@wormhole-foundation/sdk-base";
import { Tbr__factory, Proxy__factory } from "../ethers-contracts/index.js";
import { getSigner } from "../helpers/evm";

Expand Down Expand Up @@ -137,7 +138,7 @@ async function deployProxy(
}
const address = await contract.getAddress();
console.log("Successfully deployed proxy at " + address);
return { address, chainId: chain.chainId, constructorArgs: [implementationAddress, proxyConstructorArgs] };
return { address, chainId: chain.chainId, constructorArgs: [implementationAddress, encoding.hex.encode(proxyConstructorArgs, true)] };
}


Expand Down
1 change: 0 additions & 1 deletion deployment/evm/read-configured-fee-and-dropoff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from "../helpers/index.js";
import { chainIdToChain } from "@wormhole-foundation/sdk-base";
import { SupportedChains, Tbrv3 } from "@xlabs-xyz/evm-arbitrary-token-transfers";
import { ethers } from "ethers";

/**
* Reads the configured relay fee and max gas dropoff for Tbrv3 contracts
Expand Down
23 changes: 14 additions & 9 deletions deployment/solana/deploy-playbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ cd deployment && \
#

#
# ❗❗❗ make sure to
#
# ❗❗❗ make sure to have all of the following env variables set
# - solana_rpc_url
# - deployer_account: public key for deployer
# - buffer_creator_account: path to private key json, leaving .json out, ex: "/home/user/.config/solana/devnet"
# - buffer_account: public key of the key generated in step 1 starting with atb
# - program_address: public key of the program generated in step 1 starting with att
# - key_path: path to private key json, if using ledger -> key_path="usb://ledger key=$ledger_cli_derivation_path"

set -o allexport && source ./deployment/.env.testnet

Expand All @@ -36,21 +41,21 @@ solana program set-buffer-authority $buffer_account \

# If extending the program memory is required:
# solana program show $program_address --url $solana_rpc_url
# solana program extend $program_address 100000 --url $solana_rpc_url -k usb://ledger?key=$ledger_cli_derivation_path
# solana program extend $program_address 100000 --url $solana_rpc_url -k $key_path

solana program -k usb://ledger?key=$ledger_cli_derivation_path deploy \
solana program -k $key_path deploy \
--url $solana_rpc_url \
--buffer $buffer_account.json \
--program-id $program_address.json

anchor idl init --provider.cluster=$solana_rpc_url \
--provider.wallet "./deployment/$buffer_creator_account.json" \
--provider.wallet "$buffer_creator_account.json" \
--filepath ./target/idl/token_bridge_relayer.json $program_address

yarn tsx ./solana/initialize.ts && \
yarn tsx ./solana/configure.ts && \
yarn tsx ./solana/unpause-contract.ts

yarn tsx ./solana/initialize.ts
yarn tsx ./solana/configure.ts
yarn tsx ./solana/register-peers.ts
yarn tsx ./solana/unpause-contract.ts


```
26 changes: 17 additions & 9 deletions deployment/solana/read-configuration.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Chain } from "@wormhole-foundation/sdk-base";
import { SolanaTokenBridgeRelayer } from '@xlabs-xyz/solana-arbitrary-token-transfers';
import { runOnSolana, getConnection, SolanaSigner } from '../helpers/solana.js';
import { SolanaChainInfo, LoggerFn } from '../helpers/interfaces.js';
import { dependencies } from '../helpers/env.js';
import { dependencies, ecosystemChains } from '../helpers/env.js';
import { PublicKey } from '@solana/web3.js';
import { inspect } from 'util';

runOnSolana('initialize-tbr', initializeSolanaTbr).catch((e) => {
runOnSolana('read-chain-configs', readChainConfig).catch((e) => {
console.error('Error executing script: ', e);
});

async function initializeSolanaTbr(
async function readChainConfig(
chain: SolanaChainInfo,
signer: SolanaSigner,
log: LoggerFn,
): Promise<void> {
console.log('hello?');
const signerKey = new PublicKey(await signer.getAddress());
log('reading solana chain configs');
const connection = getConnection(chain);
const solanaDependencies = dependencies.find((d) => d.chainId === chain.chainId);
if (solanaDependencies === undefined) {
Expand All @@ -29,9 +29,17 @@ async function initializeSolanaTbr(
},
);

const config = await tbr.read.chainConfig('Sepolia');
ecosystemChains.evm.networks.forEach(async (chain) => {
try {
log('reading chain config', chain.name);
const config = await tbr.read.chainConfig(chain.name as Chain);

const peer = Buffer.from(config.canonicalPeer).toString('hex');
console.log('config', inspect(config));
console.log('peer', peer);
const peer = Buffer.from(config.canonicalPeer).toString('hex');
log(`config for ${chain.name}`, inspect(config));
log(`peer for ${chain.name} is`, peer);
} catch (e) {
log(`error reading chain config for ${chain.name}`, e);
}

});
}
2 changes: 1 addition & 1 deletion sdk/solana/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xlabs-xyz/solana-arbitrary-token-transfers",
"version": "0.0.1-alpha12",
"version": "0.0.2-alpha0",
"license": "ISC",
"type": "module",
"module": "ts-build/tbrv3/index.js",
Expand Down
2 changes: 1 addition & 1 deletion sdk/solana/tbrv3/idl/token_bridge_relayer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "AttbEYJMSsnVRDcKY4AcX1GBcdPy9FzHcxTbKaMGGuLs",
"address": "ATT7enfWTMV4dDTe2NQ2yBaTByuXXwrYRznsioQEUW6r",
"metadata": {
"name": "token_bridge_relayer",
"version": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/solana/tbrv3/idl/token_bridge_relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* IDL can be found at `target/idl/token_bridge_relayer.json`.
*/
export type TokenBridgeRelayer = {
"address": "AttbEYJMSsnVRDcKY4AcX1GBcdPy9FzHcxTbKaMGGuLs",
"address": "ATT7enfWTMV4dDTe2NQ2yBaTByuXXwrYRznsioQEUW6r",
"metadata": {
"name": "tokenBridgeRelayer",
"version": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion solana/programs/token-bridge-relayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cfg_if::cfg_if! {
declare_id!("AtTrxsPbTfBhC9uwwJGJbkFMux78t5EWTAXAbwUW8yC7");
const WORMHOLE_MINT_AUTHORITY: Pubkey = anchor_lang::pubkey!("BCD75RNBHrJJpW4dXVagL5mPjzRLnVZq4YirJdjEYMV7");
} else if #[cfg(feature = "solana-devnet")] {
declare_id!("AttbEYJMSsnVRDcKY4AcX1GBcdPy9FzHcxTbKaMGGuLs");
declare_id!("ATT7enfWTMV4dDTe2NQ2yBaTByuXXwrYRznsioQEUW6r");
const WORMHOLE_MINT_AUTHORITY: Pubkey = anchor_lang::pubkey!("rRsXLHe7sBHdyKU3KY3wbcgWvoT1Ntqudf6e9PKusgb");
} else if #[cfg(feature = "tilt-devnet")] {
declare_id!("46kv4wCpfEtLsHPDh4zm7jJb2pVdvke8Pj2ABYYJotFD");
Expand Down
2 changes: 1 addition & 1 deletion target/idl/token_bridge_relayer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "AttbEYJMSsnVRDcKY4AcX1GBcdPy9FzHcxTbKaMGGuLs",
"address": "ATT7enfWTMV4dDTe2NQ2yBaTByuXXwrYRznsioQEUW6r",
"metadata": {
"name": "token_bridge_relayer",
"version": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion target/types/token_bridge_relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* IDL can be found at `target/idl/token_bridge_relayer.json`.
*/
export type TokenBridgeRelayer = {
"address": "AttbEYJMSsnVRDcKY4AcX1GBcdPy9FzHcxTbKaMGGuLs",
"address": "ATT7enfWTMV4dDTe2NQ2yBaTByuXXwrYRznsioQEUW6r",
"metadata": {
"name": "tokenBridgeRelayer",
"version": "3.0.0",
Expand Down
Loading