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

Fixes gas estimation for ccrs #209

Merged
merged 4 commits into from
Feb 27, 2024
Merged

Fixes gas estimation for ccrs #209

merged 4 commits into from
Feb 27, 2024

Conversation

ferranbt
Copy link
Collaborator

📝 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


  • I have seen and agree to CONTRIBUTING.md

@@ -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
Copy link
Collaborator Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

@ferranbt ferranbt changed the title This PR fixes gas estimation for ccrs Fixes gas estimation for ccrs Feb 26, 2024
@ferranbt ferranbt requested a review from lthibault February 26, 2024 16:25
Copy link
Contributor

@lthibault lthibault left a 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 Show resolved Hide resolved
internal/ethapi/api.go Show resolved Hide resolved
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

internal/ethapi/transaction_args.go Show resolved Hide resolved
suave/e2e/workflow_test.go Show resolved Hide resolved
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)
Copy link
Contributor

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?

Copy link
Collaborator Author

@ferranbt ferranbt Feb 26, 2024

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)
Copy link
Contributor

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.

Copy link
Contributor

@lthibault lthibault left a comment

Choose a reason for hiding this comment

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

LGTM. Send it!

@ferranbt ferranbt merged commit 2118ea6 into main Feb 27, 2024
4 checks passed
@ferranbt ferranbt deleted the fix-ccr-gas-estimation branch February 27, 2024 15:38
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.

3 participants