From 57789a40e43f3a4092a4754704a8798e4d06c060 Mon Sep 17 00:00:00 2001 From: Diana Carvalho Date: Wed, 26 Feb 2025 10:08:19 +0000 Subject: [PATCH] fix: Unify both executor addresses in one file - Move executor_addresses.json to a top level directory - Delete executors.json - Use the same file for both encoding and setting executors --- don't change below this line --- ENG-4260 Took 19 minutes Took 11 seconds --- .../config => config}/executor_addresses.json | 0 foundry/foundry.toml | 2 +- foundry/hardhat.config.js | 4 ++++ foundry/scripts/README.md | 3 ++- foundry/scripts/executors.json | 6 ------ foundry/scripts/set-executors.js | 15 +++++++++------ src/encoding/evm/constants.rs | 3 +-- 7 files changed, 17 insertions(+), 16 deletions(-) rename {src/encoding/config => config}/executor_addresses.json (100%) delete mode 100644 foundry/scripts/executors.json diff --git a/src/encoding/config/executor_addresses.json b/config/executor_addresses.json similarity index 100% rename from src/encoding/config/executor_addresses.json rename to config/executor_addresses.json diff --git a/foundry/foundry.toml b/foundry/foundry.toml index 7cc18b3..26d12dc 100644 --- a/foundry/foundry.toml +++ b/foundry/foundry.toml @@ -15,7 +15,7 @@ libs = ['lib'] auto_detect_sol = true evm_version = 'cancun' optimizer = true -optimizer_runs = 44444444 +optimizer_runs = 1000 via_ir = true [rpc_endpoints] diff --git a/foundry/hardhat.config.js b/foundry/hardhat.config.js index d457528..8336e9a 100644 --- a/foundry/hardhat.config.js +++ b/foundry/hardhat.config.js @@ -9,6 +9,10 @@ module.exports = { settings: { evmVersion: "cancun", viaIR: true, + optimizer: { + enabled: true, + runs: 1000, + }, }, }, diff --git a/foundry/scripts/README.md b/foundry/scripts/README.md index 9f52962..fd31e13 100644 --- a/foundry/scripts/README.md +++ b/foundry/scripts/README.md @@ -43,4 +43,5 @@ from being stored in the shell history. 1. In `scripts/deploy-executors.js` define the executors to be deployed 2. Deploy executors: `npx hardhat run scripts/deploy-executors.js --network tenderly/mainnet` -3. Fill in the executor addresses in `scripts/executors.json` +3. Fill in the executor addresses in `config/executor_addresses.json`. Note that the naming there needs to match the one + from tycho-indexer. diff --git a/foundry/scripts/executors.json b/foundry/scripts/executors.json deleted file mode 100644 index c5ccd41..0000000 --- a/foundry/scripts/executors.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "name": "UniswapV2Executor", - "executor": "0x00C1b81e3C8f6347E69e2DDb90454798A6Be975E" - } -] \ No newline at end of file diff --git a/foundry/scripts/set-executors.js b/foundry/scripts/set-executors.js index e99a58a..95b36c8 100644 --- a/foundry/scripts/set-executors.js +++ b/foundry/scripts/set-executors.js @@ -17,15 +17,16 @@ async function main() { const TychoRouter = await ethers.getContractFactory("TychoRouter"); const router = TychoRouter.attach(routerAddress); - const executorsFilePath = path.join(__dirname, "executors.json"); - const executors = JSON.parse(fs.readFileSync(executorsFilePath, "utf8")); + const executorsFilePath = path.join(__dirname, "../../config/executor_addresses.json"); + const executors = Object.entries(JSON.parse(fs.readFileSync(executorsFilePath, "utf8"))["ethereum"]); + // Filter out executors that are already set const executorsToSet = []; - for (const executor of executors) { - const isExecutorSet = await router.executors(executor.executor); + for (const [name, executor] of executors) { + const isExecutorSet = await router.executors(executor); if (!isExecutorSet) { - executorsToSet.push(executor); + executorsToSet.push({name: name, executor: executor}); } } @@ -49,7 +50,9 @@ async function main() { // Set executors const executorAddresses = executorsToSet.map(executor => executor.executor); - const tx = await router.setExecutors(executorAddresses); + const tx = await router.setExecutors(executorAddresses, { + gasLimit: 100000 + }); await tx.wait(); // Wait for the transaction to be mined console.log(`Executors set at transaction: ${tx.hash}`); } diff --git a/src/encoding/evm/constants.rs b/src/encoding/evm/constants.rs index 62f9800..8f93215 100644 --- a/src/encoding/evm/constants.rs +++ b/src/encoding/evm/constants.rs @@ -1,7 +1,6 @@ use std::{collections::HashSet, sync::LazyLock}; -pub const DEFAULT_EXECUTORS_JSON: &str = - include_str!("../../../src/encoding/config/executor_addresses.json"); +pub const DEFAULT_EXECUTORS_JSON: &str = include_str!("../../../config/executor_addresses.json"); /// These protocols support the optimization of grouping swaps. ///