Add storage reward pools (#4779)

This commit is contained in:
Sagar Dhawan
2019-06-22 17:18:35 -07:00
committed by GitHub
parent 0cc8a841ab
commit 11992946a4
15 changed files with 122 additions and 164 deletions

View File

@@ -70,6 +70,7 @@ pub fn create_genesis_block_with_leader(
]);
builder = solana_stake_api::rewards_pools::genesis(builder);
builder = solana_storage_api::rewards_pools::genesis(builder);
GenesisBlockInfo {
genesis_block: builder.build(),

View File

@@ -186,7 +186,10 @@ impl MessageProcessor {
let program_id = instruction.program_id(&message.account_keys);
// TODO: the runtime should be checking read/write access to memory
// we are trusting the hard-coded programs not to clobber or allocate
let pre_total: u64 = program_accounts.iter().map(|a| a.lamports).sum();
let pre_total: u128 = program_accounts
.iter()
.map(|a| u128::from(a.lamports))
.sum();
let pre_data: Vec<_> = program_accounts
.iter_mut()
.map(|a| (a.owner, a.lamports, a.data.clone()))
@@ -215,7 +218,10 @@ impl MessageProcessor {
}
}
// The total sum of all the lamports in all the accounts cannot change.
let post_total: u64 = program_accounts.iter().map(|a| a.lamports).sum();
let post_total: u128 = program_accounts
.iter()
.map(|a| u128::from(a.lamports))
.sum();
if pre_total != post_total {
return Err(InstructionError::UnbalancedInstruction);
}