-
Notifications
You must be signed in to change notification settings - Fork 315
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
chore: prep for switching AVM to checkpointed native trees - TS test cleanup and refactors #12023
base: master
Are you sure you want to change the base?
Conversation
@@ -58,9 +40,10 @@ describe('AVM WitGen & Circuit – check circuit', () => { | |||
}, | |||
TIMEOUT, | |||
); | |||
// FIXME(dbanks12): fails with "Lookup PERM_MAIN_ALU failed." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was accidentally removed in a previous PR
std::hash::sha256(data) | ||
sha256::sha256_var(data, data.len() as u64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created this fn last week and used the old stdlib sha
#[public] | ||
fn assert_timestamp(expected_timestamp: u64) { | ||
let timestamp = context.timestamp(); | ||
assert(timestamp == expected_timestamp, "timestamp does not match"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
const tx = await mockTx(1234, { | ||
numberOfNonRevertiblePublicCallRequests: 2, | ||
numberOfRevertiblePublicCallRequests: 1, | ||
}); | ||
tx.data.constants.historicalHeader = context.getBlockHeader(0); | ||
tx.data.constants.vkTreeRoot = getVKTreeRoot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmed with @MirandaWood that this change should be okay
@@ -13,7 +13,6 @@ import { type PublicSideEffectTraceInterface } from '../public/side_effect_trace | |||
|
|||
export async function mockGetBytecode(worldStateDB: WorldStateDB, bytecode: Buffer) { | |||
const commitment = await computePublicBytecodeCommitment(bytecode); | |||
(worldStateDB as jest.Mocked<WorldStateDB>).getBytecode.mockResolvedValue(bytecode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wasn't used
|
||
export function getAvmTestContractFunctionSelector(functionName: string): Promise<FunctionSelector> { | ||
const artifact = AvmTestContractArtifact.functions.find(f => f.name === functionName)!; | ||
assert(!!artifact, `Function ${functionName} not found in AvmTestContractArtifact`); | ||
const params = artifact.parameters; | ||
return FunctionSelector.fromNameAndParameters(artifact.name, params); | ||
} | ||
|
||
export function getAvmTestContractArtifact(functionName: string): FunctionArtifact { | ||
const artifact = AvmTestContractArtifact.functions.find(f => f.name === functionName)!; | ||
assert( | ||
!!artifact?.bytecode, | ||
`No bytecode found for function ${functionName}. Try re-running bootstrap.sh on the repository root.`, | ||
); | ||
return artifact; | ||
} | ||
|
||
export function getAvmTestContractBytecode(functionName: string): Buffer { | ||
const artifact = getAvmTestContractArtifact(functionName); | ||
return artifact.bytecode; | ||
} | ||
|
||
export function getAvmTestContractPublicDispatchBytecode(): Buffer { | ||
return getAvmTestContractBytecode(PUBLIC_DISPATCH_FN_NAME); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these were duplicated from avm/fixtures
This stack of pull requests is managed by Graphite. Learn more about stacking. |
5b9afbc
to
27f2797
Compare
27f2797
to
5b9afbc
Compare
This PR is mostly setup for switching the AVM to use checkpointed native trees. Originally I had that in the same branch, but there were enough of these prerequisite changes to pull them out.
Orchestrator testing
prover-client's
TestContext
no longer mocks AVM simulation.Context: while trying to transition the AVM to use native checkpointed trees, I ran into issues with the orchestrator public functions tests because the public processor will no longer update the trees for public functions. So, I think we should stop mocking the AVM simulation for these tests and let the AVM do its tree updates. We can then do two types of tests:
orchestrator_public_functions.test.ts
now does this.orchestrator_multi_public_functions.test.ts
now does this.AVM & PublicProcessor testing
PublicTxSimulationTester
lets youcreateTx
separately fromsimulateTx
(useful for testingPublicProcessor
)PublicTxSimulator
test for avm bulk testPublicProcessor
test of the token contract (construct, mint, many transfers)simulator/src/avm
andsimulator/src/public
*Tester
classes, and optional contract address nullifier insertionregister*()
function instead of manually constructing contract classes and instancesMisc