Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made log calls more efficient #213

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"coverage:report": "yarn coverage:filtered-report && yarn coverage:htmlreport && yarn coverage:open-report",
"coverage:refresh": "yarn coverage:filtered-report && yarn coverage:htmlreport",
"propmon:ui": "cd src-ts && http-server . -p 8080",
"propmon:service": "ts-node ./src-ts/proposalMonitorCli.ts --jsonOutputLocation ./src-ts/propMonUi/proposalState.json --l1RpcUrl $ETH_RPC --govChainRpcUrl https://arb1.arbitrum.io/rpc --novaRpcUrl https://nova.arbitrum.io/rpc --coreGovernorAddress 0xf07DeD9dC292157749B6Fd268E37DF6EA38395B9 --treasuryGovernorAddress 0x789fC99093B09aD01C34DC7251D0C89ce743e5a4 --sevenTwelveCouncil 0x895c9fc6bcf06e553b54A9fE11D948D67a9B76FA --pollingIntervalSeconds 1",
"propmon:service": "ts-node ./src-ts/proposalMonitorCli.ts --jsonOutputLocation ./src-ts/propMonUi/proposalState.json --l1RpcUrl $ETH_RPC --govChainRpcUrl https://arb1.arbitrum.io/rpc --novaRpcUrl https://nova.arbitrum.io/rpc --coreGovernorAddress 0xf07DeD9dC292157749B6Fd268E37DF6EA38395B9 --treasuryGovernorAddress 0x789fC99093B09aD01C34DC7251D0C89ce743e5a4 --sevenTwelveCouncil 0x895c9fc6bcf06e553b54A9fE11D948D67a9B76FA --pollingIntervalSeconds 5",
"propmon": "yarn propmon:service & yarn propmon:ui"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion src-ts/proposalMonitorCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ const main = async () => {
}

const stageFactory = new StageFactory(
options.startBlock,
govChainSignerOrProvider,
l1SignerOrProvider,
novaSignerOrProvider
Expand Down
11 changes: 3 additions & 8 deletions src-ts/proposalPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { wait } from "./utils";

export class StageFactory {
constructor(
public readonly startBlock: number,
public readonly arbOneSignerOrProvider: Signer | Provider,
public readonly l1SignerOrProvider: Signer | Provider,
public readonly novaSignerOrProvider: Signer | Provider
Expand All @@ -27,11 +26,7 @@ export class StageFactory {
public async extractStages(receipt: TransactionReceipt): Promise<ProposalStage[]> {
return [
...(await GovernorQueueStage.extractStages(receipt, this.arbOneSignerOrProvider)),
...(await L2TimelockExecutionBatchStage.extractStages(
receipt,
this.arbOneSignerOrProvider,
this.startBlock
)),
...(await L2TimelockExecutionBatchStage.extractStages(receipt, this.arbOneSignerOrProvider)),
...(await L1TimelockExecutionSingleStage.extractStages(receipt, this.l1SignerOrProvider)),
...(await L1TimelockExecutionBatchStage.extractStages(receipt, this.l1SignerOrProvider)),
...(await RetryableExecutionStage.extractStages(receipt, this.arbOneSignerOrProvider)),
Expand Down Expand Up @@ -65,7 +60,6 @@ export interface TrackerEvent {
publicExecutionUrl?: string;
error?: Error;
proposalDescription?: string;

}

export class StageTracker extends EventEmitter {
Expand Down Expand Up @@ -109,7 +103,8 @@ export class StageTracker extends EventEmitter {
status === ProposalStageStatus.EXECUTED
? await this.stage.getExecutionUrl()
: undefined,
proposalDescription: this.stage instanceof GovernorQueueStage ? this.stage.description : undefined
proposalDescription:
this.stage instanceof GovernorQueueStage ? this.stage.description : undefined,
});
currentStatus = status;
}
Expand Down
36 changes: 22 additions & 14 deletions src-ts/proposalStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
ProposalCreatedEventObject,
ProposalQueuedEventObject,
} from "../typechain-types/src/L2ArbitrumGovernor";
import { CallScheduledEventObject } from "../typechain-types/src/ArbitrumTimelock";
type Provider = providers.Provider;

export function isSigner(signerOrProvider: Signer | Provider): signerOrProvider is Signer {
Expand Down Expand Up @@ -277,13 +276,15 @@ export class L2TimelockExecutionBatchStage implements ProposalStage {
governor: string,
proposalId: string,
provider: Provider,
startBlock: number
startBlock: number,
endBlock: number
): Promise<ProposalCreatedEventObject | undefined> {
const govInterface = L2ArbitrumGovernor__factory.createInterface();
const filterTopics = govInterface.encodeFilterTopics("ProposalCreated", []);

const logs = await provider.getLogs({
fromBlock: startBlock,
toBlock: "latest",
toBlock: endBlock,
address: governor,
topics: filterTopics,
});
Expand Down Expand Up @@ -319,25 +320,29 @@ export class L2TimelockExecutionBatchStage implements ProposalStage {

public static async extractStages(
receipt: TransactionReceipt,
arbOneSignerOrProvider: Provider | Signer,
startBlock: number
arbOneSignerOrProvider: Provider | Signer
): Promise<L2TimelockExecutionBatchStage[]> {
const govInterface = L2ArbitrumGovernor__factory.createInterface();
const proposalStages: L2TimelockExecutionBatchStage[] = [];
for (const log of receipt.logs) {
if (log.topics.find((t) => t === govInterface.getEventTopic("ProposalQueued"))) {
const propCreatedObj = govInterface.parseLog(log)
const propQueuedObj = govInterface.parseLog(log)
.args as unknown as ProposalQueuedEventObject;

// 10m ~ 1 month on arbitrum
const propCreatedStart = log.blockNumber - 10000000;
const propCreatedEnd = log.blockNumber;

const propCreatedEvent = await this.getProposalCreatedData(
log.address,
propCreatedObj.proposalId.toHexString(),
propQueuedObj.proposalId.toHexString(),
await getProvider(arbOneSignerOrProvider)!,
startBlock
propCreatedStart,
propCreatedEnd
);
if (!propCreatedEvent) {
throw new Error(
`Could not find proposal created event: ${propCreatedObj.proposalId.toHexString()}`
`Could not find proposal created event: ${propQueuedObj.proposalId.toHexString()}`
);
}
// calculate the operation id, and look for it in this receipt
Expand All @@ -362,7 +367,6 @@ export class L2TimelockExecutionBatchStage implements ProposalStage {
timelockAddress,
arbOneSignerOrProvider
);

proposalStages.push(executeBatch);
}
}
Expand Down Expand Up @@ -918,12 +922,16 @@ export class RetryableExecutionStage implements ProposalStage {
const stages: RetryableExecutionStage[] = [];
const l1Receipt = new L1TransactionReceipt(receipt);
const l1ToL2Events = l1Receipt.getMessageEvents();
const network = await getL2Network(l2ProviderOrSigner);
let network;
for (const e of l1ToL2Events.filter(
(e) =>
e.bridgeMessageEvent.kind === InboxMessageKind.L1MessageType_submitRetryableTx &&
e.bridgeMessageEvent.inbox.toLowerCase() === network.ethBridge.inbox.toLowerCase()
(e) => e.bridgeMessageEvent.kind === InboxMessageKind.L1MessageType_submitRetryableTx
)) {
if (!network) {
network = await getL2Network(l2ProviderOrSigner);
}
if (e.bridgeMessageEvent.inbox.toLowerCase() !== network.ethBridge.inbox.toLowerCase()) {
continue;
}
const messageParser = new SubmitRetryableMessageDataParser();
const inboxMessageData = messageParser.parse(e.inboxMessageEvent.data);
const message = L1ToL2Message.fromEventComponents(
Expand Down
28 changes: 4 additions & 24 deletions test-ts/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,7 @@ export const l2L1MonitoringValueTest = async (
proposalString
);

const stageFactory = new StageFactory(
await l2Signer.provider!.getBlockNumber(),
l2Signer,
l1Signer,
l2Signer
);
const stageFactory = new StageFactory(l2Signer, l1Signer, l2Signer);
const proposalMonitor = new GovernorProposalMonitor(
l2GovernorContract.address,
l2Signer.provider!,
Expand Down Expand Up @@ -442,12 +437,7 @@ export const l2L1L2MonitoringValueTest = async (
[transferExecution],
proposalString
);
const stageFactory = new StageFactory(
await l2Signer.provider!.getBlockNumber(),
l2Signer,
l1Signer,
l2Signer
);
const stageFactory = new StageFactory(l2Signer, l1Signer, l2Signer);
const proposalMonitor = new GovernorProposalMonitor(
l2GovernorContract.address,
l2Signer.provider!,
Expand Down Expand Up @@ -546,12 +536,7 @@ export const l2L1MonitoringTest = async (
proposalString
);

const stageFactory = new StageFactory(
await l2Signer.provider!.getBlockNumber(),
l2Signer,
l1Signer,
l2Signer
);
const stageFactory = new StageFactory(l2Signer, l1Signer, l2Signer);
const proposalMonitor = new GovernorProposalMonitor(
l2GovernorContract.address,
l2Signer.provider!,
Expand Down Expand Up @@ -644,12 +629,7 @@ export const l2L1L2MonitoringTest = async (
proposalString
);

const stageFactory = new StageFactory(
await l2Signer.provider!.getBlockNumber(),
l2Signer,
l1Signer,
l2Signer
);
const stageFactory = new StageFactory(l2Signer, l1Signer, l2Signer);
const proposalMonitor = new GovernorProposalMonitor(
l2GovernorContract.address,
l2Signer.provider!,
Expand Down