2022-09-30 11:40:22 +03:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2019-11-18 07:49:39 +03:00
|
|
|
from dataclasses import dataclass
|
2021-03-10 05:27:27 +03:00
|
|
|
from typing import List, Optional, Tuple
|
2019-11-18 07:49:39 +03:00
|
|
|
|
2021-04-04 06:55:26 +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
|
2019-08-05 11:10:40 +03:00
|
|
|
|
|
|
|
"""
|
|
|
|
Protocol between timelord and full node.
|
2021-02-09 10:14:37 +03:00
|
|
|
Note: When changing this file, also change protocol_message_types.py, and the protocol version in shared_protocol.py
|
2019-08-05 11:10:40 +03:00
|
|
|
"""
|
|
|
|
|
2020-10-30 12:38:56 +03:00
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class NewPeakTimelord(Streamable):
|
2021-02-12 23:24:33 +03:00
|
|
|
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
|
2020-12-05 12:50:12 +03:00
|
|
|
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
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-04-05 09:10:19 +03:00
|
|
|
class NewUnfinishedBlockTimelord(Streamable):
|
2021-02-12 23:24:33 +03:00
|
|
|
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
|
2021-02-12 23:24:33 +03:00
|
|
|
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
|
2020-12-05 12:50:12 +03:00
|
|
|
rc_prev: bytes32
|
2020-11-11 13:01:44 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
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]
|
2019-08-05 11:10:40 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class NewSignagePointVDF(Streamable):
|
2020-11-11 16:26:50 +03:00
|
|
|
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
|
2019-08-05 11:10:40 +03:00
|
|
|
|
|
|
|
|
2021-02-09 10:14:37 +03:00
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-02-09 10:14:37 +03:00
|
|
|
class NewEndOfSubSlotVDF(Streamable):
|
2020-11-11 13:01:44 +03:00
|
|
|
end_of_sub_slot_bundle: EndOfSubSlotBundle
|
2021-03-04 00:13:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-04-30 20:22:11 +03:00
|
|
|
class RequestCompactProofOfTime(Streamable):
|
2021-03-04 00:13:08 +03:00
|
|
|
new_proof_of_time: VDFInfo
|
|
|
|
header_hash: bytes32
|
|
|
|
height: uint32
|
|
|
|
field_vdf: uint8
|
|
|
|
|
|
|
|
|
|
|
|
@streamable
|
2022-04-09 04:29:32 +03:00
|
|
|
@dataclass(frozen=True)
|
2021-04-30 20:22:11 +03:00
|
|
|
class RespondCompactProofOfTime(Streamable):
|
2021-03-04 00:13:08 +03:00
|
|
|
vdf_info: VDFInfo
|
|
|
|
vdf_proof: VDFProof
|
|
|
|
header_hash: bytes32
|
|
|
|
height: uint32
|
|
|
|
field_vdf: uint8
|