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

refactor: remove PublicExecutor #10028

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dbanks12
Copy link
Contributor

@dbanks12 dbanks12 commented Nov 19, 2024

  • Pulls what the PublicExecutor did into an internal function of the PublicTxSimulator
  • Modifies the TXE to craft a carrier TX for public calls and just call publicTxSimulator.simulate(tx) so that we only need to maintain that interface for external use of the simulator
  • Adds gasLeft to AvmContractCallResult, removes gasLeft as an extra param to functions that accept call result.
  • Introduces AvmFinalizedCallResult which is just like AvmContractCallResult but is friendlier for use externally to the AVM. Uses standard Gas type, and uses SimulationError type for revertReason.
    • Note that we might want to only have one gas type eventually, but even just having this dedicated result type with revertReason of type SimulationError led to some cleanup
  • Removes bytecode size metering that was done in PublicExector (it wasn't useful anymore)
  • Removes unused/stale SimulationProvider paramters

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@dbanks12 dbanks12 removed the request for review from fcarreiro November 19, 2024 03:21
@dbanks12 dbanks12 changed the title refactor: remove PublicExecutor [WIP] refactor: remove PublicExecutor Nov 19, 2024
Comment on lines +198 to 215
// Mock the internal private function. Borrowed from https://stackoverflow.com/a/71033167
const simulateInternal: jest.SpiedFunction<
(
stateManager: AvmPersistableStateManager,
executionResult: any,
allocatedGas: Gas,
transactionFee: any,
fnName: any,
) => Promise<AvmFinalizedCallResult>
> = jest.spyOn(
this.publicTxSimulator as unknown as {
simulateEnqueuedCallInternal: PublicTxSimulator['simulateEnqueuedCallInternal'];
},
'simulateEnqueuedCallInternal',
);
if (executorMock) {
this.publicExecutor.simulate.mockImplementation(executorMock);
simulateInternal.mockImplementation(executorMock);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is private, so I found this way to mock it. Should I just make the function public because we need to mock this in the prover client (and also in PublicTxSimulator tests)?

@dbanks12 dbanks12 changed the title [WIP] refactor: remove PublicExecutor refactor: remove PublicExecutor Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant