Skip to content
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
12 changes: 0 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"@proto-kit/protocol": "*",
"@proto-kit/sequencer": "*",
"o1js": "2.10.0-dev.6d3a3",
"@o1js/native": "2.10.0-dev.6d3a3",
"tsyringe": "^4.10.0"
},
"devDependencies": {
Expand Down
7 changes: 5 additions & 2 deletions packages/api/src/graphql/GraphqlSequencerModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { buildSchemaSync, NonEmptyArray } from "type-graphql";
import { Closeable, closeable, SequencerModule } from "@proto-kit/sequencer";
import {
ChildContainerProvider,
Configurable,
CombinedModuleContainerConfig,
log,
ModuleContainer,
Expand Down Expand Up @@ -48,7 +47,11 @@ function assertArrayIsNotEmpty<T>(
@closeable()
export class GraphqlSequencerModule<GraphQLModules extends GraphqlModulesRecord>
extends ModuleContainer<GraphQLModules, GraphqlServerConfig>
implements Configurable<unknown>, SequencerModule<unknown>, Closeable
implements
SequencerModule<
CombinedModuleContainerConfig<GraphQLModules, GraphqlServerConfig>
>,
Closeable
{
private readonly modules: TypedClass<GraphqlModule<unknown>>[] = [];

Expand Down
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@proto-kit/stack": "*",
"@proto-kit/indexer": "*",
"o1js": "2.10.0-dev.6d3a3",
"@o1js/native": "2.10.0-dev.6d3a3",
"tsyringe": "^4.10.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/lightnet/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface InitializeArgs {
export const initializeCommand: CommandModule<{}, InitializeArgs> = {
command: "initialize",
describe:
"Initialize lightnet: wait for network, fund accounts, and deploy settlement\n\nRequires: MINA_NODE_GRAPHQL_HOST, MINA_NODE_GRAPHQL_PORT, MINA_ARCHIVE_GRAPHQL_HOST, MINA_ARCHIVE_GRAPHQL_PORT, MINA_ACCOUNT_MANAGER_HOST, MINA_ACCOUNT_MANAGER_PORT, PROTOKIT_SETTLEMENT_CONTRACT_PRIVATE_KEY, PROTOKIT_DISPATCHER_CONTRACT_PRIVATE_KEY, PROTOKIT_MINA_BRIDGE_CONTRACT_PRIVATE_KEY",
"Initialize lightnet: wait for network, fund accounts, and deploy settlement\n\nRequires: MINA_NODE_GRAPHQL, MINA_ARCHIVE_GRAPHQL, MINA_ACCOUNT_MANAGER_URL, PROTOKIT_SETTLEMENT_CONTRACT_PRIVATE_KEY, PROTOKIT_DISPATCHER_CONTRACT_PRIVATE_KEY, PROTOKIT_MINA_BRIDGE_CONTRACT_PRIVATE_KEY",
builder: (yarg) => addEnvironmentOptions(yarg),
handler: async (args) => {
try {
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/lightnet/waitForNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ interface WaitForNetworkArgs {

export const waitForNetworkCommand: CommandModule<{}, WaitForNetworkArgs> = {
command: "wait",
describe:
"Wait for network to be ready\n\nRequires: MINA_NODE_GRAPHQL_HOST, MINA_NODE_GRAPHQL_PORT",
describe: "Wait for network to be ready\n\nRequires: MINA_NODE_GRAPHQL",
builder: (yarg) => addEnvironmentOptions(yarg),
handler: async (args) => {
try {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/scripts/lightnet/faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export default async function (publicKey: string) {
const fundingAmount = 1000 * 1e9;

const net = Mina.Network({
mina: `${getRequiredEnv("MINA_NODE_GRAPHQL_HOST")}:${getRequiredEnv("MINA_NODE_GRAPHQL_PORT")}/graphql`,
archive: `${getRequiredEnv("MINA_ARCHIVE_GRAPHQL_HOST")}:${getRequiredEnv("MINA_ARCHIVE_GRAPHQL_PORT")}/graphql`,
lightnetAccountManager: `${getRequiredEnv("MINA_ACCOUNT_MANAGER_HOST")}:${getRequiredEnv("MINA_ACCOUNT_MANAGER_PORT")}`,
mina: getRequiredEnv("MINA_NODE_GRAPHQL"),
archive: getRequiredEnv("MINA_ARCHIVE_GRAPHQL"),
lightnetAccountManager: getRequiredEnv("MINA_ACCOUNT_MANAGER_URL"),
});

Mina.setActiveInstance(net);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/scripts/lightnet/wait-for-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default async function (options: LoadEnvOptions) {
const { sleep } = await import("@proto-kit/common");
const { fetchLastBlock, Provable } = await import("o1js");
loadEnvironmentVariables(options);
const graphqlEndpoint = `${getRequiredEnv("MINA_NODE_GRAPHQL_HOST")}:${getRequiredEnv("MINA_NODE_GRAPHQL_PORT")}/graphql`;
const graphqlEndpoint = getRequiredEnv("MINA_NODE_GRAPHQL");
let lastBlock;
let attempt = 0;
console.log("Waiting for network to be ready...");
Expand Down
10 changes: 4 additions & 6 deletions packages/cli/src/scripts/settlement/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default async function (options: LoadEnvOptions) {
MinaBaseLayer,
PrivateMempool,
LocalTaskQueue,
LocalTaskWorkerModule,
WorkerModule,
VanillaTaskWorkerModules,
SequencerStartupModule,
} = await import("@proto-kit/sequencer");
Expand All @@ -49,9 +49,7 @@ export default async function (options: LoadEnvOptions) {
BridgingModule,
Mempool: PrivateMempool,
TaskQueue: LocalTaskQueue,
LocalTaskWorker: LocalTaskWorkerModule.from(
VanillaTaskWorkerModules.allTasks()
),
WorkerModule: WorkerModule.from(VanillaTaskWorkerModules.allTasks()),
SequencerStartupModule,
}),
});
Expand All @@ -71,7 +69,7 @@ export default async function (options: LoadEnvOptions) {
type: process.env.MINA_NETWORK as any,
graphql: process.env.MINA_NODE_GRAPHQL!,
archive: process.env.MINA_ARCHIVE_GRAPHQL!,
accountManager: process.env.MINA_ACCOUNT_MANAGER!,
accountManager: process.env.MINA_ACCOUNT_MANAGER_URL!,
},
},
SettlementSigner: {
Expand Down Expand Up @@ -102,7 +100,7 @@ export default async function (options: LoadEnvOptions) {
TaskQueue: {
simulatedDuration: 0,
},
LocalTaskWorker: VanillaTaskWorkerModules.defaultConfig(),
WorkerModule: VanillaTaskWorkerModules.defaultConfig(),
Mempool: {},
},
});
Expand Down
1 change: 0 additions & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
},
"peerDependencies": {
"o1js": "2.10.0-dev.6d3a3",
"@o1js/native": "2.10.0-dev.6d3a3",
"tsyringe": "^4.10.0"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/deployment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@proto-kit/sequencer": "*",
"bullmq": "^4.18.3",
"o1js": "2.10.0-dev.6d3a3",
"@o1js/native": "2.10.0-dev.6d3a3",
"tsyringe": "^4.10.0"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"@proto-kit/sequencer": "*",
"koa": "^2.14.2",
"o1js": "2.10.0-dev.6d3a3",
"@o1js/native": "2.10.0-dev.6d3a3",
"tsyringe": "^4.10.0",
"type-graphql": "2.0.0-rc.2",
"typegraphql-prisma": "0.28"
Expand Down
6 changes: 5 additions & 1 deletion packages/indexer/src/tasks/IndexBatchTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import {
TaskWorkerModule,
Batch,
BatchStorage,
task,
} from "@proto-kit/sequencer";
import { inject, injectable } from "tsyringe";
import { log } from "@proto-kit/common";

@injectable()
@task()
export class IndexBatchTask
extends TaskWorkerModule
implements Task<Batch, string | void>
Expand All @@ -28,11 +30,13 @@ export class IndexBatchTask
public async compute(input: Batch): Promise<string | void> {
try {
await this.batchStorage.pushBatch(input);

log.info(`Batch ${input.height} indexed successfully`);
return "";
} catch (err) {
log.error("Failed to process settlement task", err);
return undefined;
}
return undefined;
}

public inputSerializer(): TaskSerializer<Batch> {
Expand Down
35 changes: 33 additions & 2 deletions packages/indexer/src/tasks/IndexBlockTask.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
Block,
BlockQueue,
task,
Task,
TaskSerializer,
TaskWorkerModule,
TransactionStorage,
} from "@proto-kit/sequencer";
import { log } from "@proto-kit/common";
import { inject, injectable } from "tsyringe";
Expand All @@ -24,26 +26,55 @@ export class IndexBlockTask
public constructor(
public taskSerializer: IndexBlockTaskParametersSerializer,
@inject("BlockQueue")
public blockStorage: BlockQueue
public blockStorage: BlockQueue,
@inject("TransactionStorage")
public transactionStorage: TransactionStorage
) {
super();
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
public async prepare(): Promise<void> {}

private async syncTransactions(block: Block) {
const results = await Promise.all(
block.transactions.map(async ({ tx }) => {
return [
tx,
await this.transactionStorage.findTransaction(tx.hash().toString()),
] as const;
})
);

const missingTxs = results
.filter(([, result]) => result === undefined)
.map(([tx]) => tx);

const pushResults = await Promise.all(
missingTxs.map(
async (tx) => await this.transactionStorage.pushUserTransaction(tx, 0)
)
);
if (pushResults.some((x) => !x)) {
log.error(
"Some transactions haven't been pushed, this will lead to constraint errors!"
);
}
}

public async compute(
input: IndexBlockTaskParameters
): Promise<string | void> {
try {
await this.syncTransactions(input.block);
await this.blockStorage.pushBlock(input.block);
await this.blockStorage.pushResult(input.result);
} catch (error) {
log.error("Failed to index block", input.block.height.toBigInt(), error);
return undefined;
}

log.info(`Block ${input.block.height.toBigInt()} indexed sucessfully`);
log.info(`Block ${input.block.height.toBigInt()} indexed successfully`);
return "";
}

Expand Down
2 changes: 2 additions & 0 deletions packages/indexer/src/tasks/IndexPendingTxTask.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
PendingTransaction,
task,
Task,
TaskSerializer,
TaskWorkerModule,
Expand All @@ -11,6 +12,7 @@ import { inject, injectable } from "tsyringe";
import { IndexPendingTxTaskParametersSerializer } from "./IndexPendingTxTaskParameters";

@injectable()
@task()
export class IndexPendingTxTask
extends TaskWorkerModule
implements Task<PendingTransaction, string | void>
Expand Down
4 changes: 4 additions & 0 deletions packages/indexer/src/tasks/IndexSettlementTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import {
TaskWorkerModule,
Settlement,
SettlementStorage,
task,
} from "@proto-kit/sequencer";
import { inject, injectable } from "tsyringe";
import { log } from "@proto-kit/common";

@injectable()
@task()
export class IndexSettlementTask
extends TaskWorkerModule
implements Task<Settlement, string | void>
Expand All @@ -28,6 +30,8 @@ export class IndexSettlementTask
public async compute(input: Settlement): Promise<string | void> {
try {
await this.settlementStorage.pushSettlement(input);

log.info(`Settlement ${input.batches.at(-1)!} indexed successfully`);
return "";
} catch (err) {
log.error("Failed to process settlement task", err);
Expand Down
1 change: 0 additions & 1 deletion packages/library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"@proto-kit/protocol": "*",
"@proto-kit/sequencer": "*",
"o1js": "2.10.0-dev.6d3a3",
"@o1js/native": "2.10.0-dev.6d3a3",
"tsyringe": "^4.10.0"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"@proto-kit/common": "*",
"@proto-kit/protocol": "*",
"o1js": "2.10.0-dev.6d3a3",
"@o1js/native": "2.10.0-dev.6d3a3",
"tsyringe": "^4.10.0"
},
"gitHead": "8a7eca319272a15162dc4ad04bdc134b1017716d"
Expand Down
1 change: 0 additions & 1 deletion packages/persistance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@proto-kit/protocol": "*",
"@proto-kit/sequencer": "*",
"o1js": "2.10.0-dev.6d3a3",
"@o1js/native": "2.10.0-dev.6d3a3",
"tsyringe": "^4.10.0"
},
"devDependencies": {
Expand Down
Loading
Loading