chia-blockchain/chia/protocols/timelord_protocol.py

94 lines
3.0 KiB
Python
Raw Permalink Normal View History

from __future__ import annotations
2019-11-18 07:49:39 +03:00
from dataclasses import dataclass
from typing import List, Optional, Tuple
2019-11-18 07:49:39 +03:00
from chia.types.blockchain_format.foliage import Foliage
from chia.types.blockchain_format.reward_chain_block import RewardChainBlock, RewardChainBlockUnfinished
from chia.types.blockchain_format.sized_bytes import bytes32
from chia.types.blockchain_format.sub_epoch_summary import SubEpochSummary
from chia.types.blockchain_format.vdf import VDFInfo, VDFProof
from chia.types.end_of_slot_bundle import EndOfSubSlotBundle
from chia.util.ints import uint8, uint32, uint64, uint128
from chia.util.streamable import Streamable, streamable
"""
Protocol between timelord and full node.
Note: When changing this file, also change protocol_message_types.py, and the protocol version in shared_protocol.py
"""
2020-10-30 12:38:56 +03:00
@streamable
@dataclass(frozen=True)
class NewPeakTimelord(Streamable):
reward_chain_block: RewardChainBlock
2020-11-12 10:18:33 +03:00
difficulty: uint64
2020-11-11 13:18:14 +03:00
deficit: uint8
2020-11-25 12:43:47 +03:00
sub_slot_iters: uint64 # SSi in the slot where NewPeak has been infused
2020-12-04 12:07:01 +03:00
sub_epoch_summary: Optional[
SubEpochSummary
] # If NewPeak is the last slot in epoch, the next slot should include this
previous_reward_challenges: List[Tuple[bytes32, uint128]]
2020-12-05 17:28:41 +03:00
last_challenge_sb_or_eos_total_iters: uint128
2021-03-03 21:27:00 +03:00
passes_ses_height_but_not_yet_included: bool
2019-11-18 07:50:31 +03:00
@streamable
@dataclass(frozen=True)
class NewUnfinishedBlockTimelord(Streamable):
reward_chain_block: RewardChainBlockUnfinished # Reward chain trunk data
2020-12-04 12:07:01 +03:00
difficulty: uint64
sub_slot_iters: uint64 # SSi in the slot where block is infused
foliage: Foliage # Reward chain foliage data
2020-12-04 12:07:01 +03:00
sub_epoch_summary: Optional[SubEpochSummary] # If this is the last slot in epoch, the next slot should include this
2020-12-05 17:28:41 +03:00
# This is the last thing infused in the reward chain before this signage point.
# The challenge that the SP reward chain VDF is based off of, or in the case of sp index 0, the previous infusion
rc_prev: bytes32
2020-11-11 13:01:44 +03:00
@streamable
@dataclass(frozen=True)
class NewInfusionPointVDF(Streamable):
2020-10-30 12:38:56 +03:00
unfinished_reward_hash: bytes32
challenge_chain_ip_vdf: VDFInfo
challenge_chain_ip_proof: VDFProof
reward_chain_ip_vdf: VDFInfo
reward_chain_ip_proof: VDFProof
2020-11-11 13:01:44 +03:00
infused_challenge_chain_ip_vdf: Optional[VDFInfo]
infused_challenge_chain_ip_proof: Optional[VDFProof]
@streamable
@dataclass(frozen=True)
class NewSignagePointVDF(Streamable):
index_from_challenge: uint8
2020-11-02 18:02:45 +03:00
challenge_chain_sp_vdf: VDFInfo
2020-11-03 10:46:55 +03:00
challenge_chain_sp_proof: VDFProof
2020-11-02 18:02:45 +03:00
reward_chain_sp_vdf: VDFInfo
2020-11-03 10:46:55 +03:00
reward_chain_sp_proof: VDFProof
@streamable
@dataclass(frozen=True)
class NewEndOfSubSlotVDF(Streamable):
2020-11-11 13:01:44 +03:00
end_of_sub_slot_bundle: EndOfSubSlotBundle
@streamable
@dataclass(frozen=True)
class RequestCompactProofOfTime(Streamable):
new_proof_of_time: VDFInfo
header_hash: bytes32
height: uint32
field_vdf: uint8
@streamable
@dataclass(frozen=True)
class RespondCompactProofOfTime(Streamable):
vdf_info: VDFInfo
vdf_proof: VDFProof
header_hash: bytes32
height: uint32
field_vdf: uint8