-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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!
// EncodeProof returns the proof for the current state | ||
EncodeProof() []byte |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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)
//Fake SecondMemoryProof | ||
proofData = append(proofData, insnProof[:]...) | ||
return proofData |
There was a problem hiding this comment.
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.
First part of #12198
Modify
AssertEVMReverts
to ensure it passes complete proofdata when invoking the EVM.