block_hash => blockhash
This commit is contained in:
committed by
Greg Fitzgerald
parent
0f1582c196
commit
a94880574b
@ -24,8 +24,8 @@ impl<'a> RewardsBank<'a> {
|
||||
rewards_id: Pubkey,
|
||||
lamports: u64,
|
||||
) -> Result<()> {
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = RewardsTransaction::new_account(from_keypair, rewards_id, block_hash, lamports, 0);
|
||||
let blockhash = self.bank.last_blockhash();
|
||||
let tx = RewardsTransaction::new_account(from_keypair, rewards_id, blockhash, lamports, 0);
|
||||
self.bank.process_transaction(&tx)
|
||||
}
|
||||
|
||||
@ -35,25 +35,25 @@ impl<'a> RewardsBank<'a> {
|
||||
vote_id: Pubkey,
|
||||
lamports: u64,
|
||||
) -> Result<()> {
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let blockhash = self.bank.last_blockhash();
|
||||
let tx =
|
||||
VoteTransaction::fund_staking_account(from_keypair, vote_id, block_hash, lamports, 0);
|
||||
VoteTransaction::fund_staking_account(from_keypair, vote_id, blockhash, lamports, 0);
|
||||
self.bank.process_transaction(&tx)
|
||||
}
|
||||
|
||||
fn submit_vote(&self, vote_keypair: &Keypair, tick_height: u64) -> Result<VoteState> {
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, block_hash, 0);
|
||||
let blockhash = self.bank.last_blockhash();
|
||||
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, blockhash, 0);
|
||||
self.bank.process_transaction(&tx)?;
|
||||
self.bank.register_tick(&hash(block_hash.as_ref()));
|
||||
self.bank.register_tick(&hash(blockhash.as_ref()));
|
||||
|
||||
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
|
||||
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())
|
||||
}
|
||||
|
||||
fn redeem_credits(&self, rewards_id: Pubkey, vote_keypair: &Keypair) -> Result<VoteState> {
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = RewardsTransaction::new_redeem_credits(&vote_keypair, rewards_id, block_hash, 0);
|
||||
let blockhash = self.bank.last_blockhash();
|
||||
let tx = RewardsTransaction::new_redeem_credits(&vote_keypair, rewards_id, blockhash, 0);
|
||||
self.bank.process_transaction(&tx)?;
|
||||
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
|
||||
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())
|
||||
|
@ -18,14 +18,14 @@ impl RewardsTransaction {
|
||||
pub fn new_account(
|
||||
from_keypair: &Keypair,
|
||||
rewards_id: Pubkey,
|
||||
block_hash: Hash,
|
||||
blockhash: Hash,
|
||||
num_tokens: u64,
|
||||
fee: u64,
|
||||
) -> Transaction {
|
||||
SystemTransaction::new_program_account(
|
||||
from_keypair,
|
||||
rewards_id,
|
||||
block_hash,
|
||||
blockhash,
|
||||
num_tokens,
|
||||
RewardsState::max_size() as u64,
|
||||
id(),
|
||||
@ -36,7 +36,7 @@ impl RewardsTransaction {
|
||||
pub fn new_redeem_credits(
|
||||
vote_keypair: &Keypair,
|
||||
rewards_id: Pubkey,
|
||||
block_hash: Hash,
|
||||
blockhash: Hash,
|
||||
fee: u64,
|
||||
) -> Transaction {
|
||||
let vote_id = vote_keypair.pubkey();
|
||||
@ -45,6 +45,6 @@ impl RewardsTransaction {
|
||||
vote_id, rewards_id,
|
||||
))
|
||||
.push(VoteInstruction::new_clear_credits(vote_id))
|
||||
.sign(&[vote_keypair], block_hash)
|
||||
.sign(&[vote_keypair], blockhash)
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ fn entrypoint(
|
||||
};
|
||||
storage_account_state.proofs[segment_index].push(proof_info);
|
||||
}
|
||||
StorageProgram::AdvertiseStorageRecentBlockHash { hash, entry_height } => {
|
||||
StorageProgram::AdvertiseStorageRecentBlockhash { hash, entry_height } => {
|
||||
let original_segments = storage_account_state.entry_height / ENTRIES_PER_SEGMENT;
|
||||
let segments = entry_height / ENTRIES_PER_SEGMENT;
|
||||
debug!(
|
||||
@ -229,7 +229,7 @@ mod test {
|
||||
let pubkey = keypair.pubkey();
|
||||
keyed_accounts.push(KeyedAccount::new(&pubkey, true, &mut user_account));
|
||||
|
||||
let tx = StorageTransaction::new_advertise_recent_block_hash(
|
||||
let tx = StorageTransaction::new_advertise_recent_blockhash(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -287,7 +287,7 @@ mod test {
|
||||
let mut accounts = [Account::default(), Account::default()];
|
||||
accounts[0].userdata.resize(16 * 1024, 0);
|
||||
|
||||
let tx = StorageTransaction::new_advertise_recent_block_hash(
|
||||
let tx = StorageTransaction::new_advertise_recent_blockhash(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -316,7 +316,7 @@ mod test {
|
||||
|
||||
let entry_height = 0;
|
||||
|
||||
let tx = StorageTransaction::new_advertise_recent_block_hash(
|
||||
let tx = StorageTransaction::new_advertise_recent_blockhash(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -334,7 +334,7 @@ mod test {
|
||||
);
|
||||
test_transaction(&tx, &mut accounts).unwrap();
|
||||
|
||||
let tx = StorageTransaction::new_advertise_recent_block_hash(
|
||||
let tx = StorageTransaction::new_advertise_recent_blockhash(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
@ -350,7 +350,7 @@ mod test {
|
||||
);
|
||||
test_transaction(&tx, &mut accounts).unwrap();
|
||||
|
||||
let tx = StorageTransaction::new_advertise_recent_block_hash(
|
||||
let tx = StorageTransaction::new_advertise_recent_blockhash(
|
||||
&keypair,
|
||||
Hash::default(),
|
||||
Hash::default(),
|
||||
|
@ -25,7 +25,7 @@ fn get_storage_entry_height(bank: &Bank, account: Pubkey) -> u64 {
|
||||
0
|
||||
}
|
||||
|
||||
fn get_storage_block_hash(bank: &Bank, account: Pubkey) -> Hash {
|
||||
fn get_storage_blockhash(bank: &Bank, account: Pubkey) -> Hash {
|
||||
if let Some(storage_system_account) = bank.get_account(&account) {
|
||||
let state = deserialize(&storage_system_account.userdata);
|
||||
if let Ok(state) = state {
|
||||
@ -46,23 +46,21 @@ fn test_bank_storage() {
|
||||
let jill = Keypair::new();
|
||||
|
||||
let x = 42;
|
||||
let block_hash = genesis_block.hash();
|
||||
let blockhash = genesis_block.hash();
|
||||
let x2 = x * 2;
|
||||
let storage_block_hash = hash(&[x2]);
|
||||
let storage_blockhash = hash(&[x2]);
|
||||
|
||||
bank.register_tick(&block_hash);
|
||||
bank.register_tick(&blockhash);
|
||||
|
||||
bank.transfer(10, &alice, jill.pubkey(), block_hash)
|
||||
.unwrap();
|
||||
bank.transfer(10, &alice, jill.pubkey(), blockhash).unwrap();
|
||||
|
||||
bank.transfer(10, &alice, bob.pubkey(), block_hash).unwrap();
|
||||
bank.transfer(10, &alice, jack.pubkey(), block_hash)
|
||||
.unwrap();
|
||||
bank.transfer(10, &alice, bob.pubkey(), blockhash).unwrap();
|
||||
bank.transfer(10, &alice, jack.pubkey(), blockhash).unwrap();
|
||||
|
||||
let tx = SystemTransaction::new_program_account(
|
||||
&alice,
|
||||
bob.pubkey(),
|
||||
block_hash,
|
||||
blockhash,
|
||||
1,
|
||||
4 * 1024,
|
||||
storage_program::id(),
|
||||
@ -71,10 +69,10 @@ fn test_bank_storage() {
|
||||
|
||||
bank.process_transaction(&tx).unwrap();
|
||||
|
||||
let tx = StorageTransaction::new_advertise_recent_block_hash(
|
||||
let tx = StorageTransaction::new_advertise_recent_blockhash(
|
||||
&bob,
|
||||
storage_block_hash,
|
||||
block_hash,
|
||||
storage_blockhash,
|
||||
blockhash,
|
||||
ENTRIES_PER_SEGMENT,
|
||||
);
|
||||
|
||||
@ -86,7 +84,7 @@ fn test_bank_storage() {
|
||||
//let tx = StorageTransaction::new_mining_proof(
|
||||
// &jack,
|
||||
// Hash::default(),
|
||||
// block_hash,
|
||||
// blockhash,
|
||||
// entry_height,
|
||||
// Signature::default(),
|
||||
//);
|
||||
@ -97,7 +95,7 @@ fn test_bank_storage() {
|
||||
ENTRIES_PER_SEGMENT
|
||||
);
|
||||
assert_eq!(
|
||||
get_storage_block_hash(&bank, bob.pubkey()),
|
||||
storage_block_hash
|
||||
get_storage_blockhash(&bank, bob.pubkey()),
|
||||
storage_blockhash
|
||||
);
|
||||
}
|
||||
|
@ -26,17 +26,17 @@ impl<'a> VoteBank<'a> {
|
||||
vote_id: Pubkey,
|
||||
lamports: u64,
|
||||
) -> Result<()> {
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let blockhash = self.bank.last_blockhash();
|
||||
let tx =
|
||||
VoteTransaction::fund_staking_account(from_keypair, vote_id, block_hash, lamports, 0);
|
||||
VoteTransaction::fund_staking_account(from_keypair, vote_id, blockhash, lamports, 0);
|
||||
self.bank.process_transaction(&tx)
|
||||
}
|
||||
|
||||
fn submit_vote(&self, vote_keypair: &Keypair, tick_height: u64) -> Result<VoteState> {
|
||||
let block_hash = self.bank.last_block_hash();
|
||||
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, block_hash, 0);
|
||||
let blockhash = self.bank.last_blockhash();
|
||||
let tx = VoteTransaction::new_vote(vote_keypair, tick_height, blockhash, 0);
|
||||
self.bank.process_transaction(&tx)?;
|
||||
self.bank.register_tick(&hash(block_hash.as_ref()));
|
||||
self.bank.register_tick(&hash(blockhash.as_ref()));
|
||||
|
||||
let vote_account = self.bank.get_account(&vote_keypair.pubkey()).unwrap();
|
||||
Ok(VoteState::deserialize(&vote_account.userdata).unwrap())
|
||||
@ -72,7 +72,7 @@ fn test_vote_via_bank_with_no_signature() {
|
||||
.unwrap();
|
||||
|
||||
let mallory_id = mallory_keypair.pubkey();
|
||||
let block_hash = bank.last_block_hash();
|
||||
let blockhash = bank.last_blockhash();
|
||||
let vote_ix = BuilderInstruction::new(
|
||||
vote_program::id(),
|
||||
&VoteInstruction::Vote(Vote::new(0)),
|
||||
@ -85,7 +85,7 @@ fn test_vote_via_bank_with_no_signature() {
|
||||
let tx = TransactionBuilder::default()
|
||||
.push(SystemInstruction::new_move(mallory_id, vote_id, 1))
|
||||
.push(vote_ix)
|
||||
.sign(&[&mallory_keypair], block_hash);
|
||||
.sign(&[&mallory_keypair], blockhash);
|
||||
|
||||
let result = bank.process_transaction(&tx);
|
||||
|
||||
|
@ -15,7 +15,7 @@ fn load_program(bank: &Bank, from: &Keypair, loader_id: Pubkey, program: Vec<u8>
|
||||
let tx = SystemTransaction::new_program_account(
|
||||
from,
|
||||
program_account.pubkey(),
|
||||
bank.last_block_hash(),
|
||||
bank.last_blockhash(),
|
||||
1,
|
||||
program.len() as u64,
|
||||
loader_id,
|
||||
@ -32,15 +32,14 @@ fn load_program(bank: &Bank, from: &Keypair, loader_id: Pubkey, program: Vec<u8>
|
||||
loader_id,
|
||||
offset,
|
||||
chunk.to_vec(),
|
||||
bank.last_block_hash(),
|
||||
bank.last_blockhash(),
|
||||
0,
|
||||
);
|
||||
bank.process_transaction(&tx).unwrap();
|
||||
offset += chunk_size as u32;
|
||||
}
|
||||
|
||||
let tx =
|
||||
LoaderTransaction::new_finalize(&program_account, loader_id, bank.last_block_hash(), 0);
|
||||
let tx = LoaderTransaction::new_finalize(&program_account, loader_id, bank.last_blockhash(), 0);
|
||||
bank.process_transaction(&tx).unwrap();
|
||||
assert_eq!(bank.get_signature_status(&tx.signatures[0]), Some(Ok(())));
|
||||
|
||||
@ -63,7 +62,7 @@ fn test_program_native_noop() {
|
||||
&[],
|
||||
program_id,
|
||||
&1u8,
|
||||
bank.last_block_hash(),
|
||||
bank.last_blockhash(),
|
||||
0,
|
||||
);
|
||||
bank.process_transaction(&tx).unwrap();
|
||||
@ -86,7 +85,7 @@ fn test_program_native_failure() {
|
||||
&[],
|
||||
program_id,
|
||||
&1u8,
|
||||
bank.last_block_hash(),
|
||||
bank.last_blockhash(),
|
||||
0,
|
||||
);
|
||||
assert_eq!(
|
||||
@ -141,7 +140,7 @@ fn test_program_bpf_c_noop() {
|
||||
&[],
|
||||
program_id,
|
||||
&vec![1u8],
|
||||
bank.last_block_hash(),
|
||||
bank.last_blockhash(),
|
||||
0,
|
||||
);
|
||||
bank.process_transaction(&tx).unwrap();
|
||||
@ -185,7 +184,7 @@ fn test_program_bpf_c() {
|
||||
&[],
|
||||
program_id,
|
||||
&vec![1u8],
|
||||
bank.last_block_hash(),
|
||||
bank.last_blockhash(),
|
||||
0,
|
||||
);
|
||||
bank.process_transaction(&tx).unwrap();
|
||||
@ -225,7 +224,7 @@ fn test_program_bpf_rust() {
|
||||
&[],
|
||||
program_id,
|
||||
&vec![1u8],
|
||||
bank.last_block_hash(),
|
||||
bank.last_blockhash(),
|
||||
0,
|
||||
);
|
||||
bank.process_transaction(&tx).unwrap();
|
||||
|
Reference in New Issue
Block a user