Rename userdata to data (#3282)
* Rename userdata to data Instead of saying "userdata", which is ambiguous and imprecise, say "instruction data" or "account data". Also, add `ProgramError::InvalidInstructionData` Fixes #2761
This commit is contained in:
@ -68,7 +68,7 @@ impl CrdsValueLabel {
|
||||
}
|
||||
|
||||
impl Vote {
|
||||
// TODO: it might make sense for the transaction to encode the wallclock in the userdata
|
||||
// TODO: it might make sense for the transaction to encode the wallclock in the data
|
||||
pub fn new(transaction: Transaction, wallclock: u64) -> Self {
|
||||
Vote {
|
||||
transaction,
|
||||
|
@ -33,7 +33,7 @@ impl LeaderConfirmationService {
|
||||
// the vote states
|
||||
bank.vote_accounts().for_each(|(_, account)| {
|
||||
total_stake += account.lamports;
|
||||
let vote_state = VoteState::deserialize(&account.userdata).unwrap();
|
||||
let vote_state = VoteState::deserialize(&account.data).unwrap();
|
||||
if let Some(stake_and_state) = vote_state
|
||||
.votes
|
||||
.back()
|
||||
|
@ -187,7 +187,7 @@ impl LocalCluster {
|
||||
}
|
||||
|
||||
info!("Checking for vote account registration");
|
||||
let vote_account_user_data = client.get_account_userdata(&vote_account_pubkey);
|
||||
let vote_account_user_data = client.get_account_data(&vote_account_pubkey);
|
||||
if let Ok(Some(vote_account_user_data)) = vote_account_user_data {
|
||||
if let Ok(vote_state) = VoteState::deserialize(&vote_account_user_data) {
|
||||
if vote_state.delegate_id == delegate_id {
|
||||
|
@ -517,7 +517,7 @@ mod tests {
|
||||
"result":{
|
||||
"owner": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
|
||||
"lamports": 20,
|
||||
"userdata": [],
|
||||
"data": [],
|
||||
"executable": false
|
||||
},
|
||||
"id":1}
|
||||
|
@ -17,7 +17,7 @@ use std::sync::{atomic, Arc};
|
||||
pub trait RpcSolPubSub {
|
||||
type Metadata;
|
||||
|
||||
// Get notification every time account userdata is changed
|
||||
// Get notification every time account data is changed
|
||||
// Accepts pubkey parameter as base-58 encoded string
|
||||
#[pubsub(
|
||||
subscription = "accountNotification",
|
||||
@ -34,7 +34,7 @@ pub trait RpcSolPubSub {
|
||||
)]
|
||||
fn account_unsubscribe(&self, _: Option<Self::Metadata>, _: SubscriptionId) -> Result<bool>;
|
||||
|
||||
// Get notification every time account userdata owned by a particular program is changed
|
||||
// Get notification every time account data owned by a particular program is changed
|
||||
// Accepts pubkey parameter as base-58 encoded string
|
||||
#[pubsub(
|
||||
subscription = "programNotification",
|
||||
@ -371,10 +371,7 @@ mod tests {
|
||||
|
||||
// Test signature confirmation notification #1
|
||||
let string = receiver.poll();
|
||||
let expected_userdata = arc_bank
|
||||
.get_account(&contract_state.pubkey())
|
||||
.unwrap()
|
||||
.userdata;
|
||||
let expected_data = arc_bank.get_account(&contract_state.pubkey()).unwrap().data;
|
||||
let expected = json!({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "accountNotification",
|
||||
@ -382,7 +379,7 @@ mod tests {
|
||||
"result": {
|
||||
"owner": budget_program_id,
|
||||
"lamports": 51,
|
||||
"userdata": expected_userdata,
|
||||
"data": expected_data,
|
||||
"executable": executable,
|
||||
},
|
||||
"subscription": 0,
|
||||
|
@ -239,7 +239,7 @@ mod tests {
|
||||
subscriptions.check_account(&alice.pubkey(), &account);
|
||||
let string = transport_receiver.poll();
|
||||
if let Async::Ready(Some(response)) = string.unwrap() {
|
||||
let expected = format!(r#"{{"jsonrpc":"2.0","method":"accountNotification","params":{{"result":{{"executable":false,"lamports":1,"owner":[129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"userdata":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},"subscription":0}}}}"#);
|
||||
let expected = format!(r#"{{"jsonrpc":"2.0","method":"accountNotification","params":{{"result":{{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"executable":false,"lamports":1,"owner":[129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},"subscription":0}}}}"#);
|
||||
assert_eq!(expected, response);
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ mod tests {
|
||||
subscriptions.check_program(&solana_budget_api::id(), &alice.pubkey(), &account);
|
||||
let string = transport_receiver.poll();
|
||||
if let Async::Ready(Some(response)) = string.unwrap() {
|
||||
let expected = format!(r#"{{"jsonrpc":"2.0","method":"programNotification","params":{{"result":["{:?}",{{"executable":false,"lamports":1,"owner":[129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"userdata":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}],"subscription":0}}}}"#, alice.pubkey());
|
||||
let expected = format!(r#"{{"jsonrpc":"2.0","method":"programNotification","params":{{"result":["{:?}",{{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"executable":false,"lamports":1,"owner":[129,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}],"subscription":0}}}}"#, alice.pubkey());
|
||||
assert_eq!(expected, response);
|
||||
}
|
||||
|
||||
|
@ -395,10 +395,10 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_system_transaction_userdata_layout() {
|
||||
fn test_system_transaction_data_layout() {
|
||||
use crate::packet::PACKET_DATA_SIZE;
|
||||
let mut tx0 = test_tx();
|
||||
tx0.instructions[0].userdata = vec![1, 2, 3];
|
||||
tx0.instructions[0].data = vec![1, 2, 3];
|
||||
let message0a = tx0.message();
|
||||
let tx_bytes = serialize(&tx0).unwrap();
|
||||
assert!(tx_bytes.len() < PACKET_DATA_SIZE);
|
||||
@ -408,9 +408,9 @@ mod tests {
|
||||
);
|
||||
let tx1 = deserialize(&tx_bytes).unwrap();
|
||||
assert_eq!(tx0, tx1);
|
||||
assert_eq!(tx1.instructions[0].userdata, vec![1, 2, 3]);
|
||||
assert_eq!(tx1.instructions[0].data, vec![1, 2, 3]);
|
||||
|
||||
tx0.instructions[0].userdata = vec![1, 2, 4];
|
||||
tx0.instructions[0].data = vec![1, 2, 4];
|
||||
let message0b = tx0.message();
|
||||
assert_ne!(message0a, message0b);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ fn node_staked_accounts_at_epoch(
|
||||
}
|
||||
|
||||
fn filter_no_delegate(account_id: &Pubkey, account: &Account) -> bool {
|
||||
VoteState::deserialize(&account.userdata)
|
||||
VoteState::deserialize(&account.data)
|
||||
.map(|vote_state| vote_state.delegate_id != *account_id)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
@ -91,7 +91,7 @@ fn to_vote_state(
|
||||
node_staked_accounts: impl Iterator<Item = (impl Borrow<Pubkey>, u64, impl Borrow<Account>)>,
|
||||
) -> impl Iterator<Item = (u64, VoteState)> {
|
||||
node_staked_accounts.filter_map(|(_, stake, account)| {
|
||||
VoteState::deserialize(&account.borrow().userdata)
|
||||
VoteState::deserialize(&account.borrow().data)
|
||||
.ok()
|
||||
.map(|vote_state| (stake, vote_state))
|
||||
})
|
||||
|
@ -235,7 +235,7 @@ impl StorageStage {
|
||||
);
|
||||
|
||||
if let Some(account) = account_to_create {
|
||||
if client.get_account_userdata(&account).is_ok() {
|
||||
if client.get_account_data(&account).is_ok() {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
@ -383,7 +383,7 @@ impl StorageStage {
|
||||
*current_key_idx += size_of::<Signature>();
|
||||
*current_key_idx %= storage_keys.len();
|
||||
} else if solana_storage_api::check_id(&program_id) {
|
||||
match deserialize(&tx.instructions[i].userdata) {
|
||||
match deserialize(&tx.instructions[i].data) {
|
||||
Ok(StorageProgram::SubmitMiningProof {
|
||||
entry_height: proof_entry_height,
|
||||
..
|
||||
|
Reference in New Issue
Block a user