-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fixes gas estimation for ccrs #209
Conversation
internal/ethapi/api.go
Outdated
@@ -2017,7 +2017,7 @@ func runMEVM(ctx context.Context, b Backend, state *state.StateDB, header *types | |||
} | |||
|
|||
if result.Failed() { | |||
return nil, nil, nil, fmt.Errorf("%w: %s", result.Err, hexutil.Encode(result.Revert())) | |||
return nil, result, storeFinalize, nil |
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.
result.Failed()
indicates an error during the execution but it should not be treated as a fatal error for the call. Functions that use runMEVM
need to differentiate between fatal errors and execution errors.
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.
Ditto.
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.
See inline for comments. As a general note, the PR comments you wrote are very enlightening, and I think it would be beneficial to include them as code comments!
internal/ethapi/api.go
Outdated
@@ -2017,7 +2017,7 @@ func runMEVM(ctx context.Context, b Backend, state *state.StateDB, header *types | |||
} | |||
|
|||
if result.Failed() { | |||
return nil, nil, nil, fmt.Errorf("%w: %s", result.Err, hexutil.Encode(result.Revert())) | |||
return nil, result, storeFinalize, nil |
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.
Ditto.
require.Equal(t, bids[0].Id, record.Id) | ||
// fetch the records and validate that it is empty since a call should not modify the store | ||
vals := fr.callPrecompile("fetchDataRecords", []interface{}{uint64(0), "default:v0:ethBundles"}) | ||
require.Len(t, vals[0], 0) |
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.
Are we certain that vals
always has a nonzero length?
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.
Yup, enforced in callPrecompile
. callPrecompile
fails if it cannot decode the output of fetchDataRecords
and fetchDataRecords
always returns one item, the data record.
valRaw := doCall("confidentialRetrieve", record.Id, "a") | ||
require.Equal(t, val, valRaw[0]) | ||
vals = fr.callPrecompile("fetchDataRecords", []interface{}{uint64(0), "default:v0:ethBundles"}) | ||
require.Len(t, vals[0], 0) |
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.
Same question about len(vals)
. Just want to make sure the test doesn't panic instead of failing cleanly.
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.
LGTM. Send it!
📝 Summary
This PR fixes gas estimation for Confidential Compute requests. There were a few small issues here and there. Notes on the code as comments.
📚 References