Skip to content

Commit

Permalink
tilt: e2e with mm and executor
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray committed Dec 20, 2024
1 parent 91a7dc8 commit cd7e319
Show file tree
Hide file tree
Showing 29 changed files with 4,950 additions and 270 deletions.
59 changes: 44 additions & 15 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ docker_build(
ignore=["./sdk/__tests__", "./sdk/Dockerfile", "./sdk/ci.yaml", "./sdk/**/dist", "./sdk/node_modules", "./sdk/**/node_modules"],
dockerfile = "./solana/Dockerfile",
)
docker_build(
ref = "solana-test-validator",
context = "solana",
dockerfile = "solana/Dockerfile.test-validator"
)
k8s_yaml_with_ns("./solana/solana-devnet.yaml")
k8s_resource(
"solana-devnet",
labels = ["anchor-ntt"],
port_forwards = [
port_forward(8899, name = "Solana RPC [:8899]"),
port_forward(8900, name = "Solana WS [:8900]"),
],
)
# docker_build(
# ref = "solana-test-validator",
# context = "solana",
# dockerfile = "solana/Dockerfile.test-validator"
# )
# k8s_yaml_with_ns("./solana/solana-devnet.yaml")
# k8s_resource(
# "solana-devnet",
# labels = ["anchor-ntt"],
# port_forwards = [
# port_forward(8899, name = "Solana RPC [:8899]"),
# port_forward(8900, name = "Solana WS [:8900]"),
# ],
# )

# EVM build
docker_build(
Expand All @@ -36,6 +36,35 @@ docker_build(
dockerfile = "./evm/Dockerfile",
)

# MM and Executor Contract Deploy / Setup
docker_build(
ref = "executor-deploy",
context = "tilt",
dockerfile = "tilt/Dockerfile.deploy",
only = ["deploy.sh"]
)
docker_build(
ref = "executor",
context = "tilt",
dockerfile = "tilt/Dockerfile.executor",
only = [],
)
k8s_yaml_with_ns("tilt/executor-deploy.yaml")
k8s_resource(
"executor-deploy",
labels = ["executor"],
resource_deps = ["eth-devnet", "eth-devnet2"],
)
k8s_yaml_with_ns("tilt/executor.yaml")
k8s_resource(
"executor",
labels = ["executor"],
resource_deps = ["eth-devnet", "eth-devnet2", "guardian", "executor-deploy"],
port_forwards = [
port_forward(3000, name = "Executor [:3000]"),
],
)

# CI tests
docker_build(
ref = "ntt-ci",
Expand All @@ -47,5 +76,5 @@ k8s_yaml_with_ns("./sdk/ci.yaml")
k8s_resource(
"ntt-ci-tests",
labels = ["ntt"],
resource_deps = ["eth-devnet", "eth-devnet2", "solana-devnet", "guardian", "relayer-engine", "wormchain"],
resource_deps = ["eth-devnet", "eth-devnet2", "solana-devnet", "guardian", "relayer-engine", "wormchain", "executor"],
)
2 changes: 1 addition & 1 deletion evm/lib/example-messaging-executor
20 changes: 10 additions & 10 deletions evm/src/NttManager/NttManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
using TrimmedAmountLib for uint256;
using TrimmedAmountLib for TrimmedAmount;

string public constant NTT_MANAGER_VERSION = "1.1.0";
string public constant NTT_MANAGER_VERSION = "2.0.0";

// =============== Setup =================================================================

Expand Down Expand Up @@ -597,7 +597,8 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
checkFork(evmChainId);

// Compute the quote price and refund user excess value from msg.value
uint256 epTotalPriceQuote = quoteAndRefund(recipientChain, transceiverInstructions);
(uint256 epTotalPriceQuote, uint256 excessValue) =
quoteEndpoint(recipientChain, transceiverInstructions);

return _transfer(
_TransferArgs({
Expand All @@ -610,7 +611,8 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
executorQuote: executorQuote,
relayInstructions: relayInstructions,
transceiverInstructions: transceiverInstructions,
epTotalPriceQuote: epTotalPriceQuote
epTotalPriceQuote: epTotalPriceQuote,
excessValue: excessValue
})
);
}
Expand All @@ -627,6 +629,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
bytes relayInstructions;
bytes transceiverInstructions;
uint256 epTotalPriceQuote;
uint256 excessValue;
}

function _transfer(
Expand Down Expand Up @@ -667,7 +670,7 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
relayInstructions = abi.encodePacked(relayInstructions, args.relayInstructions);
}

executor.requestExecution(
executor.requestExecution{value: args.excessValue}(
args.recipientChain,
peerData.peerAddress,
UniversalAddressLibrary.fromBytes32(args.refundAddress).toAddress(),
Expand All @@ -682,15 +685,12 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
return args.sequence;
}

function quoteAndRefund(
function quoteEndpoint(
uint16 recipientChain,
bytes memory transceiverInstructions
) internal returns (uint256 epTotalPriceQuote) {
) internal returns (uint256 epTotalPriceQuote, uint256 excessValue) {
epTotalPriceQuote = quoteDeliveryPrice(recipientChain, transceiverInstructions);
uint256 excessValue = msg.value - epTotalPriceQuote;
if (excessValue > 0) {
_refundToSender(excessValue);
}
excessValue = msg.value - epTotalPriceQuote;
}

function buildEncodedPayload(
Expand Down
2 changes: 1 addition & 1 deletion evm/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"build": "npm run build:esm && npm run build:cjs",
"rebuild": "npm run clean && npm run build",
"clean": "rm -rf ./dist",
"generate:test": "typechain --node16-modules --target ethers-v6 --out-dir ethers-ci-contracts '../out/**/*.json'",
"generate:test": "typechain --node16-modules --target ethers-v6 --out-dir ethers-ci-contracts '../out/?(WormholeTransceiver.sol|NttManager.sol)/*.json'",
"generate:slim": "ABI_VERSION=`tsx scripts/readVersion.ts` && typechain --node16-modules --target ethers-v6 --out-dir src/ethers-contracts/$ABI_VERSION '../out/?(WormholeTransceiver.sol|NttManager.sol)/*.json'",
"generate": "npm run generate:slim",
"build:contracts": "cd ../.. && make build-evm-prod",
Expand Down
10 changes: 3 additions & 7 deletions evm/ts/src/bindings.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { Provider } from "ethers";

import { _0_1_0, _1_0_0, _1_1_0 } from "./ethers-contracts/index.js";
import { _0_1_0, _1_0_0, _1_1_0, _2_0_0 } from "./ethers-contracts/index.js";
import { Ntt } from "@wormhole-foundation/sdk-definitions-ntt";

// This is a descending list of all ABI versions the SDK is aware of.
// We check for the first match in descending order, allowing for higher minor and patch versions
// being used by the live contract (these are supposed to still be compatible with older ABIs).
export const abiVersions = [
["1.1.0", _1_1_0],
["1.0.0", _1_0_0],
["0.1.0", _0_1_0],
] as const;
export const abiVersions = [["2.0.0", _2_0_0]] as const;
export type AbiVersion = (typeof abiVersions)[number][0];

export interface NttBindings {
Expand All @@ -32,7 +28,7 @@ export interface NttTransceiverBindings {
}

export namespace NttManagerBindings {
export type NttManager = ReturnType<typeof _0_1_0.NttManager.connect>;
export type NttManager = ReturnType<typeof _2_0_0.NttManager.connect>;
}

export interface NttManagerBindings {
Expand Down
Loading

0 comments on commit cd7e319

Please sign in to comment.