Skip to content

Commit

Permalink
chore(avm): nit fixes on message opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro committed Mar 4, 2024
1 parent 64955f6 commit fa53136
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 4 additions & 2 deletions yarn-project/simulator/src/avm/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ export function allSameExcept(original: any, overrides: any): any {
/**
* Create an empty L1ToL2Message oracle input
*/
export function initL1ToL2MessageOracleInput(leafIndex?: bigint): any {
export function initL1ToL2MessageOracleInput(
leafIndex?: bigint,
): MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT> {
return new MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>(
leafIndex ? leafIndex : BigInt(0),
leafIndex ?? 0n,
new SiblingPath(L1_TO_L2_MSG_TREE_HEIGHT, Array(L1_TO_L2_MSG_TREE_HEIGHT)),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ describe('Accrued Substate', () => {
});
});

describe('L1ToL1MessageExists', () => {
describe('L1ToL2MessageExists', () => {
it('Should (de)serialize correctly', () => {
const buf = Buffer.from([
L1ToL2MessageExists.opcode, // opcode
Expand Down Expand Up @@ -397,7 +397,7 @@ describe('Accrued Substate', () => {
expect(inst.serialize()).toEqual(buf);
});

it('Should append l1 to l2 messages correctly', async () => {
it('Should append l2 to l1 messages correctly', async () => {
const recipientOffset = 0;
const recipient = new Fr(42);
const contentOffset = 1;
Expand Down
4 changes: 0 additions & 4 deletions yarn-project/simulator/src/avm/opcodes/accrued_substate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ export class L1ToL2MessageExists extends Instruction {
}

async execute(context: AvmContext): Promise<void> {
if (context.environment.isStaticCall) {
throw new StaticCallStorageAlterError();
}

const msgHash = context.machineState.memory.get(this.msgHashOffset).toFr();
const msgLeafIndex = context.machineState.memory.get(this.msgLeafIndexOffset).toFr();
const exists = await context.persistableState.checkL1ToL2MessageExists(msgHash, msgLeafIndex);
Expand Down

0 comments on commit fa53136

Please sign in to comment.