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

@ -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);