Skip to content

Commit

Permalink
Fixed issue with wrong resolving of service
Browse files Browse the repository at this point in the history
  • Loading branch information
rpanic committed Jul 30, 2024
1 parent 493287b commit a7e1827
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/sequencer/src/mempool/private/PrivateMempool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class PrivateMempool extends SequencerModule implements Mempool {
);

throw new Error(
`Validation of tx ${tx.hash().toString()} failed: ${error ?? "unknown error"}`
`Validation of tx ${tx.hash().toString()} failed: ${error ?? "unknown error"}`
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Runtime,
RuntimeModulesRecord,
} from "@proto-kit/module";
import { Provable } from "o1js";

import { Mempool } from "../../../mempool/Mempool";
import {
Expand All @@ -25,7 +26,6 @@ import { CachedStateService } from "../../../state/state/CachedStateService";
import { MessageStorage } from "../../../storage/repositories/MessageStorage";

import { TransactionExecutionService } from "./TransactionExecutionService";
import { Provable } from "o1js";

export interface BlockConfig {
allowEmptyBlock?: boolean;
Expand All @@ -47,6 +47,7 @@ export class UnprovenProducerModule extends SequencerModule<BlockConfig> {
@inject("BlockTreeStore")
private readonly blockTreeStore: AsyncMerkleTreeStore,
private readonly executionService: TransactionExecutionService,
@inject("MethodIdResolver")
private readonly methodIdResolver: MethodIdResolver,
@inject("Runtime") private readonly runtime: Runtime<RuntimeModulesRecord>
) {
Expand All @@ -57,6 +58,42 @@ export class UnprovenProducerModule extends SequencerModule<BlockConfig> {
return this.config.allowEmptyBlock ?? true;
}

private prettyPrintBlockContents(block: UnprovenBlock) {
block.transactions.forEach((tx, i) => {
const methodName = this.methodIdResolver.getMethodNameFromId(
tx.tx.methodId.toBigInt()
);
if (!methodName) return;

const module = this.runtime.resolve(methodName[0]);
const paramEncoder = MethodParameterEncoder.fromMethod(
module,
methodName[1]
);

log.info("---------------------------------------");
log.info(`Transaction #${i}`);
log.info(
"Sender:",
tx.tx.sender.toBase58(),
"Nonce:",
tx.tx.nonce.toBigInt()
);
log.info(`Method: ${methodName?.join(".")}`);
log.info();
if (log.getLevel() <= log.levels.INFO) {
Provable.log("Arguments:", paramEncoder.decodeFields(tx.tx.argsFields));
}
log.info(
`Status: ${tx.status.toBoolean()}`,
tx.statusMessage !== undefined ? `Reason: ${tx.statusMessage}` : ""
);
});
if (block.transactions.length > 0) {
log.info("---------------------------------------");
}
}

public async tryProduceUnprovenBlock(): Promise<
UnprovenBlockWithMetadata | undefined
> {
Expand All @@ -74,34 +111,7 @@ export class UnprovenProducerModule extends SequencerModule<BlockConfig> {
}

log.info(`Produced unproven block (${block.transactions.length} txs)`);
block.transactions.forEach((tx, i) => {
const methodName = this.methodIdResolver.getMethodNameFromId(
tx.tx.methodId.toBigInt()
);
if (!methodName) return;

const module = this.runtime.resolve(methodName[0]);
const paramEncoder = MethodParameterEncoder.fromMethod(
module,
methodName[1]
);

log.info("---------------------------------------");
log.info(`Transaction #${i}`);
log.info(`Method: ${methodName?.join(".")}`);
log.info(
`Status: ${tx.status.toBoolean()}`,
tx.statusMessage !== undefined ? `Reason: ${tx.statusMessage}` : ""
);
log.info("Sender:", tx.tx.sender.toBase58());
log.info("Nonce:", tx.tx.nonce.toBigInt());
if (log.getLevel() === log.levels.INFO) {
Provable.log(
"Arguments:",
paramEncoder.decodeFields(tx.tx.argsFields)
);
}
});
this.prettyPrintBlockContents(block);

// Generate metadata for next block

Expand Down

0 comments on commit a7e1827

Please sign in to comment.