Skip to content

Commit

Permalink
Merge pull request #5012 from connext/propagate_to_rootmanager
Browse files Browse the repository at this point in the history
fix: resolve propagate for oproots v1
  • Loading branch information
liu-zhipeng authored Oct 16, 2023
2 parents 7e3a86a + 32e6400 commit 51294c4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/adapters/database/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ export const getRootMessage = async (
): Promise<RootMessage | undefined> => {
const poolToUse = _pool ?? pool;
const message = await db.select("root_messages", { spoke_domain, root }).run(poolToUse);
return message ? convertFromDbRootMessage(message[0]) : undefined;
return message.length > 0 ? convertFromDbRootMessage(message[0]) : undefined;
};

export const saveAggregatedRoots = async (
Expand Down
2 changes: 1 addition & 1 deletion packages/adapters/subgraph/src/lib/operations/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ export const getPropagatedOptimisticRootsByDomainQuery = (
for (const param of params) {
const prefix = config.sources[param.hub].prefix;
combinedQuery += `
${prefix}_optimisticRootFinalizeds (
${prefix}_optimisticRootPropagateds (
where: {}
) {
${PROPAGATED_OPTIMISTIC_ROOT_ENTITY}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const propagate = async () => {
throw new NoChainIdForHubDomain(config.hubDomain, requestContext, methodContext);
}

const relayerProxyHubAddress = config.chains[config.hubDomain].deployments.relayerProxy;
const rootManagerAddress = config.chains[config.hubDomain].deployments.relayerProxy;
const _connectors: string[] = [];
const _encodedData: string[] = [];
const _fees: string[] = [];
Expand Down Expand Up @@ -100,7 +100,7 @@ export const propagate = async () => {
const { taskId } = await sendWithRelayerWithBackup(
hubChainId,
config.hubDomain,
relayerProxyHubAddress,
rootManagerAddress,
encodedDataForRelayer,
relayers,
chainreader,
Expand All @@ -112,7 +112,7 @@ export const propagate = async () => {
logger.error("Error at sendWithRelayerWithBackup", requestContext, methodContext, e as NxtpError, {
hubChainId,
hubDomain: config.hubDomain,
relayerProxyHubAddress,
rootManagerAddress,
encodedDataForRelayer,
});
}
Expand All @@ -134,7 +134,7 @@ export const finalizeAndPropagate = async () => {
throw new NoChainIdForHubDomain(config.hubDomain, requestContext, methodContext);
}

const relayerProxyHubAddress = config.chains[config.hubDomain].deployments.relayerProxy;
const rootManagerAddress = config.chains[config.hubDomain].deployments.rootManager;
const _connectors: string[] = [];
const _encodedData: string[] = [];
const _fees: string[] = [];
Expand Down Expand Up @@ -212,7 +212,7 @@ export const finalizeAndPropagate = async () => {
_endOfDispute,
});

const encodedDataForRelayer = contracts.relayerProxyHub.encodeFunctionData("finalizeAndPropagateKeep3r", [
const encodedDataForRelayer = contracts.rootManager.encodeFunctionData("finalizeAndPropagate", [
_connectors,
_fees,
_encodedData,
Expand All @@ -224,19 +224,19 @@ export const finalizeAndPropagate = async () => {
const { taskId } = await sendWithRelayerWithBackup(
hubChainId,
config.hubDomain,
relayerProxyHubAddress,
rootManagerAddress,
encodedDataForRelayer,
relayers,
chainreader,
logger,
requestContext,
);
logger.info("finalizeAndPropagateKeep3r tx sent", requestContext, methodContext, { taskId });
logger.info("finalizeAndPropagate tx sent", requestContext, methodContext, { taskId });
} catch (e: unknown) {
logger.error("Error at sendWithRelayerWithBackup", requestContext, methodContext, e as NxtpError, {
hubChainId,
hubDomain: config.hubDomain,
relayerProxyHubAddress,
rootManagerAddress,
encodedDataForRelayer,
});
}
Expand Down
3 changes: 3 additions & 0 deletions packages/agents/lighthouse/src/tasks/propagate/propagate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainReader, contractDeployments, getAmbABIs, getContractInterfaces } from "@connext/nxtp-txservice";
import { closeDatabase, getDatabase } from "@connext/nxtp-adapters-database";
import {
ChainData,
createLoggingContext,
Expand Down Expand Up @@ -46,6 +47,7 @@ export const makePropagate = async (config: NxtpLighthouseConfig, chainData: Map
context.logger.child({ module: "ChainReader" }),
context.config.chains,
);
context.adapters.database = await getDatabase(context.config.database.url, context.logger);

context.adapters.relayers = [];
for (const relayerConfig of context.config.relayers) {
Expand Down Expand Up @@ -107,6 +109,7 @@ export const makePropagate = async (config: NxtpLighthouseConfig, chainData: Map
}
} catch (e: unknown) {
console.error("Error starting Propagate task. Sad! :(", e);
await closeDatabase();
} finally {
process.exit();
}
Expand Down
1 change: 0 additions & 1 deletion packages/agents/lighthouse/src/tasks/propose/propose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export const makePropose = async (config: NxtpLighthouseConfig, chainData: Map<s
} catch (e: unknown) {
console.error("Error starting Propose task. Sad! :(", e);
await closeDatabase();
process.exit();
} finally {
process.exit();
}
Expand Down

0 comments on commit 51294c4

Please sign in to comment.