Skip to content

Commit

Permalink
add missing UnfinishedBlock and SubEpochSummary types
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Oct 18, 2023
1 parent 063857a commit 41a47d3
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 2 deletions.
4 changes: 4 additions & 0 deletions chia-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub mod proof_of_space;
pub mod reward_chain_block;
pub mod slots;
pub mod spend_bundle;
pub mod sub_epoch_summary;
pub mod unfinished_block;
pub mod vdf;
pub mod wallet_protocol;
pub mod weight_proof;
Expand All @@ -38,6 +40,8 @@ pub use crate::proof_of_space::*;
pub use crate::reward_chain_block::*;
pub use crate::slots::*;
pub use crate::spend_bundle::*;
pub use crate::sub_epoch_summary::*;
pub use crate::unfinished_block::*;
pub use crate::vdf::*;
pub use crate::wallet_protocol::*;
pub use crate::weight_proof::*;
11 changes: 11 additions & 0 deletions chia-protocol/src/sub_epoch_summary.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::streamable_struct;
use crate::Bytes32;
use chia_streamable_macro::Streamable;

streamable_struct!(SubEpochSummary {
prev_subepoch_summary_hash: Bytes32,
reward_chain_hash: Bytes32, // hash of reward chain at end of last segment
num_blocks_overflow: u8, // How many more blocks than 384*(N-1)
new_difficulty: Option<u64>, // Only once per epoch (diff adjustment)
new_sub_slot_iters: Option<u64>, // Only once per epoch (diff adjustment)
});
21 changes: 21 additions & 0 deletions chia-protocol/src/unfinished_block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use chia_streamable_macro::Streamable;

use crate::streamable_struct;
use crate::EndOfSubSlotBundle;
use crate::Program;
use crate::RewardChainBlockUnfinished;
use crate::VDFProof;
use crate::{Foliage, FoliageTransactionBlock, TransactionsInfo};

streamable_struct! (UnfinishedBlock {
// Full block, without the final VDFs
finished_sub_slots: Vec<EndOfSubSlotBundle>, // If first sb
reward_chain_block: RewardChainBlockUnfinished, // Reward chain trunk data
challenge_chain_sp_proof: Option<VDFProof>, // If not first sp in sub-slot
reward_chain_sp_proof: Option<VDFProof>, // If not first sp in sub-slot
foliage: Foliage, // Reward chain foliage data
foliage_transaction_block: Option<FoliageTransactionBlock>, // Reward chain foliage data (tx block)
transactions_info: Option<TransactionsInfo>, // Reward chain foliage data (tx block additional)
transactions_generator: Option<Program>, // Program that generates transactions
transactions_generator_ref_list: Vec<u32>, // List of block heights of previous generators referenced in this block
});
70 changes: 70 additions & 0 deletions wheel/chia_rs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,76 @@ class SpendBundle:
@staticmethod
def from_json_dict(o: Dict[str, Any]) -> SpendBundle: ...

class SubEpochSummary:
prev_subepoch_summary_hash: bytes32
reward_chain_hash: bytes32
num_blocks_overflow: int
new_difficulty: Optional[int]
new_sub_slot_iters: Optional[int]
def __init__(
self,
prev_subepoch_summary_hash: bytes,
reward_chain_hash: bytes,
num_blocks_overflow: int,
new_difficulty: Optional[int],
new_sub_slot_iters: Optional[int]
) -> None: ...
def __hash__(self) -> int: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __richcmp__(self) -> Any: ...
def __deepcopy__(self) -> SubEpochSummary: ...
def __copy__(self) -> SubEpochSummary: ...
@staticmethod
def from_bytes(bytes) -> SubEpochSummary: ...
@staticmethod
def parse_rust(ReadableBuffer) -> Tuple[SubEpochSummary, int]: ...
def to_bytes(self) -> bytes: ...
def __bytes__(self) -> bytes: ...
def get_hash(self) -> bytes32: ...
def to_json_dict(self) -> Dict[str, Any]: ...
@staticmethod
def from_json_dict(o: Dict[str, Any]) -> SubEpochSummary: ...

class UnfinishedBlock:
finished_sub_slots: List[EndOfSubSlotBundle]
reward_chain_block: RewardChainBlockUnfinished
challenge_chain_sp_proof: Optional[VDFProof]
reward_chain_sp_proof: Optional[VDFProof]
foliage: Foliage
foliage_transaction_block: Optional[FoliageTransactionBlock]
transactions_info: Optional[TransactionsInfo]
transactions_generator: Optional[Program]
transactions_generator_ref_list: List[int]
def __init__(
self,
finished_sub_slots: Sequence[EndOfSubSlotBundle],
reward_chain_block: RewardChainBlockUnfinished,
challenge_chain_sp_proof: Optional[VDFProof],
reward_chain_sp_proof: Optional[VDFProof],
foliage: Foliage,
foliage_transaction_block: Optional[FoliageTransactionBlock],
transactions_info: Optional[TransactionsInfo],
transactions_generator: Optional[Program],
transactions_generator_ref_list: Sequence[int]
) -> None: ...
def __hash__(self) -> int: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __richcmp__(self) -> Any: ...
def __deepcopy__(self) -> UnfinishedBlock: ...
def __copy__(self) -> UnfinishedBlock: ...
@staticmethod
def from_bytes(bytes) -> UnfinishedBlock: ...
@staticmethod
def parse_rust(ReadableBuffer) -> Tuple[UnfinishedBlock, int]: ...
def to_bytes(self) -> bytes: ...
def __bytes__(self) -> bytes: ...
def get_hash(self) -> bytes32: ...
def to_json_dict(self) -> Dict[str, Any]: ...
@staticmethod
def from_json_dict(o: Dict[str, Any]) -> UnfinishedBlock: ...

class VDFInfo:
challenge: bytes32
number_of_iterations: int
Expand Down
6 changes: 4 additions & 2 deletions wheel/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use chia_protocol::{
RespondChildren, RespondFeeEstimates, RespondHeaderBlocks, RespondPuzzleSolution,
RespondRemovals, RespondSesInfo, RespondToCoinUpdates, RespondToPhUpdates, RewardChainBlock,
RewardChainBlockUnfinished, RewardChainSubSlot, SendTransaction, SpendBundle,
SubEpochChallengeSegment, SubEpochSegments, SubSlotData, SubSlotProofs, TransactionAck,
TransactionsInfo, VDFInfo, VDFProof,
SubEpochChallengeSegment, SubEpochSegments, SubEpochSummary, SubSlotData, SubSlotProofs,
TransactionAck, TransactionsInfo, UnfinishedBlock, VDFInfo, VDFProof,
};
use clvmr::serde::tree_hash_from_stream;
use clvmr::{
Expand Down Expand Up @@ -329,6 +329,8 @@ pub fn chia_rs(py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<SubSlotData>()?;
m.add_class::<SubEpochChallengeSegment>()?;
m.add_class::<SubEpochSegments>()?;
m.add_class::<SubEpochSummary>()?;
m.add_class::<UnfinishedBlock>()?;

// wallet protocol
m.add_class::<RequestPuzzleSolution>()?;
Expand Down

0 comments on commit 41a47d3

Please sign in to comment.