LimeChain / Fruzhin

Java implementation of the Polkadot Host
Apache License 2.0
32 stars 1 forks source link

refactor(block execution)!: showcase a MWE with explicit `Context` object #413

Closed David-Petrov closed 5 months ago

David-Petrov commented 5 months ago

Description

Decouple the Spring app from runtime invocations. This PR showcases a variant of this decoupling using an explicit Context object to pass to the runtime builder, in which object all necessary dependencies for the host API endpoints are contained, thus granting the caller the ability to define all interactions from the runtime to the outside world through the behaviour of these dependencies.

The main goal of this MWE is to execute the first block in Kusama without ever starting the Spring app (i.e. in isolation). In more practical terms: to rewrite the previously existing BlockExecutorTest, and the new variant can be found in BlockExecutorIsolatedTest. The diff between the two tests is the starting point for grasping all the changes.

The bulk of refactoring is isolated in the package com.limechain.runtime.research.hybrid, where I've copied a lot of existing classes in an isolated environment and made changes on the copies, since applying changes in the already existing production classes quickly proved to be non-viable for the purpose of achieving a MWE.

Breakdown on the main changes within com.limechain.runtime.research.hybrid:

Other notable changes (outside the hybrid package) which were necessary to achieve this decoupling:

sonarcloud[bot] commented 5 months ago

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarCloud

David-Petrov commented 5 months ago

Closing this as already implemented in #456.