Skip to main content

Executor

Struct Executor 

Source
pub struct Executor { /* private fields */ }
Expand description

実行している状態。

Implementations§

Source§

impl Executor

Source

pub fn restore_partial( config: ChainConfig, network: NetworkIdentifier, generation_hash_seed: GenerationHashSeed, rows: impl IntoIterator<Item = (Vec<u8>, Vec<u8>)>, meta: &[u8], ) -> Result<Self, ExecError>

大きい表を全部はメモリに持たない形で戻す。rows は、全部メモリに持つ表の行と、ハッシュロックの行 (期限の来ていないロックを含むものだけを持つ)。meta は木に入らない実行の状態。ほかは、要るときに Executor::load_wanted で読む

Source

pub fn is_partial(&self) -> bool

大きい表を全部はメモリに持たない形か

Source

pub fn load_tree_roots( &mut self, source: &dyn StateSource, ) -> Result<(), ExecError>

必要なノードだけを持つ木の根を、source から読む。戻したあと、根を求める前に呼ぶ

Source

pub fn load_wanted( &mut self, source: &dyn StateSource, wanted: &Wanted, ) -> Result<usize, ExecError>

wanted のうち、まだ読み込んでいないものを source から読む。行は、木の葉までの道のノードも読む。読んだ行の数

Source

pub fn take_missed(&mut self) -> Wanted

まだ読んでいないのに引かれたキー

Source

pub fn wanted_for(&self, block: &Block) -> Wanted

block を確かめて当てるのに要りそうなキー。足りなければ当てる途中で記録されるので、ここは多くの ブロックで1回で済むためのもの

Source

pub fn wanted_for_transaction(&self, transaction: &Transaction) -> Wanted

トランザクション1つを確かめるのに要りそうなキー。連署を待つアグリゲートボンデッドを、ブロックの外で 確かめるとき(Executor::check_partial)にも使う

Source

pub fn undo_attempt( &mut self, source: &dyn StateSource, checkpoint: &[u8], ) -> Result<(), ExecError>

まだ読んでいないキーを引いて捨てる実行を、当てる前に戻す。source はまだ当てる前の状態 (コミットしていない)、checkpoint は当てる前の高さの木に入らない実行の状態。直近のトランザクションの ハッシュは、その実行で新しく覚えた分だけを忘れる。ブロックのトランザクションの全部を忘れると、二度入れで 弾いたトランザクションの、前のブロックで覚えたハッシュまで消えて、次のブロックに入り直してしまう

Source

pub fn release_loaded(&mut self) -> usize

要るものだけを読む形のとき、ブロックをコミットしたあとで、読み込んだ大きい表と木のノードを手放す。次に 要れば読み口から読む。ブロックをまたいで持っておくのは、読み口の側(super::source::CachedSource)。 期限の来ていないハッシュロックは、期限を処理するときに読み直さずに表をたどるので持っておく。変えてまだ しまっていないものも持っておく。手放した数

Source§

impl Executor

Source

pub fn take_changes(&mut self) -> StateChanges

前に書いてから変わったかもしれない行。今の値を書くか、なくなっていれば消す。

Source

pub fn restore( config: ChainConfig, network: NetworkIdentifier, generation_hash_seed: GenerationHashSeed, rows: impl IntoIterator<Item = (Vec<u8>, Vec<u8>)>, meta: &[u8], ) -> Result<Self, ExecError>

行と、木に入らない実行の状態から戻す。木は、最初に根を求めるときに組み直す。

Source

pub fn restore_rows( config: ChainConfig, network: NetworkIdentifier, generation_hash_seed: GenerationHashSeed, rows: impl IntoIterator<Item = (Vec<u8>, Vec<u8>)>, height: u64, ) -> Result<Self, ExecError>

行だけから、height のあとの木を組めるように戻す。木に入らない実行の状態は戻らないので、続きは実行できない。 昔の高さの根を確かめるのに使う

Source

pub fn revert( &mut self, rows: impl IntoIterator<Item = (Vec<u8>, Option<Vec<u8>>)>, checkpoint: &[u8], ) -> Result<(), ExecError>

巻き戻した高さ c に、メモリの状態を戻す。rows は c より上で変わった行の c のときの値 (保存の changes_above で、巻き戻す前に読む)、checkpoint は c のチェックポイント。 木のノードの変化は捨てる(DB の木のノードは巻き戻しで戻っている)。二度入れを弾くハッシュは空になるので、 呼ぶ側が直前のブロックから Executor::remember_transactions で覚え直す。 戻したあとで、根が c のブロックの StateHash と合うかを確かめること

Source

pub fn encode_meta(&self) -> Vec<u8> ⓘ

木に入らない実行の状態。行と一緒にコミットする

Source§

impl Executor

Source

pub fn remember_transactions(&mut self, block: &Block) -> Result<(), ExecError>

実行したブロックのトランザクションのハッシュを覚え直す。途中から実行するときに、直前のブロックを 古い順に渡す(期限の上限はボンデッドの 48 時間なので、最後のブロックの時刻からそれだけさかのぼれば足りる)

Source§

impl Executor

Source

pub fn hash_lock_ready(&self, hash: &Hash256) -> bool

アグリゲートボンデッド hash のハッシュロックが、確定していて、使われておらず、期限が来ていないか (catapult の AggregateHashPresentValidator)。今の先端の高さで見る

Source

pub fn check_partial(&self, transaction: &Transaction) -> PartialCheck

連署を待つアグリゲートボンデッドを、今の状態で確かめる。連署できない人がいれば、それを返す。いなければ、 中のトランザクションに要る署名者がみな(マルチシグならたどって要る数だけ)連署しているか。 ブロックの中と違い、中のトランザクションは当てずに、今の状態のまま見る(catapult と同じ)

Source§

impl Executor

Source

pub fn new( config: ChainConfig, network: NetworkIdentifier, generation_hash_seed: GenerationHashSeed, ) -> Self

Source

pub fn height(&self) -> u64

実行した最後の高さ。

Source

pub fn score(&self) -> Option<u128>

ジェネシスからのチェーンのスコア。前の DB から戻してまだ入れていなければ None

Source

pub fn set_score(&mut self, total: u128, last: BlockStatistic)

前の DB から戻したときに、しまったブロックから求めたスコアと、最後のブロックを入れる

Source

pub fn apply(&mut self, block: &Block) -> Result<(), ExecError>

次の高さのブロックを実行する。ブロックそのものは確かめてあること。

Source

pub fn failed_transaction(&self) -> Option<usize>

作るブロックを当てて、ヘッダーに書く StateHash、ReceiptsHash、importance ブロックの足を求める。 ブロックのそれらは見ない(0 のままでよい)。どれも状態を変えないので、当てたあとの状態は、求めたものを書いた ブロックを実行したあとのものと同じ。通らなければ状態は途中のままなので、捨てて戻し直すこと 最後の Executor::apply がトランザクションを当てているところで弾いたなら、それがブロックの何件目か(0から)

Source

pub fn apply_produced(&mut self, block: &Block) -> Result<Produced, ExecError>

Source

pub fn take_statement(&mut self) -> BlockStatement

最後に実行したブロックのステートメント。この Merkle の根が、ブロックの ReceiptsHash になる

Source

pub fn roots(&mut self) -> [Hash256; 9]

9本の木の根。アカウントは変わったものだけ、ほかは葉を並べ直して、変わった道だけを計算し直す。

Source

pub fn restore_trees( &mut self, nodes: impl IntoIterator<Item = (Vec<u8>, Vec<u8>)>, ) -> Result<(), ExecError>

しまった木のノードから9本の木を戻す。行から組み直すと全部の葉とノードのハッシュを求め直すが、 こちらはハッシュをほとんど求めない。戻したあとで、根がブロックの StateHash と合うかを確かめること

Source

pub fn rebuild_trees(&mut self)

木を捨てて、行から組み直すことにする。Executor::restore_trees の根が合わなかったとき

Source

pub fn take_node_changes(&mut self) -> Vec<(Vec<u8>, Option<Vec<u8>>)>

前に呼んでから変わった、9本の木のノード。キー(crate::tree::node_key)と、 今のノードのバイト列か、なくなったら None。Executor::roots のあとで呼ぶ

Source

pub fn forget_node_changes(&mut self)

木の組み直しなどで溜まったノードの変化を捨てて、これからの変化を覚える。DB にあるものと同じ木のとき

Source

pub fn all_nodes(&mut self) -> Option<Vec<(Vec<u8>, Vec<u8>)>>

9本の木のノードを全部。Executor::roots のあとで呼ぶ。必要なノードだけを持つ木があれば None

Source

pub fn leaf_of_row(&self, row: &[u8]) -> (SubCache, Hash256, Option<Hash256>)

行(persist::row_key)の、木の番号と木のキーと、木にある葉の値。Executor::roots のあとで呼ぶ

Source

pub fn state_bytes_of_row(&self, row: &[u8]) -> Option<Vec<u8>>

行の、木の葉の値のもとになる catapult の形のバイト列。この SHA3-256 が葉の値になる。 木の中を見ないので、行だけから戻した状態でも使える。木に入らなければ None

Source

pub fn path_of_row(&mut self, row: &[u8]) -> Option<Vec<TreeNode>>

行の葉への経路。Executor::roots のあとで呼ぶ。必要なノードだけを持つ木なら None

Source

pub fn check_harvester( &self, parent: &Block, parent_generation_hash: &GenerationHash, block: &Block, parameters: &NetworkParameters, ) -> Result<GenerationHash, ExecError>

block を出したアカウントに、その資格があるか。1つ前のブロック parent のあとの状態で、実行する前に呼ぶ。 catapult の BlockchainProcessor の CheckGenerationHash と BlockHitPredicate:

  1. 署名者のアカウントが、公開鍵で見つかる
  2. 署名者がリモートならメインアカウントの、VRF の鍵で、parent_generation_hash の証明が通る
  3. 証明から出た generation hash で当たりになる。importance は、リモートならメインアカウントの、 その高さの importance の高さのもの。違う高さのものしかなければ 0

通れば、このブロックの generation hash を返す。

Source

pub fn check_hit( &self, parent: &Block, block: &Block, parameters: &NetworkParameters, ) -> Result<PublicKey, ExecError>

Executor::check_harvester のうち、状態を見るところ(1 と 3)。VRF の証明はまだ確かめずに、証明の gamma から 出る generation hash で当たりかを見る。通れば、証明を確かめるのに使う VRF の鍵を返す。

証明は状態に依らないので、呼んだ側が別に(別のスレッドなどで)heika_core::vrf::verify で確かめる。 確かめ終えるまで、このブロックは確かめたことにならない

Source

pub fn harvester_importance(&self, block: &Block) -> Result<u64, ExecError>

block を出したアカウント(リモートならメインアカウント)の、そのブロックの高さで使う Importance

Source

pub fn signer_importance( &self, signer: &PublicKey, height: u64, ) -> Result<u64, ExecError>

signer が高さ height のブロックを出すときに使う Importance(リモートならメインアカウントのもの)

Source

pub fn harvester_address( &self, signer: &PublicKey, ) -> Result<[u8; 24], ExecError>

signer の鍵でブロックを出したときに、報酬を受け取るアカウントのアドレス(リモートならメインアカウント)

Source

pub fn harvesting_stake(&self) -> u128

大口のアカウント(収穫モザイクの残高が minHarvesterBalance 以上)の残高の合計。catapult が Importance を 求めるときの ActiveHarvestingMosaics(ハーベストしているかに依らない)

Source

pub fn voting_set(&self, epoch: u32) -> VotingSet

今の状態で決まる、エポック epoch の投票者。catapult の FinalizationContext の作り方と同じで、 投票の鍵を持ち、収穫モザイクの残高が minVoterBalance 以上のアカウントの、そのエポックの鍵と残高。 今の高さが epoch の1つ前のエポックの最後の高さのときに呼ぶ

Source

pub fn state_hash(&mut self) -> Hash256

根から求めた StateHash。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.