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

Add MirrorNodeState init with subcomponents #9793

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bilyana-gospodinova
Copy link
Contributor

Description:
This PR adds the MirrorNodeState initialization and subcomponents invocation. Some additional changes were made in order for the init method to finish successfully.
It will stay in draft until the PR with the flag introduction is merged.

Fixes #9791

Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
@bilyana-gospodinova bilyana-gospodinova added enhancement Type: New feature web3 Area: Web3 API labels Nov 21, 2024
@bilyana-gospodinova bilyana-gospodinova self-assigned this Nov 21, 2024
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 95.12195% with 4 lines in your changes missing coverage. Please review.

Project coverage is 92.32%. Comparing base (0253168) to head (5dd1280).

Files with missing lines Patch % Lines
.../com/hedera/mirror/web3/state/MirrorNodeState.java 96.07% 2 Missing ⚠️
...hedera/mirror/web3/common/ContractCallContext.java 0.00% 0 Missing and 1 partial ⚠️
...era/mirror/web3/state/core/MapWritableKVState.java 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9793      +/-   ##
============================================
+ Coverage     88.72%   92.32%   +3.59%     
- Complexity     1166     7693    +6527     
============================================
  Files           378      933     +555     
  Lines         12135    32252   +20117     
  Branches       1715     4094    +2379     
============================================
+ Hits          10767    29777   +19010     
- Misses         1224     1511     +287     
- Partials        144      964     +820     

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


🚨 Try these New Features:

@@ -79,6 +79,10 @@ public static ContractCallContext get() {
return SCOPED_VALUE.get();
}

public static Optional<Long> getTimestamp() {
return SCOPED_VALUE.isBound() ? SCOPED_VALUE.get().timestamp : Optional.empty();
Copy link
Contributor

Choose a reason for hiding this comment

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

In this PR, it seems it might be beneficial to return Optional.of current/instant time. Do we have checks that are connected tightly to have Optional.empty() as return value that won't work with having the instant timestamp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a lot of tests we mock that the returned timestamp is Optional.empty(), so this will break a lot of tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, then for now we can leave it like this.


private Map<Long, Function<Configuration, Bytes>> genesisContentProviders(
final NetworkInfo networkInfo, final com.swirlds.config.api.Configuration config) {
final var genesisSchema = new V0490FileSchema();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we plan to use dynamically the most recent schema? Having a hardcoded schema will mean we will have to support it and change it from time to time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the example in TransactionExecutorsTest. I haven't investigated yet if we need to pass here the latest schema. This can be done in a separate PR after we clear up most of the issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, that we can check the schema population and adapt it if needed, in a future PR.

filesConfig.exchangeRates(), genesisSchema::genesisExchangeRates,
filesConfig.networkProperties(), genesisSchema::genesisNetworkProperties,
filesConfig.hapiPermissions(), genesisSchema::genesisHapiPermissions,
filesConfig.throttleDefinitions(), genesisSchema::genesisThrottleDefinitions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would execution fail if we leave only filesConfig.feeSchedules() and filesConfig.exchangeRates() to be set?

Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Signed-off-by: Bilyana Gospodinova <bilyana.gospodinova14@gmail.com>
Copy link

sonarcloud bot commented Nov 21, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type: New feature web3 Area: Web3 API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance MirrorNodeState to get initialized on startup
3 participants