Integrate Message into Transaction

This commit is contained in:
Greg Fitzgerald
2019-03-29 10:05:06 -06:00
committed by Grimes
parent 98d60e6124
commit 31f8b6d352
14 changed files with 197 additions and 177 deletions

View File

@ -67,8 +67,8 @@ fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {
let from: Vec<u8> = (0..64).map(|_| thread_rng().gen()).collect();
let to: Vec<u8> = (0..64).map(|_| thread_rng().gen()).collect();
let sig: Vec<u8> = (0..64).map(|_| thread_rng().gen()).collect();
new.account_keys[0] = Pubkey::new(&from[0..32]);
new.account_keys[1] = Pubkey::new(&to[0..32]);
new.message.account_keys[0] = Pubkey::new(&from[0..32]);
new.message.account_keys[1] = Pubkey::new(&to[0..32]);
new.signatures = vec![Signature::new(&sig[0..64])];
new
})
@ -77,7 +77,7 @@ fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {
transactions.iter().for_each(|tx| {
let fund = SystemTransaction::new_move(
&mint_keypair,
&tx.account_keys[0],
&tx.message.account_keys[0],
mint_total / txes as u64,
genesis_block.hash(),
0,
@ -159,25 +159,25 @@ fn bench_banking_stage_multi_programs(bencher: &mut Bencher) {
let from: Vec<u8> = (0..32).map(|_| thread_rng().gen()).collect();
let sig: Vec<u8> = (0..64).map(|_| thread_rng().gen()).collect();
let to: Vec<u8> = (0..32).map(|_| thread_rng().gen()).collect();
new.account_keys[0] = Pubkey::new(&from[0..32]);
new.account_keys[1] = Pubkey::new(&to[0..32]);
let prog = new.instructions[0].clone();
new.message.account_keys[0] = Pubkey::new(&from[0..32]);
new.message.account_keys[1] = Pubkey::new(&to[0..32]);
let prog = new.message.instructions[0].clone();
for i in 1..progs {
//generate programs that spend to random keys
let to: Vec<u8> = (0..32).map(|_| thread_rng().gen()).collect();
let to_key = Pubkey::new(&to[0..32]);
new.account_keys.push(to_key);
assert_eq!(new.account_keys.len(), i + 2);
new.instructions.push(prog.clone());
assert_eq!(new.instructions.len(), i + 1);
new.instructions[i].accounts[1] = 1 + i as u8;
new.message.account_keys.push(to_key);
assert_eq!(new.message.account_keys.len(), i + 2);
new.message.instructions.push(prog.clone());
assert_eq!(new.message.instructions.len(), i + 1);
new.message.instructions[i].accounts[1] = 1 + i as u8;
assert_eq!(new.key(i, 1), Some(&to_key));
assert_eq!(
new.account_keys[new.instructions[i].accounts[1] as usize],
new.message.account_keys[new.message.instructions[i].accounts[1] as usize],
to_key
);
}
assert_eq!(new.instructions.len(), progs);
assert_eq!(new.message.instructions.len(), progs);
new.signatures = vec![Signature::new(&sig[0..64])];
new
})
@ -185,7 +185,7 @@ fn bench_banking_stage_multi_programs(bencher: &mut Bencher) {
transactions.iter().for_each(|tx| {
let fund = SystemTransaction::new_move(
&mint_keypair,
&tx.account_keys[0],
&tx.message.account_keys[0],
mint_total / txes as u64,
genesis_block.hash(),
0,

View File

@ -164,7 +164,7 @@ mod tests {
use bs58;
// golden needs to be updated if blob stuff changes....
let golden = Hash::new(
&bs58::decode("7CESTE6TiU1kz3HXoDA6fYUhfnneqbSm75zLYCBdczzp")
&bs58::decode("GnNzHbBRnn1WbrAXudmyxcqhaFiXQdzYWZpi6ToMM4pW")
.into_vec()
.unwrap(),
);

View File

@ -128,7 +128,7 @@ pub fn get_packet_offsets(packet: &Packet, current_offset: u32) -> (u32, u32, u3
let sig_start = current_offset as usize + sig_size;
let msg_start = current_offset as usize + msg_start_offset;
let pubkey_start = msg_start + pubkey_size;
let pubkey_start = msg_start + 1 + pubkey_size;
(
sig_len as u32,
@ -367,7 +367,7 @@ mod tests {
Some(SIG_OFFSET)
);
assert_eq!(
memfind(&tx_bytes, &tx.account_keys[0].as_ref()),
memfind(&tx_bytes, &tx.message().account_keys[0].as_ref()),
Some(pubkey_offset as usize)
);
assert_eq!(
@ -385,7 +385,7 @@ mod tests {
fn test_system_transaction_data_layout() {
use crate::packet::PACKET_DATA_SIZE;
let mut tx0 = test_tx();
tx0.instructions[0].data = vec![1, 2, 3];
tx0.message.instructions[0].data = vec![1, 2, 3];
let message0a = tx0.message_data();
let tx_bytes = serialize(&tx0).unwrap();
assert!(tx_bytes.len() < PACKET_DATA_SIZE);
@ -395,9 +395,9 @@ mod tests {
);
let tx1 = deserialize(&tx_bytes).unwrap();
assert_eq!(tx0, tx1);
assert_eq!(tx1.instructions[0].data, vec![1, 2, 3]);
assert_eq!(tx1.message().instructions[0].data, vec![1, 2, 3]);
tx0.instructions[0].data = vec![1, 2, 4];
tx0.message.instructions[0].data = vec![1, 2, 4];
let message0b = tx0.message_data();
assert_ne!(message0a, message0b);
}
@ -417,19 +417,19 @@ mod tests {
#[test]
fn test_get_packet_offsets() {
assert_eq!(get_packet_offsets_from_tx(test_tx(), 0), (1, 1, 64, 1));
assert_eq!(get_packet_offsets_from_tx(test_tx(), 100), (1, 1, 64, 1));
assert_eq!(get_packet_offsets_from_tx(test_tx(), 0), (1, 1, 64, 2));
assert_eq!(get_packet_offsets_from_tx(test_tx(), 100), (1, 1, 64, 2));
// Ensure we're not indexing packet by the `current_offset` parameter.
assert_eq!(
get_packet_offsets_from_tx(test_tx(), 1_000_000),
(1, 1, 64, 1)
(1, 1, 64, 2)
);
// Ensure we're returning sig_len, not sig_size.
assert_eq!(
get_packet_offsets_from_tx(test_multisig_tx(), 0),
(2, 1, 128, 1)
(2, 1, 128, 2)
);
}

View File

@ -401,9 +401,10 @@ impl StorageStage {
// Go through the transactions, find proofs, and use them to update
// the storage_keys with their signatures
for tx in entry.transactions {
for (i, program_id) in tx.program_ids.iter().enumerate() {
let message = tx.message();
for (i, program_id) in message.program_ids.iter().enumerate() {
if solana_storage_api::check_id(&program_id) {
match deserialize(&tx.instructions[i].data) {
match deserialize(&message.instructions[i].data) {
Ok(StorageInstruction::SubmitMiningProof {
entry_height: proof_entry_height,
signature,
@ -436,7 +437,7 @@ impl StorageStage {
(proof_entry_height / ENTRIES_PER_SEGMENT) as usize;
if proof_segment_index < statew.replicator_map.len() {
statew.replicator_map[proof_segment_index]
.insert(tx.account_keys[0]);
.insert(message.account_keys[0]);
}
}
debug!("storage proof: entry_height: {}", entry_height);