From 4b2f9f0c7e7e575dd266c238a017b9856b254a1f Mon Sep 17 00:00:00 2001 From: Earle Lowe <30607889+emlowe@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:02:55 -0700 Subject: [PATCH] Revert "use rust types for RecentChainData, ProofBlockHeader and WeightProof" #17738 (#18231) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert "use rust types for RecentChainData, ProofBlockHeader and WeightProof …" This reverts commit 3f0d5c070bfcc76abb6deb2dd118ebfce42ac324. --- chia/types/weight_proof.py | 47 ++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/chia/types/weight_proof.py b/chia/types/weight_proof.py index 2670b17f5e9d..6c2b17e7aee0 100644 --- a/chia/types/weight_proof.py +++ b/chia/types/weight_proof.py @@ -1,11 +1,50 @@ from __future__ import annotations +from dataclasses import dataclass +from typing import List + import chia_rs -ProofBlockHeader = chia_rs.ProofBlockHeader -RecentChainData = chia_rs.RecentChainData -SubEpochChallengeSegment = chia_rs.SubEpochChallengeSegment +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 + + +SubEpochChallengeSegment = chia_rs.SubEpochChallengeSegment SubEpochSegments = chia_rs.SubEpochSegments SubSlotData = chia_rs.SubSlotData -WeightProof = chia_rs.WeightProof + + +@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]