-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: serialize AvmVerificationKeyData (#8529)
This PR adds a integration test for the RPC layer between the queue and agent to validate that all the function calls correctly encode/decode their inputs and outputs.
- Loading branch information
Showing
8 changed files
with
276 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
yarn-project/prover-client/src/prover-agent/agent-queue-rpc-integration.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { PublicKernelType, type ServerCircuitProver } from '@aztec/circuit-types'; | ||
import { ClientIvcProof, Fr, PrivateKernelEmptyInputData, TubeInputs } from '@aztec/circuits.js'; | ||
import { | ||
makeAvmCircuitInputs, | ||
makeBaseParityInputs, | ||
makeBaseRollupInputs, | ||
makeBlockMergeRollupInputs, | ||
makeBlockRootRollupInputs, | ||
makeHeader, | ||
makeMergeRollupInputs, | ||
makePublicKernelCircuitPrivateInputs, | ||
makePublicKernelTailCircuitPrivateInputs, | ||
makeRootParityInputs, | ||
makeRootRollupInputs, | ||
} from '@aztec/circuits.js/testing'; | ||
import { type JsonRpcServer } from '@aztec/foundation/json-rpc/server'; | ||
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop'; | ||
|
||
import getPort from 'get-port'; | ||
|
||
import { MockProver } from '../test/mock_prover.js'; | ||
import { MemoryProvingQueue } from './memory-proving-queue.js'; | ||
import { ProverAgent } from './prover-agent.js'; | ||
import { createProvingJobSourceClient, createProvingJobSourceServer } from './rpc.js'; | ||
|
||
describe('Prover agent <-> queue integration', () => { | ||
let queue: MemoryProvingQueue; | ||
let queueRpcServer: JsonRpcServer; | ||
let agent: ProverAgent; | ||
let prover: ServerCircuitProver; | ||
|
||
type MakeInputs = { | ||
[K in keyof ServerCircuitProver]: () => Parameters<ServerCircuitProver[K]>[0]; | ||
}; | ||
|
||
const makeInputs: MakeInputs = { | ||
getAvmProof: makeAvmCircuitInputs, | ||
getBaseParityProof: makeBaseParityInputs, | ||
getBaseRollupProof: makeBaseRollupInputs, | ||
getRootParityProof: makeRootParityInputs, | ||
getBlockMergeRollupProof: makeBlockMergeRollupInputs, | ||
getBlockRootRollupProof: makeBlockRootRollupInputs, | ||
getEmptyPrivateKernelProof: () => | ||
new PrivateKernelEmptyInputData(makeHeader(), Fr.random(), Fr.random(), Fr.random()), | ||
getEmptyTubeProof: () => new PrivateKernelEmptyInputData(makeHeader(), Fr.random(), Fr.random(), Fr.random()), | ||
getMergeRollupProof: makeMergeRollupInputs, | ||
getPublicKernelProof: () => { | ||
return { | ||
type: PublicKernelType.APP_LOGIC, | ||
inputs: makePublicKernelCircuitPrivateInputs(), | ||
}; | ||
}, | ||
getPublicTailProof: () => { | ||
return { | ||
type: PublicKernelType.TAIL, | ||
inputs: makePublicKernelTailCircuitPrivateInputs(), | ||
}; | ||
}, | ||
getRootRollupProof: makeRootRollupInputs, | ||
getTubeProof: () => new TubeInputs(ClientIvcProof.empty()), | ||
}; | ||
|
||
beforeEach(async () => { | ||
prover = new MockProver(); | ||
|
||
queue = new MemoryProvingQueue(new NoopTelemetryClient(), 100, 10); | ||
queue.start(); | ||
const port = await getPort(); | ||
queueRpcServer = createProvingJobSourceServer(queue); | ||
queueRpcServer.start(port); | ||
|
||
agent = new ProverAgent(prover, 1, 10); | ||
const queueRpcClient = createProvingJobSourceClient(`http://127.0.0.1:${port}`); | ||
agent.start(queueRpcClient); | ||
}); | ||
|
||
afterEach(async () => { | ||
await agent.stop(); | ||
await queueRpcServer.stop(); | ||
await queue.stop(); | ||
}); | ||
|
||
it.each(Object.entries(makeInputs))('can call %s over JSON-RPC', async (fnName, makeInputs) => { | ||
const resp = await queue[fnName as keyof ServerCircuitProver](makeInputs() as any); | ||
expect(resp).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import { | ||
type PublicInputsAndRecursiveProof, | ||
type PublicInputsAndTubeProof, | ||
type ServerCircuitProver, | ||
makePublicInputsAndRecursiveProof, | ||
} from '@aztec/circuit-types'; | ||
import { | ||
AvmVerificationKeyData, | ||
type BaseOrMergeRollupPublicInputs, | ||
type BlockRootOrBlockMergePublicInputs, | ||
type KernelCircuitPublicInputs, | ||
type PublicKernelCircuitPublicInputs, | ||
RECURSIVE_PROOF_LENGTH, | ||
type RecursiveProof, | ||
type RootRollupPublicInputs, | ||
VerificationKeyData, | ||
makeEmptyProof, | ||
makeRecursiveProof, | ||
} from '@aztec/circuits.js'; | ||
import { | ||
makeBaseOrMergeRollupPublicInputs, | ||
makeBlockRootOrBlockMergeRollupPublicInputs, | ||
makeKernelCircuitPublicInputs, | ||
makePublicKernelCircuitPublicInputs, | ||
makeRootParityInput, | ||
makeRootRollupPublicInputs, | ||
} from '@aztec/circuits.js/testing'; | ||
|
||
export class MockProver implements ServerCircuitProver { | ||
constructor() {} | ||
|
||
getAvmProof() { | ||
return Promise.resolve( | ||
Promise.resolve({ | ||
proof: makeEmptyProof(), | ||
verificationKey: AvmVerificationKeyData.makeFake(), | ||
}), | ||
); | ||
} | ||
|
||
getBaseParityProof() { | ||
return Promise.resolve(makeRootParityInput(RECURSIVE_PROOF_LENGTH)); | ||
} | ||
|
||
getRootParityProof() { | ||
return Promise.resolve(makeRootParityInput(RECURSIVE_PROOF_LENGTH)); | ||
} | ||
|
||
getBaseRollupProof() { | ||
return Promise.resolve( | ||
makePublicInputsAndRecursiveProof( | ||
makeBaseOrMergeRollupPublicInputs(), | ||
makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
VerificationKeyData.makeFake(), | ||
), | ||
); | ||
} | ||
|
||
getMergeRollupProof(): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs>> { | ||
return Promise.resolve( | ||
makePublicInputsAndRecursiveProof( | ||
makeBaseOrMergeRollupPublicInputs(), | ||
makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
VerificationKeyData.makeFake(), | ||
), | ||
); | ||
} | ||
|
||
getBlockMergeRollupProof() { | ||
return Promise.resolve( | ||
makePublicInputsAndRecursiveProof( | ||
makeBlockRootOrBlockMergeRollupPublicInputs(), | ||
makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
VerificationKeyData.makeFake(), | ||
), | ||
); | ||
} | ||
|
||
getBlockRootRollupProof(): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs>> { | ||
return Promise.resolve( | ||
makePublicInputsAndRecursiveProof( | ||
makeBlockRootOrBlockMergeRollupPublicInputs(), | ||
makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
VerificationKeyData.makeFake(), | ||
), | ||
); | ||
} | ||
|
||
getEmptyPrivateKernelProof(): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> { | ||
return Promise.resolve( | ||
makePublicInputsAndRecursiveProof( | ||
makeKernelCircuitPublicInputs(), | ||
makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
VerificationKeyData.makeFake(), | ||
), | ||
); | ||
} | ||
|
||
getEmptyTubeProof(): Promise<PublicInputsAndTubeProof<KernelCircuitPublicInputs>> { | ||
return Promise.resolve( | ||
makePublicInputsAndRecursiveProof( | ||
makeKernelCircuitPublicInputs(), | ||
makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
VerificationKeyData.makeFake(), | ||
), | ||
); | ||
} | ||
|
||
getPublicKernelProof(): Promise<PublicInputsAndRecursiveProof<PublicKernelCircuitPublicInputs>> { | ||
return Promise.resolve( | ||
makePublicInputsAndRecursiveProof( | ||
makePublicKernelCircuitPublicInputs(), | ||
makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
VerificationKeyData.makeFake(), | ||
), | ||
); | ||
} | ||
|
||
getPublicTailProof(): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> { | ||
return Promise.resolve( | ||
makePublicInputsAndRecursiveProof( | ||
makeKernelCircuitPublicInputs(), | ||
makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
VerificationKeyData.makeFake(), | ||
), | ||
); | ||
} | ||
|
||
getRootRollupProof(): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs>> { | ||
return Promise.resolve( | ||
makePublicInputsAndRecursiveProof( | ||
makeRootRollupPublicInputs(), | ||
makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
VerificationKeyData.makeFake(), | ||
), | ||
); | ||
} | ||
|
||
getTubeProof(): Promise<{ | ||
tubeVK: VerificationKeyData; | ||
tubeProof: RecursiveProof<typeof RECURSIVE_PROOF_LENGTH>; | ||
}> { | ||
return Promise.resolve({ | ||
tubeVK: VerificationKeyData.makeFake(), | ||
tubeProof: makeRecursiveProof(RECURSIVE_PROOF_LENGTH), | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters