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

test(vm): Test EVM emulator in multivm crate #3232

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

slowli
Copy link
Contributor

@slowli slowli commented Nov 6, 2024

What ❔

Adds basic low-level tests for the real EVM emulator.

Why ❔

EVM emulator functionality should be covered by tests.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zkstack dev fmt and zkstack dev lint.

uint gasMultiplier = _isEvmTester ? 1 : 5;
uint currentGas = gasleft();
if (_isEvmTester) {
// FIXME: doesn't work for EraVM tester (~115k less gas is passed)
Copy link
Contributor

@0xVolosnikov 0xVolosnikov Nov 6, 2024

Choose a reason for hiding this comment

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

It should be the decommit cost

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've thought about it as well. Is this cost emulated by the EVM emulator? My confusion with this explanation is that it doesn't match how decommits are priced in EraVM; the amount of the subtracted gas doesn't depend on whether the called contact is "cold" or "hot" (i.e., was previously decommitted; IIUC, in the latter case, the decommit cost should be 0). Note that both calls with default gas passed must be switched off; the second one calls a hot contract.

Copy link
Contributor

@0xVolosnikov 0xVolosnikov Nov 7, 2024

Choose a reason for hiding this comment

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

Yes, this was implemented to somehow charge for decommits when we have EVM stipend (charge from the callee frame). So it was supposed to charge even if we are calling already "hot" contract, because EVM doesn't know about hot/cold accounts in EraVM context.

But if we remove EVM stipend, we can remove this as well, I guess. Decommit cost will be charged from the caller frame

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.

2 participants