Skip to content

Commit

Permalink
Merge pull request #4 from connext/refactor/clean
Browse files Browse the repository at this point in the history
feat: using utils stable version and cleanup
  • Loading branch information
rhlsthrm authored Mar 28, 2023
2 parents 1dbc6b8 + 174861a commit 0475197
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 26 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ ETHERSCAN_API_KEY=
ENVIRONMENT= # "staging" (dev environment), "testnet", or "mainnet"
RPC_HTTPS_URI= # goerli for staging/testnet, mainnet for mainnet
ARBITRUM_RPC_URI= # arbitrum testnet for staging/testnet, arbitrum one for mainnet
FLASHBOTS_PROVIDER_URL= # https://relay-goerli.flashbots.net for staging/testnet, https://relay.flashbots.net for mainnet
FLASHBOTS_PROVIDER_URL= # https://relay-goerli.flashbots.net for staging/testnet, https://relay.flashbots.net for mainnet
LISTENER_INTERVAL_DELAY= # Optional: Get next block after X seconds of sleep. This number must be bigger than the time between 2 blocks.
LISTENER_BLOCK_DELAY= # Optional: After getting a new block, wait X seconds before calling starting the work process.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@connext/nxtp-adapters-subgraph": "^0.2.8-alpha.1",
"@connext/nxtp-utils": "^0.2.8-alpha.1",
"@eth-optimism/sdk": "^2.0.0",
"@keep3r-network/keeper-scripting-utils": "0.0.0-bcd23fa4",
"@keep3r-network/keeper-scripting-utils": "1.1.0",
"dotenv": "16.0.3",
"ethers": "5.6.9",
"interval-promise": "^1.4.0",
Expand Down
1 change: 0 additions & 1 deletion src/helpers/propagate/zksync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const getPropagateParams = async ({ provider }: InitialSetup): Promise<Ex

const l2Provider = new Provider('https://testnet.era.zksync.dev');
const zk = await l2Provider.getMainContractAddress();
console.log('zk: ', zk);
const zkSyncContract = new Contract(zk, ZKSYNC_ABI, provider);
const txCostPrice = await zkSyncContract.l2TransactionBaseCost(gasPrice, gasLimit, gasPerPubdataByte);

Expand Down
21 changes: 6 additions & 15 deletions src/init-propagate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const PRIORITY_FEE = 2e9;
txSigner,
bundleSigner,
environment: getEnvVariable('ENVIRONMENT') as 'staging' | 'testnet' | 'mainnet',
listenerIntervalDelay: Number(process.env['LISTENER_INTERVAL_DELAY'] || 60_000),
listenerBlockDelay: Number(process.env['LISTENER_BLOCK_DELAY'] || 0),
};

// CONTRACTS
Expand All @@ -38,23 +40,12 @@ const PRIORITY_FEE = 2e9;
throw new Error('Invalid environment');
}

console.log('proxyHub: ', proxyHub.address);
console.log(`Proxy Hub:`, proxyHub.address);

// PROVIDERS
// flashbots:
// const flashbotsProvider = await FlashbotsBundleProvider.create(provider, bundleSigner, flashbotsProviderUrl);
// const flashbotBroadcastor = new FlashbotsBroadcastor(flashbotsProvider, PRIORITY_FEE, GAS_LIMIT);
// mempool:
const mempoolBroadcastor = new MempoolBroadcastor(provider, PRIORITY_FEE, GAS_LIMIT);
const flashbotsProvider = await FlashbotsBundleProvider.create(provider, bundleSigner, flashbotsProviderUrl);
const flashbotBroadcastor = new FlashbotsBroadcastor(flashbotsProvider, PRIORITY_FEE, GAS_LIMIT);

// INITIALIZE
// flashbots:
// await runPropagate(proxyHub, setup, WORK_FUNCTION, flashbotBroadcastor.tryToWorkOnFlashbots.bind(flashbotBroadcastor));
// mempool:
await runPropagate(
proxyHub as MainnetSdk['relayerProxyHub'],
setup,
WORK_FUNCTION,
mempoolBroadcastor.tryToWorkOnMempool.bind(mempoolBroadcastor)
);
await runPropagate(proxyHub as MainnetSdk['relayerProxyHub'], setup, WORK_FUNCTION, flashbotBroadcastor.tryToWorkOnFlashbots.bind(flashbotBroadcastor));
})();
4 changes: 1 addition & 3 deletions src/shared/run-propagate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ export async function runPropagate(
const { connectors, encodedData, fees } = await populateParamsForDomains(domains, rootManagerMeta, setup);

try {
// TODO: delete this
console.debug({ jobContract: jobContract.address, workMethod, workArguments: [connectors, fees, encodedData], block: block.number });
await broadcastMethod({ jobContract, workMethod, workArguments: [connectors, fees, encodedData], block });
} catch (error: unknown) {
if (error instanceof Error) console.log(`Propagate failed with:`, error.message);
}
});
}, setup.listenerIntervalDelay, setup.listenerBlockDelay);
}
2 changes: 2 additions & 0 deletions src/utils/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export type InitialSetup = {
txSigner: Wallet;
bundleSigner: Wallet;
environment: "staging" | "testnet" | "mainnet";
listenerIntervalDelay: number;
listenerBlockDelay: number;
};

export type ExtraPropagateParam = {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ __metadata:
"@dethcrypto/eth-sdk": 0.3.3
"@dethcrypto/eth-sdk-client": 0.1.6
"@eth-optimism/sdk": ^2.0.0
"@keep3r-network/keeper-scripting-utils": 0.0.0-bcd23fa4
"@keep3r-network/keeper-scripting-utils": 1.1.0
"@types/lodash.isequal": 4.5.6
dotenv: 16.0.3
ethers: 5.6.9
Expand Down Expand Up @@ -3245,16 +3245,16 @@ __metadata:
languageName: node
linkType: hard

"@keep3r-network/keeper-scripting-utils@npm:0.0.0-bcd23fa4":
version: 0.0.0-bcd23fa4
resolution: "@keep3r-network/keeper-scripting-utils@npm:0.0.0-bcd23fa4"
"@keep3r-network/keeper-scripting-utils@npm:1.1.0":
version: 1.1.0
resolution: "@keep3r-network/keeper-scripting-utils@npm:1.1.0"
dependencies:
"@flashbots/ethers-provider-bundle": 0.5.0
chalk: 4.1.1
dotenv: 16.0.1
ethers: 5.6.9
rxjs: 7.5.6
checksum: 380236dd436e67040a51343c4a53c8d9ddb7343c1c698290c2f76072066a006c434cb22ae08e33f98b4bbeda606bfdd2da8223b19c12470df7040c836edd5b04
checksum: add501a2cdee147418ff4c6952d1e435a3079f10b459d5d979aec91345c6b8eba727bb24c91fcae869952a25fd8e79f73d389aec0347e5e6177bbf8c4d2a87c5
languageName: node
linkType: hard

Expand Down

0 comments on commit 0475197

Please sign in to comment.