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

use rust types for RecentChainData, ProofBlockHeader and WeightProof #17738

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 4 additions & 43 deletions chia/types/weight_proof.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,11 @@
from __future__ import annotations

from dataclasses import dataclass
from typing import List

import chia_rs

from chia.types.blockchain_format.reward_chain_block import RewardChainBlock
from chia.types.end_of_slot_bundle import EndOfSubSlotBundle
from chia.types.header_block import HeaderBlock
from chia.util.streamable import Streamable, streamable

SubEpochData = chia_rs.SubEpochData

# number of challenge blocks
# Average iters for challenge blocks
# |--A-R----R-------R--------R------R----R----------R-----R--R---| Honest difficulty 1000
# 0.16

# compute total reward chain blocks
# |----------------------------A---------------------------------| Attackers chain 1000
# 0.48
# total number of challenge blocks == total number of reward chain blocks


ProofBlockHeader = chia_rs.ProofBlockHeader
RecentChainData = chia_rs.RecentChainData
SubEpochChallengeSegment = chia_rs.SubEpochChallengeSegment
SubEpochData = chia_rs.SubEpochData
SubEpochSegments = chia_rs.SubEpochSegments
SubSlotData = chia_rs.SubSlotData


@streamable
@dataclass(frozen=True)
# this is used only for serialization to database
class RecentChainData(Streamable):
recent_chain_data: List[HeaderBlock]


@streamable
@dataclass(frozen=True)
class ProofBlockHeader(Streamable):
finished_sub_slots: List[EndOfSubSlotBundle]
reward_chain_block: RewardChainBlock


@streamable
@dataclass(frozen=True)
class WeightProof(Streamable):
sub_epochs: List[SubEpochData]
sub_epoch_segments: List[SubEpochChallengeSegment] # sampled sub epoch
recent_chain_data: List[HeaderBlock]
WeightProof = chia_rs.WeightProof
Loading