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

Code optimization recommendations #3192

Open
grarco opened this issue May 7, 2024 · 0 comments
Open

Code optimization recommendations #3192

grarco opened this issue May 7, 2024 · 0 comments

Comments

@grarco
Copy link
Contributor

grarco commented May 7, 2024

Reported by Informal Systems.

Description

Upon reviewing the codebase, several optimizations were identified that could enhance the efficiency and readability of the code.

Problem Scenarios

  1. The validate_tx function is redundantly called twice in the check_proposal_tx function, during
    process proposal, leading to unnecessary overhead. 1st: /process_proposal.rs#L249-L256
    2nd: /process_proposal.rs#L265-L270
  2. The previously defined inner_tx_hash should be used instead of &tx.raw_header_hash() .
    mempool_validation()
  3. Move parameter obtaining from storage outside loop iterations to minimize unnecessary storage calls. In this way, the number of calls to storage would be reduced. /governance.rs#L79
  4. Since the validate_wrapper_bytes function is specific to Wrapper transactions, the transaction type check should be performed at the beginning of the function. If the transaction is not a WrapperTx, an error
    should be immediately returned. /prepare_proposal.rs#L286

Recommendation

To improve performance, it is recommended to implement the suggestions outlined in the Problem Scenarios section.

@grarco grarco added this to the Later / optional milestone May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant