Skip to content

Commit

Permalink
fix(avm): CALL operand resolution (#9018)
Browse files Browse the repository at this point in the history
Cherrypicking some fixes by @sirasistant.
  • Loading branch information
fcarreiro authored Oct 4, 2024
1 parent 567e9a8 commit 7f2e29f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions yarn-project/simulator/src/avm/opcodes/external_calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,22 @@ abstract class ExternalCall extends Instruction {
this.argsSizeOffset,
this.retOffset,
this.successOffset,
this.functionSelectorOffset,
];
const addressing = Addressing.fromWire(this.indirect, operands.length);
const [gasOffset, addrOffset, argsOffset, argsSizeOffset, retOffset, successOffset] = addressing.resolve(
operands,
memory,
);
const [gasOffset, addrOffset, argsOffset, argsSizeOffset, retOffset, successOffset, functionSelectorOffset] =
addressing.resolve(operands, memory);
memory.checkTags(TypeTag.FIELD, gasOffset, gasOffset + 1);
memory.checkTag(TypeTag.FIELD, addrOffset);
memory.checkTag(TypeTag.UINT32, argsSizeOffset);
memory.checkTag(TypeTag.FIELD, this.functionSelectorOffset);
memory.checkTag(TypeTag.FIELD, functionSelectorOffset);

const calldataSize = memory.get(argsSizeOffset).toNumber();
memory.checkTagsRange(TypeTag.FIELD, argsOffset, calldataSize);

const callAddress = memory.getAs<Field>(addrOffset);
const calldata = memory.getSlice(argsOffset, calldataSize).map(f => f.toFr());
const functionSelector = memory.getAs<Field>(this.functionSelectorOffset).toFr();
const functionSelector = memory.getAs<Field>(functionSelectorOffset).toFr();
// If we are already in a static call, we propagate the environment.
const callType = context.environment.isStaticCall ? 'STATICCALL' : this.type;

Expand Down

0 comments on commit 7f2e29f

Please sign in to comment.