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
2 changes: 1 addition & 1 deletion avm-transpiler/src/transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub fn brillig_to_avm(brillig: &Brillig) -> Vec<u8> {
BrilligOpcode::Stop { return_data_offset, return_data_size } => {
avm_instrs.push(AvmInstruction {
opcode: AvmOpcode::RETURN,
indirect: Some(ZEROTH_OPERAND_INDIRECT),
indirect: Some(ALL_DIRECT),
operands: vec![
AvmOperand::U32 { value: *return_data_offset as u32 },
AvmOperand::U32 { value: *return_data_size as u32 },
Expand Down
12 changes: 7 additions & 5 deletions yarn-project/simulator/src/avm/opcodes/external_calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,16 @@ export class Return extends Instruction {
}

async execute(context: AvmContext): Promise<void> {
const output = context.machineState.memory.getSlice(this.returnOffset, this.copySize).map(word => word.toFr());
const [returnOffset] = Addressing.fromWire(this.indirect).resolve([this.returnOffset], context.machineState.memory);

const output = context.machineState.memory.getSlice(returnOffset, this.copySize).map(word => word.toFr());

context.machineState.return(output);
}
}

export class Revert extends Instruction {
static type: string = 'RETURN';
static type: string = 'REVERT';
static readonly opcode: Opcode = Opcode.REVERT;
// Informs (de)serialization. See Instruction.deserialize.
static readonly wireFormat: OperandType[] = [
Expand All @@ -187,9 +189,9 @@ export class Revert extends Instruction {
}

async execute(context: AvmContext): Promise<void> {
const output = context.machineState.memory
.getSlice(this.returnOffset, this.returnOffset + this.retSize)
.map(word => word.toFr());
const [returnOffset] = Addressing.fromWire(this.indirect).resolve([this.returnOffset], context.machineState.memory);

const output = context.machineState.memory.getSlice(returnOffset, this.retSize).map(word => word.toFr());

context.machineState.revert(output);
}
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/simulator/src/avm/opcodes/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,13 @@ export class CalldataCopy extends Instruction {
}

async execute(context: AvmContext): Promise<void> {
const [dstOffset] = Addressing.fromWire(this.indirect).resolve([this.dstOffset], context.machineState.memory);

const transformedData = context.environment.calldata
.slice(this.cdOffset, this.cdOffset + this.copySize)
.map(f => new Field(f));

context.machineState.memory.setSlice(this.dstOffset, transformedData);
context.machineState.memory.setSlice(dstOffset, transformedData);

context.machineState.incrementPc();
}
Expand Down