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

Mx 15315 refactor sov runtype comp #6065

Conversation

axenteoctavian
Copy link

@axenteoctavian axenteoctavian commented Mar 25, 2024

Reasoning behind the pull request

  • Refactor RunType components for Chain Simulator
  • refactored DataCodec and TopicsChecker

Proposed changes

  • Refactor RunType components

Testing procedure

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@axenteoctavian axenteoctavian marked this pull request as draft March 25, 2024 16:53
@axenteoctavian axenteoctavian marked this pull request as ready for review March 26, 2024 12:33
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 78.17%. Comparing base (19ae2f2) to head (b0dea1e).
Report is 1 commits behind head on feat/refactor-runtype-components.

❗ Current head b0dea1e differs from pull request most recent head 9569ac8. Consider uploading reports for the commit 9569ac8 to get more accurate results

Files Patch % Lines
factory/runType/runTypeComponentsHandler.go 50.00% 6 Missing and 6 partials ⚠️
Additional details and impacted files
@@                         Coverage Diff                          @@
##           feat/refactor-runtype-components    #6065      +/-   ##
====================================================================
+ Coverage                             78.11%   78.17%   +0.05%     
====================================================================
  Files                                   874      874              
  Lines                                103470   103512      +42     
====================================================================
+ Hits                                  80828    80917      +89     
+ Misses                                17153    17106      -47     
  Partials                               5489     5489              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mariusmihaic mariusmihaic self-requested a review April 9, 2024 08:49
cmd/sovereignnode/sovereignNodeRunner.go Outdated Show resolved Hide resolved
factory/processing/processComponents.go Show resolved Hide resolved
factory/runType/runTypeComponents.go Outdated Show resolved Hide resolved
factory/runType/runTypeComponentsHandler.go Show resolved Hide resolved
cmd/sovereignnode/sovereignNodeRunner.go Outdated Show resolved Hide resolved
require.NotNil(t, managedRunTypeComponents.AdditionalStorageServiceCreator())
require.NotNil(t, managedRunTypeComponents.SCProcessorCreator())
require.NotNil(t, managedRunTypeComponents.SCResultsPreProcessorCreator())
require.NotEqual(t, consensus.ConsensusModelInvalid, managedRunTypeComponents.ConsensusModel())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we check against the expected value (v1/v2)?

Copy link
Author

Choose a reason for hiding this comment

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

ConsensusModelInvalid is default

Copy link
Contributor

Choose a reason for hiding this comment

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

There you check that the consensus model IS NOT invalid.
Therefore it should be v1/v2. Please check against the values accordingly

factory/runType/sovereignRunTypeComponents.go Outdated Show resolved Hide resolved
process/block/baseProcess_test.go Outdated Show resolved Hide resolved
@raduchis raduchis self-requested a review April 10, 2024 13:04
factory/processing/processComponents.go Show resolved Hide resolved
@@ -131,6 +133,24 @@ func (mrc *managedRunTypeComponents) CheckSubcomponents() error {
if check.IfNil(mrc.scResultPreProcessorCreator) {
return errors.ErrNilSCResultsPreProcessorCreator
}
if mrc.consensusModel == consensus.ConsensusModelInvalid {
return errors.ErrInvalidConsensusModel
Copy link
Contributor

Choose a reason for hiding this comment

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

please add unit tests for the newly added checks.

Copy link
Author

@axenteoctavian axenteoctavian Apr 16, 2024

Choose a reason for hiding this comment

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

as discussed, I added a TODO

@@ -362,6 +382,30 @@ func (mrc *managedRunTypeComponents) AccountsCreator() state.AccountFactory {
return mrc.runTypeComponents.accountsCreator
}

// DataCodecHandler returns the data codec factory
func (mrc *managedRunTypeComponents) DataCodecHandler() sovereign.DataDecoderHandler {
Copy link
Contributor

Choose a reason for hiding this comment

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

the name of the method and the return are different.
Could DataCodecHandler() be renamed to DataDecoderHandler()?

Copy link
Author

Choose a reason for hiding this comment

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

renamed everywhere to DataCodec and DataCodecHandler because it does both decoding and encoding and the name was misleading

@@ -362,6 +382,30 @@ func (mrc *managedRunTypeComponents) AccountsCreator() state.AccountFactory {
return mrc.runTypeComponents.accountsCreator
}

// DataCodecHandler returns the data codec factory
func (mrc *managedRunTypeComponents) DataCodecHandler() sovereign.DataDecoderHandler {
mrc.mutStateComponents.RLock()
Copy link
Contributor

Choose a reason for hiding this comment

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

the mutex has is called with StateComponents. I think it was my bad naming. Please rename it to mutRunTypeComponents.

cmd/sovereignnode/sovereignNodeRunner.go Outdated Show resolved Hide resolved
cmd/sovereignnode/sovereignNodeRunner.go Outdated Show resolved Hide resolved
cmd/sovereignnode/sovereignNodeRunner.go Outdated Show resolved Hide resolved
factory/processing/processComponents.go Show resolved Hide resolved
require.NotNil(t, managedRunTypeComponents.AdditionalStorageServiceCreator())
require.NotNil(t, managedRunTypeComponents.SCProcessorCreator())
require.NotNil(t, managedRunTypeComponents.SCResultsPreProcessorCreator())
require.NotEqual(t, consensus.ConsensusModelInvalid, managedRunTypeComponents.ConsensusModel())
Copy link
Contributor

Choose a reason for hiding this comment

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

There you check that the consensus model IS NOT invalid.
Therefore it should be v1/v2. Please check against the values accordingly

process/block/baseProcess_test.go Outdated Show resolved Hide resolved
@@ -85,11 +85,11 @@ func TestManagedRunTypeComponents_Create(t *testing.T) {
require.NotNil(t, managedRunTypeComponents.AdditionalStorageServiceCreator())
require.NotNil(t, managedRunTypeComponents.SCProcessorCreator())
require.NotNil(t, managedRunTypeComponents.SCResultsPreProcessorCreator())
require.NotEqual(t, consensus.ConsensusModelInvalid, managedRunTypeComponents.ConsensusModel())
require.Equal(t, consensus.ConsensusModelV1, managedRunTypeComponents.ConsensusModel())
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessarily in this PR, but we should have a similar unit test for sovereign run type comps

@axenteoctavian axenteoctavian merged commit 462bf36 into feat/refactor-runtype-components Apr 16, 2024
4 checks passed
@axenteoctavian axenteoctavian deleted the MX-15315-refactor-sov-runtype-comp branch April 16, 2024 13:34
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