Skip to content

Commit 2554e55

Browse files
committed
chore(toolchain): removed the calculate profitability and improved error handling
1 parent 6295b39 commit 2554e55

File tree

4 files changed

+22
-94
lines changed

4 files changed

+22
-94
lines changed

contracts/deploy/03-routers/03-gnosis-to-arb-router.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,19 @@ const deployRouter: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
7575
const liveDeployer = async () => {
7676
const { outboxNetwork, inboxNetwork } = getNetworkConfig(chainId);
7777

78-
try {
79-
const [veaOutbox, veaInbox] = await Promise.all([
80-
hre.companionNetworks[outboxNetwork].deployments.get(`VeaOutboxGnosisToArb${suffix}`),
81-
hre.companionNetworks[inboxNetwork].deployments.get(`VeaInboxGnosisToArb${suffix}`),
82-
]);
83-
84-
const router = await deploy(deploymentName, {
85-
from: deployer,
86-
contract: contractBaseName,
87-
args: [arbitrumBridge, amb, veaInbox.address, veaOutbox.address, chainId],
88-
log: true,
89-
});
90-
91-
console.log(`${deploymentName} deployed to: ${router.address}`);
92-
} catch (error) {
93-
console.error("Failed to deploy:", error);
94-
throw error;
95-
}
78+
const [veaOutbox, veaInbox] = await Promise.all([
79+
hre.companionNetworks[outboxNetwork].deployments.get(`VeaOutboxGnosisToArb${suffix}`),
80+
hre.companionNetworks[inboxNetwork].deployments.get(`VeaInboxGnosisToArb${suffix}`),
81+
]);
82+
83+
const router = await deploy(deploymentName, {
84+
from: deployer,
85+
contract: contractBaseName,
86+
args: [arbitrumBridge, amb, veaInbox.address, veaOutbox.address, chainId],
87+
log: true,
88+
});
89+
90+
console.log(`${deploymentName} deployed to: ${router.address}`);
9691
};
9792

9893
// ----------------------------------------------------------------------------------------------

contracts/test/merkle/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ describe("Merkle", () => {
3939

4040
merkleTreeExposed = await merkleTreeExposedFactory.deploy();
4141
merkleProofExposed = await merkleProofExposedFactory.deploy();
42-
43-
// Note: In ethers v6, we don't need to call deployed() anymore
44-
// The deploy() promise resolves only after the contract is deployed
4542
});
4643

4744
it("Merkle Root verification", async () => {

relayer-cli/src/utils/relay.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,9 @@ const relay = async (chainId: number, nonce: number) => {
3535
getMessageDataToRelay(chainId, nonce),
3636
]);
3737

38-
try {
39-
const txn = await veaOutbox.sendMessage(proof, nonce, to, data);
40-
const receipt = await txn.wait();
41-
return receipt;
42-
} catch (error) {
43-
console.error("Transaction failed:", error);
44-
throw error;
45-
}
38+
const txn = await veaOutbox.sendMessage(proof, nonce, to, data);
39+
const receipt = await txn.wait();
40+
return receipt;
4641
};
4742

4843
const relayBatch = async (chainId: number, nonce: number, maxBatchSize: number) => {
@@ -121,12 +116,11 @@ const relayAllFrom = async (chainId: number, nonce: number, msgSender: string):
121116
};
122117

123118
const getNonceFrom = async (chainId: number, nonce: number, msgSender: string) => {
124-
try {
125-
const subgraph = getInboxSubgraph(chainId);
119+
const subgraph = getInboxSubgraph(chainId);
126120

127-
const result = await request(
128-
`https://api.studio.thegraph.com/query/${subgraph}`,
129-
`{
121+
const result = await request(
122+
`https://api.studio.thegraph.com/query/${subgraph}`,
123+
`{
130124
messageSents(
131125
first: 1000,
132126
where: {
@@ -139,13 +133,9 @@ const getNonceFrom = async (chainId: number, nonce: number, msgSender: string) =
139133
nonce
140134
}
141135
}`
142-
);
136+
);
143137

144-
return result[`messageSents`].map((a: { nonce: number }) => a.nonce);
145-
} catch (e) {
146-
console.error("Error getting nonces:", e);
147-
return undefined;
148-
}
138+
return result[`messageSents`].map((a: { nonce: number }) => a.nonce);
149139
};
150140

151141
export { relayAllFrom, relay, relayBatch };

validator-cli/src/ArbToEth/watcherArbToGnosis.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ const watch = async () => {
332332
"challenge progess for epoch " + veaEpochOutboxCheck + " is " + JSON.stringify(challengeProgress)
333333
);
334334
//TODO : check profitablity of the whole dispute resolution
335-
//const profitablity = await calculateDisputeResolutionProfitability(veaEpochOutboxCheck,claim,veaOutbox,veaInbox,providerGnosis,providerArb,providerEth);
336335
if (claim.challenger == ethers.ZeroAddress) {
337336
if (challengeProgress?.challenge.status == "pending") continue;
338337
const txnChallenge = (await retryOperation(
@@ -746,59 +745,6 @@ async function getClaimForEpoch(
746745
return null;
747746
}
748747

749-
// async function calculateDisputeResolutionProfitability(
750-
// epoch: number,
751-
// claim: ClaimStruct,
752-
// veaOutbox: VeaOutboxArbToGnosis,
753-
// veaInbox: VeaInboxArbToGnosis,
754-
// providerGnosis: JsonRpcProvider,
755-
// providerArb: JsonRpcProvider,
756-
// providerEth: JsonRpcProvider
757-
// ): Promise<{ profitable: boolean; estimatedProfit: BigInt }> {
758-
// try {
759-
// const deposit = await retryOperation(() => veaOutbox.deposit(), 1000, 10) as bigint;
760-
// const totalReward = deposit;
761-
// const minimumProfit = totalReward * BigInt(40) / BigInt(100); // 40% of total reward
762-
// let maximumAllowableCost = totalReward - minimumProfit;
763-
// let totalCost = BigInt(0);
764-
765-
// // 1. Costs on Gnosis Chain
766-
// const gnosisGasEstimate = await veaOutbox.challenge.estimateGas(epoch, claim);
767-
768-
// const gnosisGasPrice = await providerGnosis.getGasPrice();
769-
// const gnosisCost = gnosisGasEstimate * gnosisGasPrice;
770-
771-
// if (gnosisCost > maximumAllowableCost) {
772-
// return { profitable: false, estimatedProfit: BigInt(0) };
773-
// }
774-
// totalCost = totalCost + gnosisCost;
775-
// maximumAllowableCost = maximumAllowableCost - gnosisCost;
776-
777-
// const l2Network = await getArbitrumNetwork(providerArb);
778-
779-
// const arbGasEstimate = (await retryOperation(
780-
// () => veaInbox.sendSnapshot.estimateGas(epoch, 200000, claim),
781-
// 1000,
782-
// 10
783-
// )) as BigInt;
784-
785-
// const arbGasPrice = (await retryOperation(() => providerArb.getGasPrice(), 1000, 10)) as BigInt;
786-
// const arbCost = arbGasEstimate * arbGasPrice;
787-
788-
// if (arbCost > maximumAllowableCost) {
789-
// return { profitable: false, estimatedProfit: BigInt(0) };
790-
// }
791-
// totalCost = totalCost + arbCost;
792-
// maximumAllowableCost = maximumAllowableCost - arbCost;
793-
794-
// // 3. Costs on Ethereum (for Arbitrum -> Ethereum message)
795-
// //TODO : L2 to L1 message execution gas cost
796-
// } catch (error) {
797-
// console.error("Error calculating profitability:", error);
798-
// return { profitable: false, estimatedProfit: BigInt(0) };
799-
// }
800-
// }
801-
802748
function needsRetry(current: ChallengeProgress, previous: ChallengeProgress | undefined): boolean {
803749
if (!previous) return false;
804750

0 commit comments

Comments
 (0)