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

Mining Rule Engine Scaffolding and Sync Rate Rule implementation #654

Merged
merged 7 commits into from
Mar 24, 2025

Conversation

coderofstuff
Copy link
Collaborator

@coderofstuff coderofstuff commented Mar 19, 2025

Splitting the PR at #634 into multiple parts, this is part 1/3 with

  • Mining Rule Engine scaffolding
  • Sync Rate Rule implementation

Mining Rule

  • A new construct that tracks some data or metrics and influences mining in some form if conditions are met
  • It has these parts:
    • Rule: the mining-related strategy this rule will apply when triggered
    • Metric: the data that this rule cares about and attempts to influence
    • Trigger: the condition(s) upon which this rule will begin to apply
    • Recovery: the condition(s) upon which this rule will be lifted

Sync Rate Rule

Goal:
Allow mining even when the sink timestamp is outdated if the sync rate falls below a threshold

Rule:

Allow mining even if the sink timestamp is outdated. Accept blocks in Submit Block RPC.

Metric:

Field Tracking
body_count Already tracked in processing counters
header_count Already tracked in processing counters
received_blocks Not tracked, but calculated as max(delta.body_count, delta.header_count)
expected_blocks Not tracked, but calculated based on interval_in_millis / target_time_per_block

Definitions:

  • Sync Rate = received_blocks / expected_blocks
  • sync rate threshold = 0.9

Trigger:

  • finality is "recent" AND
  • sync rate < THRESHOLD

Recovery:

  • sync rate >= THRESHOLD

someone235
someone235 previously approved these changes Mar 23, 2025
- monitor sync state and update anything that cares about is_sycned to
  use the updated rules
- sync rate rule: allow mining if sync rate is below threshold and
  finality point is recent

Move most is_nearly_synced logic to mining_rule_engine

- instantiate Hub in daemon
- Reverse the dependency of flow context and MRE
- remove the async_is_nearly_synced consensus api
- add get_sink_daa_score_timestamp consensus API

Move is_nearly_synced logic from params to rule engine
- Make it not depend on sync rate rule
someone235
someone235 previously approved these changes Mar 23, 2025
@michaelsutton
Copy link
Contributor

LGTM

@michaelsutton michaelsutton merged commit b9bbd71 into kaspanet:master Mar 24, 2025
6 checks passed
@coderofstuff coderofstuff deleted the sync-rate-rule branch March 24, 2025 16:07
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