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 dependency on swirlds-state-impl from swirlds-platform-core #16568

Open
Tracked by #15574
imalygin opened this issue Nov 12, 2024 · 2 comments · May be fixed by #17275
Open
Tracked by #15574

Remove dependency on swirlds-state-impl from swirlds-platform-core #16568

imalygin opened this issue Nov 12, 2024 · 2 comments · May be fixed by #17275
Assignees
Labels
Platform Tickets pertaining to the platform

Comments

@imalygin
Copy link
Member

imalygin commented Nov 12, 2024

This is a follow-up for #16322

PlatformMerkleStateRoot extends MerkleStateRoot but it shouldn't really be the case because it unnecessarily creates a dependency on the implementation of the com.swirlds.state.State interface.
What we do need is an implementation of com.swirlds.platform.system.SwirldState that contains an instance of the com.swirlds.state.State and instance of com.swirlds.platform.state.MerkleStateLifecycles. Then, it should have the implementation of SwirldState interface methods that looks as follows:

    void preHandle(final Event event) {
        lifecycles.onPreHandle(event, state);
    }

    void handleConsensusRound(final Round round, final PlatformStateModifier platformState) {
         throwIfImmutable();
         lifecycles.onHandleConsensusRound(round, this);
    }

    void sealConsensusRound(@NonNull final Round round) {
            requireNonNull(round);
            throwIfImmutable();
           lifecycles.onSealConsensusRound(round, state);
    }

and so on. Then this implementation should replace usages of PlatformMerkleStateRoot, and PlatformMerkleStateRoot, in its turn, should be removed.

This refactoring will allow to get rid of swirlds-state-impl dependency. The common wisdom is that whilst app can depend on the implementation details of the state (and therefore the module), the platform has absolutely to reason for this dependency.

@imalygin imalygin self-assigned this Nov 12, 2024
@imalygin imalygin added the Platform Tickets pertaining to the platform label Nov 12, 2024
@imalygin
Copy link
Member Author

Blocked by #16322

@imalygin
Copy link
Member Author

To complete PlatformMerkleStateRoot removal this task - #16436 - has to be completed first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Tickets pertaining to the platform
Projects
None yet
1 participant