Skip to content

Commit 6d6d91e

Browse files
committed
Merge branch 'decouple-order-3-leyers' into save-open
2 parents bfdf87a + 98de0d5 commit 6d6d91e

File tree

153 files changed

+32581
-3042
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+32581
-3042
lines changed

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:20-alpine
2+
3+
# Bundle APP files
4+
WORKDIR /workspace
5+
COPY . ./
6+
RUN corepack enable
7+
RUN yarn install
8+
RUN yarn build:solver
9+
RUN npm install pm2 -g
10+
11+
# Show current folder structure in logs
12+
RUN ls -al -R
13+
14+
CMD [ "pm2-runtime", "start", "ecosystem.config.js", "--env", "production" ]

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,33 @@ cd intents-framework
3131
yarn
3232
```
3333

34+
### Running the Solver
35+
36+
Run the following commands from the root directory (you need `docker` installed)
37+
38+
```bash
39+
docker build -t solver .
40+
```
41+
42+
Once it finish building the image
43+
44+
```bash
45+
docker run -it -e [PRIVATE_KEY=SOME_PK_YOU_OWN | MNEMONIC=SOME_MNEMONIC_YOU_OWN] solver
46+
```
47+
48+
The solver is run using `pm2` inside the docker container so `pm2` commands can still be used inside a container with the docker exec command:
49+
50+
```bash
51+
# Monitoring CPU/Usage of each process
52+
docker exec -it <container-id> pm2 monit
53+
# Listing managed processes
54+
docker exec -it <container-id> pm2 list
55+
# Get more information about a process
56+
docker exec -it <container-id> pm2 show
57+
# 0sec downtime reload all applications
58+
docker exec -it <container-id> pm2 reload all
59+
```
60+
3461
### Versioning
3562

3663
For the versions available, see the tags on this repository.

ecosystem.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
apps : [{
3+
name: "solver",
4+
script: "./typescript/solver/dist/index.js",
5+
env: {
6+
NODE_ENV: "development",
7+
},
8+
env_production: {
9+
NODE_ENV: "production",
10+
LOG_LEVEL: "info",
11+
LOG_FORMAT: "json",
12+
}
13+
}]
14+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "intents-framework",
33
"version": "0.1.0",
44
"scripts": {
5-
"test": "echo \"Error: no test specified\" && exit 1"
5+
"build:solver": "yarn workspace solver build"
66
},
77
"repository": {
88
"type": "git",

typescript/solver/NonceKeeperWallet.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { defaultPath, HDNode } from "@ethersproject/hdnode";
12
import type { Deferrable } from "@ethersproject/properties";
23
import type {
34
Provider,
45
TransactionRequest,
56
TransactionResponse,
67
} from "@ethersproject/providers";
78
import { Wallet } from "@ethersproject/wallet";
9+
import type { Wordlist } from "@ethersproject/wordlists";
810

911
import { log } from "./logger.js";
1012

@@ -31,8 +33,22 @@ export class NonceKeeperWallet extends Wallet {
3133
transaction.nonce = this.getNextNonce();
3234
}
3335

34-
log.debug("transaction", transaction);
36+
log.debug({ msg: "transaction", transaction });
3537

3638
return super.sendTransaction(transaction);
3739
}
40+
41+
static override fromMnemonic(
42+
mnemonic: string,
43+
path?: string,
44+
wordlist?: Wordlist,
45+
) {
46+
if (!path) {
47+
path = defaultPath;
48+
}
49+
50+
return new NonceKeeperWallet(
51+
HDNode.fromMnemonic(mnemonic, undefined, wordlist).derivePath(path),
52+
);
53+
}
3854
}

typescript/solver/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ The clock-list supersedes the allow-list, i.e. if a message matches both the all
142142
143143
### Logging
144144
145-
The application utilizes a custom Logger class for logging. You can adjust the log level and format by modifying the Logger instantiation in index.ts.
145+
The application utilizes a custom Logger class for logging. You can adjust the log level and format by modifying the Logger instantiation in index.ts. By default it will log to `stdout` in a human-readable format using the `INFO` level.
146+
147+
You can customize the logging destination by using a pino transport of your choosing. There's an example for logging to a Syslog server running on `localhost` commented in [logger.ts](logger.ts). Check out the [pino transports docs](https://github.com/pinojs/pino/blob/main/docs/transports.md) for other available transports.
146148
147149
## Adding a New Solver
148150
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { z } from "zod";
2+
3+
import { chainMetadata as defaultChainMetadata } from "@hyperlane-xyz/registry";
4+
5+
import { ChainMetadataSchema } from "@hyperlane-xyz/sdk";
6+
import type { ChainMap, ChainMetadata } from "@hyperlane-xyz/sdk";
7+
8+
import { objMerge } from "@hyperlane-xyz/utils";
9+
10+
const customChainMetadata = {
11+
// Example custom configuration
12+
// "base": {
13+
// "rpcUrls": [
14+
// {
15+
// "http": "https://base.llamarpc.com"
16+
// }
17+
// ]
18+
// }
19+
};
20+
21+
const chainMetadata = objMerge<ChainMap<ChainMetadata>>(
22+
defaultChainMetadata,
23+
customChainMetadata,
24+
10,
25+
false,
26+
);
27+
28+
z.record(z.string(), ChainMetadataSchema).parse(chainMetadata);
29+
30+
export { chainMetadata };

typescript/solver/config/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import z from "zod";
21
import dotenvFlow from "dotenv-flow";
2+
import z from "zod";
33
import allowBlockListsGlobal from "./allowBlockLists.js";
4+
import { chainMetadata } from "./chainMetadata.js";
45
import { ConfigSchema } from "./types.js";
5-
import { chainMetadata } from "@hyperlane-xyz/registry";
66

77
dotenvFlow.config();
88

@@ -15,7 +15,7 @@ export { LOG_FORMAT, LOG_LEVEL, MNEMONIC, PRIVATE_KEY };
1515

1616
type GenericAllowBlockListItem = z.infer<typeof ConfigSchema>;
1717

18-
type GenericAllowBlockLists = {
18+
export type GenericAllowBlockLists = {
1919
allowList: GenericAllowBlockListItem[];
2020
blockList: GenericAllowBlockListItem[];
2121
};
@@ -69,16 +69,16 @@ const { chainIds, chainNames, chainIdsToName } = Object.entries(
6969
chainMetadata,
7070
).reduce<{
7171
chainNames: Array<string>;
72-
chainIds: { [key: string]: number | string };
72+
chainIds: { [key: string]: number };
7373
chainIdsToName: { [key: string]: string };
7474
}>(
7575
(acc, [key, value]) => {
7676
acc.chainNames.push(key);
77-
acc.chainIds[key] = value.chainId;
77+
acc.chainIds[key] = Number(value.chainId);
7878
acc.chainIdsToName[value.chainId.toString()] = key;
7979
return acc;
8080
},
8181
{ chainNames: [], chainIds: {}, chainIdsToName: {} },
8282
);
8383

84-
export { chainIds, chainNames, chainIdsToName };
84+
export { chainIds, chainIdsToName, chainNames };

typescript/solver/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import "./patch-bigint-buffer-warn.js";
55
import { log } from "./logger.js";
66
import * as solvers from "./solvers/index.js";
77
import { getMultiProvider } from "./solvers/utils.js";
8-
8+
import { chainMetadata } from "./config/chainMetadata.js";
99

1010
const main = async () => {
11-
const multiProvider = await getMultiProvider().catch(
11+
const multiProvider = await getMultiProvider(chainMetadata).catch(
1212
(error) => (log.error(error.reason ?? error.message), process.exit(1)),
1313
);
1414

typescript/solver/logger.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ function createLogger(name?: string, logFormat?: LogFormat, logLevel?: Level) {
2626
const baseConfig = { level: logLevel, name };
2727

2828
if (logFormat === LogFormat.JSON) {
29-
return pino(baseConfig);
29+
return pino({
30+
...baseConfig,
31+
// transport: {
32+
// target: "pino-socket",
33+
// options: {
34+
// address: "127.0.0.1",
35+
// port: 514,
36+
// mode: "udp",
37+
// },
38+
// },
39+
});
3040
}
3141

3242
return pino(baseConfig, pretty(prettyConfig));

0 commit comments

Comments
 (0)