Skip to content

Commit

Permalink
added settlement module keys config, and worker startup signed settle…
Browse files Browse the repository at this point in the history
…ment to the payload
  • Loading branch information
maht0rz committed Dec 9, 2024
1 parent 22e6c1d commit ffd08ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/sequencer/src/sequencer/SequencerStartupModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
CompilerTaskParams,
} from "../protocol/production/tasks/CircuitCompilerTask";
import { VerificationKeyService } from "../protocol/runtime/RuntimeVerificationKeyService";
import { SettlementModule } from "../settlement/SettlementModule";

import { SequencerModule, sequencerModule } from "./builder/SequencerModule";

Expand All @@ -31,7 +32,8 @@ export class SequencerStartupModule extends SequencerModule {
private readonly compileTask: CircuitCompilerTask,
private readonly verificationKeyService: VerificationKeyService,
private readonly registrationFlow: WorkerRegistrationFlow,
private readonly compileRegistry: CompileRegistry
private readonly compileRegistry: CompileRegistry,
private readonly settlementModule: SettlementModule
) {
super();
}
Expand Down Expand Up @@ -140,6 +142,7 @@ export class SequencerStartupModule extends SequencerModule {
runtimeVerificationKeyRoot: root,
bridgeContractVerificationKey: bridgeVk?.verificationKey,
compiledArtifacts: this.compileRegistry.getAllArtifacts(),
signedSettlements: this.settlementModule.utils.isSignedSettlement(),
});

log.info("Protocol circuits compiled successfully, commencing startup");
Expand Down
3 changes: 3 additions & 0 deletions packages/sequencer/src/settlement/SettlementModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface SettlementModuleConfig {
keys?: {
settlement: PrivateKey;
dispatch: PrivateKey;
minaBridge: PrivateKey;
};
}

Expand Down Expand Up @@ -428,6 +429,8 @@ export class SettlementModule
}

public async start(): Promise<void> {
this.keys = this.config.keys;
this.addresses = this.config.addresses;
const contractArgs = SettlementSmartContractBase.args;

SettlementSmartContractBase.args = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ArtifactRecordSerializer,
SerializedArtifactRecord,
} from "../../../protocol/production/tasks/CircuitCompilerTask";
import { SettlementModule } from "../../../settlement/SettlementModule";

import { CloseWorkerError } from "./CloseWorkerError";

Expand All @@ -32,6 +33,7 @@ export type WorkerStartupPayload = {
// This has to be nullable, since
bridgeContractVerificationKey?: VerificationKey;
compiledArtifacts: ArtifactRecord;
signedSettlements: boolean;
};

@injectable()
Expand All @@ -44,6 +46,7 @@ export class WorkerRegistrationTask

public constructor(
@inject("Protocol") private readonly protocol: Protocol<any>,
@inject("SettlementModule") settlementModule: SettlementModule,
private readonly compileRegistry: CompileRegistry
) {
super();
Expand Down Expand Up @@ -71,6 +74,9 @@ export class WorkerRegistrationTask
input.bridgeContractVerificationKey;
}

SettlementSmartContractBase.args.signedSettlements =
input.signedSettlements;

this.compileRegistry.addArtifactsRaw(input.compiledArtifacts);
this.protocol.dependencyContainer
.resolve(ChildVerificationKeyService)
Expand All @@ -87,6 +93,7 @@ export class WorkerRegistrationTask
runtimeVerificationKeyRoot: string;
bridgeContractVerificationKey: VerificationKeyJSON | undefined;
compiledArtifacts: SerializedArtifactRecord;
signedSettlements: boolean;
};

const artifactSerializer = new ArtifactRecordSerializer();
Expand All @@ -104,6 +111,7 @@ export class WorkerRegistrationTask
compiledArtifacts: artifactSerializer.toJSON(
payload.compiledArtifacts
),
signedSettlements: payload.signedSettlements,
} satisfies WorkerStartupPayloadJSON);
},
fromJSON: (payload: string) => {
Expand All @@ -122,6 +130,7 @@ export class WorkerRegistrationTask
compiledArtifacts: artifactSerializer.fromJSON(
jsonObject.compiledArtifacts
),
signedSettlements: jsonObject.signedSettlements,
};
},
};
Expand Down

0 comments on commit ffd08ec

Please sign in to comment.