Skip to content

Commit

Permalink
Validator reward with runtime (#1152)
Browse files Browse the repository at this point in the history
* test validator reward in runtime

* proper equality for epoch info

* add test for state sync. Address comments

* reward test in epoch manager

* reenable test_kickout
  • Loading branch information
bowenwang1996 authored Aug 10, 2019
1 parent 183dc13 commit 5863a7c
Show file tree
Hide file tree
Showing 18 changed files with 974 additions and 650 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ impl Chain {
vec![],
vec![],
0,
chain_genesis.gas_price,
chain_genesis.total_supply,
)?;
store_update.save_block_header(genesis.header.clone());
store_update.save_block(genesis.clone());
Expand Down Expand Up @@ -350,6 +352,8 @@ impl Chain {
vec![],
vec![],
header.gas_used,
header.gas_price,
header.total_supply,
)?;
}
}
Expand Down Expand Up @@ -1248,8 +1252,6 @@ impl<'a> ChainUpdate<'a> {
&block.hash(),
&receipts,
&chunk.transactions,
block.header.gas_price,
block.header.total_supply,
)
.map_err(|e| ErrorKind::Other(e.to_string()))?;

Expand Down Expand Up @@ -1416,6 +1418,8 @@ impl<'a> ChainUpdate<'a> {
vec![],
vec![],
block.header.gas_used,
block.header.gas_price,
block.header.total_supply,
)?;

// Add validated block to the db, even if it's not the selected fork.
Expand Down
4 changes: 2 additions & 2 deletions chain/chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ impl RuntimeAdapter for KeyValueRuntime {
_slashed_validators: Vec<AccountId>,
_validator_mask: Vec<bool>,
_gas_used: GasUsage,
_gas_price: Balance,
_total_supply: Balance,
) -> Result<(), Error> {
Ok(())
}
Expand All @@ -375,8 +377,6 @@ impl RuntimeAdapter for KeyValueRuntime {
_block_hash: &CryptoHash,
receipts: &Vec<ReceiptTransaction>,
transactions: &Vec<SignedTransaction>,
_gas_price: Balance,
_total_supply: Balance,
) -> Result<ApplyTransactionResult, Error> {
let mut tx_results = vec![];

Expand Down
4 changes: 2 additions & 2 deletions chain/chain/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ pub trait RuntimeAdapter: Send + Sync {
slashed_validators: Vec<AccountId>,
validator_mask: Vec<bool>,
gas_used: GasUsage,
gas_price: Balance,
total_supply: Balance,
) -> Result<(), Error>;

/// Apply transactions to given state root and return store update and new state root.
Expand All @@ -192,8 +194,6 @@ pub trait RuntimeAdapter: Send + Sync {
block_hash: &CryptoHash,
receipts: &Vec<ReceiptTransaction>,
transactions: &Vec<SignedTransaction>,
gas_price: Balance,
total_supply: Balance,
) -> Result<ApplyTransactionResult, Error>;

/// Query runtime with given `path` and `data`.
Expand Down
Loading

0 comments on commit 5863a7c

Please sign in to comment.