iotex-core icon indicating copy to clipboard operation
iotex-core copied to clipboard

[action] pass Envelope to protocol.Handle() and Validate()

Open dustinxie opened this issue 1 year ago • 3 comments

Description

  1. All our actions include a data field AbstractAction, while the envelope struct also contains AbstractAction.
  2. the only reason is b/c transfer and execution has a TotalSize() method that needs to access fields in AbstractAction
  3. added an interface Envelope.Size() to reflect the total size for transfer and execution
  4. pass Envelope to protocol's Handle() and Validate() method

benefits:

  1. simplify code and data structure
  2. better readability, less clumsy code
  3. for example, SignedTransfer now has 7 inputs, after this is done, it will reduce to 3 inputs

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

dustinxie avatar Jun 11 '24 01:06 dustinxie

How can TotalSize() be removed if doing a full sync after the fork?

Liuhaai avatar Jun 24 '24 23:06 Liuhaai

Quality Gate Failed Quality Gate failed

Failed conditions
30.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Aug 29 '24 23:08 sonarqubecloud[bot]