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

docker rep-build. #114

Merged
merged 15 commits into from
Jan 24, 2025
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
257 changes: 129 additions & 128 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 7 additions & 6 deletions deployment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "deployment",
"version": "0.0.1",
"scripts": {
"build:evm:typechain": "typechain --target=ethers-v6 --out-dir=./ethers-contracts ../evm/build-forge/*.sol/!(*.dbg).json --show-stack-traces",
"build:evm": "forge build --root=../evm && yarn build:evm:typechain",
"clean": "rm -rf ./ts-build && git clean --force -- ./ethers-contracts && git checkout -- ./ethers-contracts",
"build:evm:typechain": "mkdir -p evm-build/bindings && yarn tsx ../evm/solc2bindings.ts evm-build/Tbr.output.json evm-build/bindings",
"build:evm:contract": "mkdir -p evm-build && docker build --file ../evm/Dockerfile .. --tag tbrv3-evm-rebuild --output type=local,dest=evm-build",
"build:evm": "yarn build:evm:contract && yarn build:evm:typechain",
"clean": "rm -rf evm-build",
"deploy:evm:localnet": "ENV=localnet tsx evm/deploy.ts",
"deploy:evm:testnet": "ENV=testnet tsx evm/deploy.ts",
"deploy:evm:mainnet": "ENV=mainnet tsx evm/deploy.ts",
Expand All @@ -22,7 +23,6 @@
"@coral-xyz/anchor": "^0.30.1",
"@solana/spl-token": "^0.4.9",
"@solana/web3.js": "^1.98.0",
"@typechain/ethers-v6": "^0.5.1",
"@wormhole-foundation/sdk-base": "^1.4.5",
"@wormhole-foundation/sdk-definitions": "^1.4.5",
"@wormhole-foundation/sdk-evm": "^1.4.5",
Expand All @@ -34,9 +34,10 @@
"@xlabs-xyz/ledger-signer-ethers-v6": "^0.0.1",
"@xlabs-xyz/ledger-signer-solana": "^0.0.1",
"@xlabs-xyz/solana-arbitrary-token-transfers": "workspace:*",
"@xlabs-xyz/typechain": "^8.3.7",
"@xlabs-xyz/typechain-ethers-v6": "^0.5.1",
"chalk": "^5.3.0",
"dotenv": "^16.4.5",
"ethers": "^6.13.5",
"typechain": "^8.3.2"
"ethers": "^6.13.5"
}
}
12 changes: 9 additions & 3 deletions deployment/solana/register-peers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ const configureSolanaTbr: SolanaScriptCb = async function (

if (!currentChainConfig) {
log('Registering peer on chain', tbrDeployment.chainId);
const ix = await tbr.registerPeer(
const ixs = await tbr.registerFirstPeer(
signerKey,
chainIdToChain(tbrDeployment.chainId),
peerUniversalAddress,
{
maxGasDropoffMicroToken: Number(desiredChainConfig.maxGasDropoff) * 10 ** 6,
relayerFeeMicroUsd: desiredChainConfig.relayFee,
// TODO: have this be configurable?
pausedOutboundTransfers: false,
}
);
const tx = await ledgerSignAndSend(connection, [ix], []);
const tx = await ledgerSignAndSend(connection, ixs, []);
log(`Register succeeded on tx: ${tx}`);
} else {
const currentPeer = currentChainConfig.canonicalPeer.toUniversalAddress();
Expand Down Expand Up @@ -100,7 +106,7 @@ const configureSolanaTbr: SolanaScriptCb = async function (
log(
`Updating relayerFee on chain ${tbrDeployment.chainId} to ${desiredChainConfig.relayFee}`,
);
const ix = await tbr.updateRelayerFee(
const ix = await tbr.updateBaseFee(
signerKey,
chainIdToChain(tbrDeployment.chainId),
desiredChainConfig.relayFee,
Expand Down
41 changes: 41 additions & 0 deletions evm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ghcr.io/foundry-rs/foundry:nightly-4817280d96e0e33a2e96cf169770da60514d1764 AS builder

# Preflight

WORKDIR /app
COPY evm/foundry.toml evm/foundry.toml
COPY --link lib lib
COPY --link evm/lib evm/lib
COPY --link evm/src evm/src
RUN apk add --no-cache jq

# Prepare compiler input.

RUN export FOUNDRY_PROFILE=prod; cd evm; \
forge verify-contract --show-standard-json-input 0x0000000000000000000000000000000000000000 src/Tbr.sol:Tbr > Tbr.input.json

# Get compiler according to forge configuration (foundry.toml specified)

RUN SOLC_VERSION=$(cd evm; forge config | grep "^solc =" | sed 's/solc = //' | sed 's/"//g'); \
if [ -z $SOLC_VERSION ]; then echo "SOLC_VERSION not set"; exit 1; fi; \
wget --output-document=evm/solc https://github.com/ethereum/solidity/releases/download/v$SOLC_VERSION/solc-static-linux && chmod +x evm/solc

# Compile contract(s). NOTE: jq must be pre-applied to "clean" the output from forge
# otherwise solc aborts with duplicated key/newline problems.

RUN cd evm; \
cat Tbr.input.json | jq > Tbr.input.tmp.json; \
mv Tbr.input.tmp.json Tbr.input.json; \
./solc --standard-json Tbr.input.json > Tbr.output.json && \
SOLC_ERR=$(jq '.errors[]? | select(.severity == "error")' Tbr.output.json) && \
if [ ! -z "$SOLC_ERR" ]; then \
echo "Error detected during solc execution."; \
echo $SOLC_ERR; \
exit 2; \
fi

# Generate Typechain bindings

# Consolidate all generated output
FROM scratch AS foundry-export
COPY --from=builder /app/evm/*.input.json /app/evm/*.output.json ./
2 changes: 0 additions & 2 deletions evm/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ remappings = [
"wormhole-sdk/=lib/wormhole-solidity-sdk/src/",
"tbr/=src/",
"price-oracle/=../lib/relayer-infra-contracts/apps/price-oracle/evm/src/",
"@openzeppelin/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"permit2/=lib/permit2/src/interfaces/",
]

Expand Down
7 changes: 4 additions & 3 deletions evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"clean:contracts": "forge clean",
"test": "bash -c 'source ../.env.evm-test && forge test --fork-url ${0}'"
},
"dependencies": {
"@typechain/ethers-v6": "^0.5.1",
"typechain": "^8.3.2"
"devDependencies": {
"@xlabs-xyz/typechain": "^8.3.7",
"@xlabs-xyz/typechain-ethers-v6": "^0.5.1",
"tsx": "^4.19.2"
}
}
44 changes: 44 additions & 0 deletions evm/solc2bindings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { runTypeChainInMemory, FileDescription } from '@xlabs-xyz/typechain';
import ethersv6Codegen from "@xlabs-xyz/typechain-ethers-v6";
import { readFile } from 'fs/promises';
import path from 'path';

(async () => {

if (process.argv.length < 4) {
console.log('Generate Typechain bindings from Solc output');
console.log(`\nsolc2bindings <inputFile> <outDir>`);
process.exit(1);
}

const outDir = process.argv[3];
const inputFile = process.argv[2];

const data = await readFile(inputFile, null);
const json = JSON.parse(data.toString());
const contracts: any = json['contracts'];
const fileDescriptions: FileDescription[] = [];

console.log(`Found ${Object.keys(contracts).length} entries to process...`);

for (const [path, contents] of Object.entries(contracts)) {
const contractsInFile = Object.entries(contents as { [key: string]: any });
console.log(` Found path ${path} with ${contractsInFile.length} contracts `);
for (const [contractName, abiAndBytecodeData] of contractsInFile) {
console.log(` Adding contract ${contractName} `);
fileDescriptions.push({ path, contents: JSON.stringify(abiAndBytecodeData) });
}
}

const pc = {
cwd: path.join(process.cwd()),
allFiles: fileDescriptions.map(k => k.contents),
outDir
};

const result = await runTypeChainInMemory(pc, fileDescriptions, ethersv6Codegen);

console.log(`Generated ${result.filesGenerated} file(s)`);
})()


2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "",
"scripts": {
"build": "yarn ./deployment build:evm:typechain; yarn ./sdk/common build && yarn ./sdk/evm build && yarn ./sdk/solana build && yarn ./sdk/deployment test:build && yarn ./solana build:ts && yarn ./connect/definitions build && yarn ./connect/platforms/evm build && yarn ./connect/platforms/solana build && yarn ./connect/route build",
"build:all:common": "yarn ./evm build:all && yarn build",
"build:all:common": "yarn ./deployment build:evm:contract && yarn build",
"build:all-testnet": "yarn ./solana build:contract:testnet && yarn build:all:common",
"build:verifiable:all-testnet": "yarn ./solana build:contract:verifiable:testnet && yarn build:all:common",
"build:all-mainnet": "yarn ./solana build:contract:mainnet && yarn build:all:common",
Expand Down
2 changes: 1 addition & 1 deletion sdk/solana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@coral-xyz/anchor": "^0.30.1",
"@solana/spl-token": "^0.4.9",
"@solana/web3.js": "^1.98.0",
"@xlabs-xyz/solana-price-oracle-sdk": "^0.0.18"
"@xlabs-xyz/solana-price-oracle-sdk": "^0.0.20"
},
"devDependencies": {
"@types/node": "20.17.5",
Expand Down
18 changes: 9 additions & 9 deletions sdk/solana/tbrv3/idl/token_bridge_relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export type TokenBridgeRelayer = {
97,
100,
101,
32,
95,
108,
111,
99,
Expand Down Expand Up @@ -265,7 +265,7 @@ export type TokenBridgeRelayer = {
"name": "mint",
"docs": [
"Mint info. This is the SPL token that will be bridged over to the",
"foreign contract. Mutable.",
"foreign contract.",
"",
"In the case of a native transfer, it's the mint for the token wrapped by Wormhole;",
"in the case of a wrapped transfer, it's the native SPL token mint."
Expand All @@ -277,7 +277,7 @@ export type TokenBridgeRelayer = {
"docs": [
"Recipient associated token account. The recipient authority check",
"is necessary to ensure that the recipient is the intended recipient",
"of the bridged tokens. Mutable."
"of the bridged tokens."
],
"writable": true,
"optional": true,
Expand Down Expand Up @@ -429,7 +429,7 @@ export type TokenBridgeRelayer = {
"docs": [
"account that holds this mint's balance. This account needs to be",
"unchecked because a token account may not have been created for this",
"mint yet. Mutable.",
"mint yet.",
"",
"# Exclusive",
"",
Expand Down Expand Up @@ -600,7 +600,7 @@ export type TokenBridgeRelayer = {
97,
100,
101,
32,
95,
108,
111,
99,
Expand Down Expand Up @@ -1251,7 +1251,7 @@ export type TokenBridgeRelayer = {
97,
100,
101,
32,
95,
108,
111,
99,
Expand Down Expand Up @@ -1400,7 +1400,7 @@ export type TokenBridgeRelayer = {
"name": "mint",
"docs": [
"Mint info. This is the SPL token that will be bridged over to the",
"canonical peer. Mutable.",
"canonical peer.",
"",
"In the case of a native transfer, it's the native mint; in the case of a",
"wrapped transfer, it's the token wrapped by Wormhole."
Expand Down Expand Up @@ -1448,7 +1448,7 @@ export type TokenBridgeRelayer = {
"docs": [
"account that holds this mint's balance. This account needs to be",
"unchecked because a token account may not have been created for this",
"mint yet. Mutable.",
"mint yet.",
"",
"# Exclusive",
"",
Expand Down Expand Up @@ -2273,7 +2273,7 @@ export type TokenBridgeRelayer = {
{
"name": "seedPrefixUpgradeLock",
"type": "bytes",
"value": "[117, 112, 103, 114, 97, 100, 101, 32, 108, 111, 99, 107]"
"value": "[117, 112, 103, 114, 97, 100, 101, 95, 108, 111, 99, 107]"
}
]
};
18 changes: 9 additions & 9 deletions target/idl/token_bridge_relayer.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
97,
100,
101,
32,
95,
108,
111,
99,
Expand Down Expand Up @@ -259,7 +259,7 @@
"name": "mint",
"docs": [
"Mint info. This is the SPL token that will be bridged over to the",
"foreign contract. Mutable.",
"foreign contract.",
"",
"In the case of a native transfer, it's the mint for the token wrapped by Wormhole;",
"in the case of a wrapped transfer, it's the native SPL token mint."
Expand All @@ -271,7 +271,7 @@
"docs": [
"Recipient associated token account. The recipient authority check",
"is necessary to ensure that the recipient is the intended recipient",
"of the bridged tokens. Mutable."
"of the bridged tokens."
],
"writable": true,
"optional": true,
Expand Down Expand Up @@ -423,7 +423,7 @@
"docs": [
"account that holds this mint's balance. This account needs to be",
"unchecked because a token account may not have been created for this",
"mint yet. Mutable.",
"mint yet.",
"",
"# Exclusive",
"",
Expand Down Expand Up @@ -594,7 +594,7 @@
97,
100,
101,
32,
95,
108,
111,
99,
Expand Down Expand Up @@ -1245,7 +1245,7 @@
97,
100,
101,
32,
95,
108,
111,
99,
Expand Down Expand Up @@ -1394,7 +1394,7 @@
"name": "mint",
"docs": [
"Mint info. This is the SPL token that will be bridged over to the",
"canonical peer. Mutable.",
"canonical peer.",
"",
"In the case of a native transfer, it's the native mint; in the case of a",
"wrapped transfer, it's the token wrapped by Wormhole."
Expand Down Expand Up @@ -1442,7 +1442,7 @@
"docs": [
"account that holds this mint's balance. This account needs to be",
"unchecked because a token account may not have been created for this",
"mint yet. Mutable.",
"mint yet.",
"",
"# Exclusive",
"",
Expand Down Expand Up @@ -2267,7 +2267,7 @@
{
"name": "SEED_PREFIX_UPGRADE_LOCK",
"type": "bytes",
"value": "[117, 112, 103, 114, 97, 100, 101, 32, 108, 111, 99, 107]"
"value": "[117, 112, 103, 114, 97, 100, 101, 95, 108, 111, 99, 107]"
}
]
}
Loading
Loading