Skip to content
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

fix(avm): CALL operand resolution #9018

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
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
Loading