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

MTCannon: Fix AssertEVMReverts to correctly construct data #12200

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

joohhnnn
Copy link
Contributor

First part of #12198
Modify AssertEVMReverts to ensure it passes complete proofdata when invoking the EVM.

@joohhnnn joohhnnn requested review from a team as code owners September 29, 2024 22:07
Copy link
Contributor

@mbaxter mbaxter left a comment

Choose a reason for hiding this comment

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

Thanks for raising this issue - great find!

Comment on lines +59 to +60
// EncodeProof returns the proof for the current state
EncodeProof() []byte
Copy link
Contributor

Choose a reason for hiding this comment

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

I probably wouldn't modify the main interface for this - in particular because the tests here need an "initial"/incomplete proof without the memory proofs that are generated by running FPVM.step().

I'd suggest adding a helper function in the test utils here.

@@ -182,11 +182,11 @@ func ValidateEVM(t *testing.T, stepWitness *mipsevm.StepWitness, step uint64, go

// AssertEVMReverts runs a single evm step from an FPVM prestate and asserts that the VM panics
func AssertEVMReverts(t *testing.T, state mipsevm.FPVMState, contracts *ContractMetadata, tracer *tracing.Hooks) {
insnProof := state.GetMemory().MerkleProof(state.GetPC())
Copy link
Contributor

@mbaxter mbaxter Sep 30, 2024

Choose a reason for hiding this comment

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

I'd suggest accepting an expected revert message here. Then you can check it with:

retVal, _, err := env.Call(vm.AccountRef(sender), contracts.Addresses.MIPS, input, startingGas, common.U2560)
require.Contains(t, string(retVal), expectedRevertMsg)

Comment on lines +192 to +194
//Fake SecondMemoryProof
proofData = append(proofData, insnProof[:]...)
return proofData
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't generate fake data in production code - if necessary, this should be a test utility.

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