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

remove check performed in the mempool #1708

Merged
merged 3 commits into from
Dec 19, 2023
Merged

Conversation

tudor-malene
Copy link
Collaborator

@tudor-malene tudor-malene commented Dec 19, 2023

Why this change is needed

  • remove gas check that is done by the mempool as well to return a consistent error message with ethereum tooling
  • fix major flakyness

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

Copy link

coderabbitai bot commented Dec 19, 2023

Walkthrough

The core change involves the removal of a gas check within the SubmitTx method of the enclaveImpl type in Go. This adjustment simplifies the transaction submission process by omitting the step that previously validated the gas for transactions, potentially impacting how transactions are processed and validated.

Changes

File Path Change Summary
go/enclave/enclave.go Removed gas check logic in SubmitTx method of enclaveImpl.
go/enclave/nodetype/sequencer.go Updated logic for producing batch #2 by modifying createGenesisBatch method in sequencer.go.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4ee0cca and 046efc2.
Files selected for processing (1)
  • go/enclave/enclave.go (1 hunks)

Comment on lines 503 to 504
if err = e.service.SubmitTransaction(decryptedTx); err != nil {
e.logger.Debug("Could not submit transaction", log.TxKey, decryptedTx.Hash(), log.ErrKey, err)
Copy link

Choose a reason for hiding this comment

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

The error handling for the SubmitTransaction call within the SubmitTx method logs the error but also returns an encrypted error response. It is crucial to ensure that the error returned does not leak sensitive information and that it is properly encrypted using the viewing key handler.

Confirm that the error encryption process is secure and that the error messages are generic enough to not reveal details that could be exploited by an attacker.

@@ -166,7 +166,7 @@ func (s *sequencer) createGenesisBatch(block *common.L1Block) error {

// produce batch #2 which has the message bus and any other system contracts
cb, err := s.produceBatch(
batch.Header.SequencerOrderNo.Add(batch.Header.SequencerOrderNo, big.NewInt(1)),
big.NewInt(0).Add(batch.Header.SequencerOrderNo, big.NewInt(1)),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was the major source of all flakyness.
This call was mutating the sequencer number of the first batch.

@@ -499,10 +499,6 @@ func (e *enclaveImpl) SubmitTx(tx common.EncryptedTx) (*responses.RawTx, common.
if e.crossChainProcessors.Local.IsSyntheticTransaction(*decryptedTx) {
return responses.AsPlaintextError(responses.ToInternalError(fmt.Errorf("synthetic transaction coming from external rpc"))), nil
}
if err = e.checkGas(decryptedTx); err != 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.

this check is performed again in the geth mempool, and returns better errors

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 046efc2 and 3b43599.
Files selected for processing (2)
  • go/enclave/enclave.go (2 hunks)
  • go/enclave/nodetype/sequencer.go (1 hunks)
Additional comments: 1
go/enclave/nodetype/sequencer.go (1)
  • 166-172: The logic for incrementing SequencerOrderNo in the createGenesisBatch method has been changed to use big.NewInt(0).Add(...) instead of batch.Header.SequencerOrderNo.Add(...). This change should be functionally equivalent but ensure that it does not introduce any unintended side effects.

Comment on lines 499 to 504
if e.crossChainProcessors.Local.IsSyntheticTransaction(*decryptedTx) {
return responses.AsPlaintextError(responses.ToInternalError(fmt.Errorf("synthetic transaction coming from external rpc"))), nil
}
if err = e.checkGas(decryptedTx); err != nil {
e.logger.Info("gas check failed", log.ErrKey, err.Error())
return responses.AsEncryptedError(err, vkHandler), nil
}

if err = e.service.SubmitTransaction(decryptedTx); err != nil {
e.logger.Debug("Could not submit transaction", log.TxKey, decryptedTx.Hash(), log.ErrKey, err)
Copy link

Choose a reason for hiding this comment

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

The removal of the gas check logic in the SubmitTx method aligns with the PR's objective to standardize error messages with Ethereum tooling. Ensure that the removal does not introduce any security or functional issues, especially considering that gas checks are a critical part of transaction validation in Ethereum-like networks.

Copy link
Contributor

@StefanIliev545 StefanIliev545 left a comment

Choose a reason for hiding this comment

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

LGTM

@tudor-malene tudor-malene merged commit 98e0913 into main Dec 19, 2023
2 checks passed
@tudor-malene tudor-malene deleted the tudor/mempool_fix_2 branch December 19, 2023 13:50
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