Skip to content

Conversation

@starwarfan
Copy link
Contributor

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

2. What is the scope of this PR (e.g. component or file name):

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains CI/CD configuration changes
  • Contains documentation changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

6. Release note

None

- Cross-function fallback (limited to single function scope)

## Success Criteria
- JIT-compiled EVM code can fallback to interpreter at any instruction boundary
Copy link
Contributor

Choose a reason for hiding this comment

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

design how to test this feature

Copy link
Contributor

Choose a reason for hiding this comment

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

more test cases: stack flush/restore, memory consistency, gas, fallback triggers, error conditions, OutOfGas and revert in fallbacked interpreter, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a unittest is added

const auto &RuntimeFunctions = getRuntimeFunctionTable();
// Create a constant instruction for the target PC
MType *I64Type = &Ctx.I64Type;
MInstruction *PCConst = createIntConstInstruction(I64Type, targetPC);
Copy link
Contributor

Choose a reason for hiding this comment

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

only stack sized synced, are all stack elements in Instance now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

currently we only call this after handleEndBlock

intx::uint256 Value = 0;
for (size_t J = 0; J < ELEMENT_SIZE; ++J) {
Value = (Value << 8) + ElementData[J];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the "proper byte order"?
need a testcase for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add some simple test cases

Frame->Stack[I] = Value;
}

// Ensure memory state consistency between JIT and interpreter
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be easier to test if we add a test option or hints for testing purposes (such as a specific offset or after a certain opcode) to specify a location where JIT falls back to the interpreter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. now we use 0xee as a trigger to fallback for testing

endif()

if(ZEN_ENABLE_JIT_FALLBACK_TEST)
add_definitions(-DZEN_ENABLE_JIT_FALLBACK_TEST)
Copy link
Contributor

Choose a reason for hiding this comment

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

In the GitHub CI workflow, we should run tests for both scenarios: with ZEN_ENABLE_JIT_FALLBACK_TEST enabled and disabled.
After the tests pass, we can archive the openspec change.

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