syscall work, rename syscall to sysvar, rename current to clock (#5074)
* syscall work, rename syscall to sysvar, rename current to clock * missed one * nit
This commit is contained in:
@ -15,8 +15,8 @@ use solana_sdk::message::Message;
|
||||
use solana_sdk::native_loader;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::syscall;
|
||||
use solana_sdk::system_program;
|
||||
use solana_sdk::sysvar;
|
||||
use solana_sdk::transaction::Result;
|
||||
use solana_sdk::transaction::{Transaction, TransactionError};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
@ -494,7 +494,7 @@ impl Accounts {
|
||||
|
||||
pub fn hash_internal_state(&self, fork_id: Fork) -> Option<Hash> {
|
||||
let account_hashes = self.scan_fork(fork_id, |stored_account| {
|
||||
if !syscall::check_id(&stored_account.balance.owner) {
|
||||
if !sysvar::check_id(&stored_account.balance.owner) {
|
||||
Some(Self::hash_account(stored_account))
|
||||
} else {
|
||||
None
|
||||
@ -695,7 +695,7 @@ mod tests {
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::instruction::CompiledInstruction;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::syscall;
|
||||
use solana_sdk::sysvar;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use std::io::Cursor;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
@ -1183,7 +1183,7 @@ mod tests {
|
||||
fn test_accounts_empty_hash_internal_state() {
|
||||
let accounts = Accounts::new(None);
|
||||
assert_eq!(accounts.hash_internal_state(0), None);
|
||||
accounts.store_slow(0, &Pubkey::default(), &Account::new(1, 0, &syscall::id()));
|
||||
accounts.store_slow(0, &Pubkey::default(), &Account::new(1, 0, &sysvar::id()));
|
||||
assert_eq!(accounts.hash_internal_state(0), None);
|
||||
}
|
||||
|
||||
|
@ -33,11 +33,11 @@ use solana_sdk::inflation::Inflation;
|
||||
use solana_sdk::native_loader;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::{Keypair, Signature};
|
||||
use solana_sdk::syscall::{
|
||||
current, fees, rewards,
|
||||
use solana_sdk::system_transaction;
|
||||
use solana_sdk::sysvar::{
|
||||
clock, fees, rewards,
|
||||
slot_hashes::{self, SlotHashes},
|
||||
};
|
||||
use solana_sdk::system_transaction;
|
||||
use solana_sdk::timing::{duration_as_ns, get_segment_from_slot, MAX_RECENT_BLOCKHASHES};
|
||||
use solana_sdk::transaction::{Result, Transaction, TransactionError};
|
||||
use std::cmp;
|
||||
@ -289,7 +289,7 @@ impl Bank {
|
||||
bank.epoch_stakes.insert(i, stakes.clone());
|
||||
}
|
||||
}
|
||||
bank.update_current();
|
||||
bank.update_clock();
|
||||
bank
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ impl Bank {
|
||||
});
|
||||
|
||||
self.update_rewards(parent.epoch());
|
||||
self.update_current();
|
||||
self.update_clock();
|
||||
self.update_fees();
|
||||
self
|
||||
}
|
||||
@ -408,10 +408,10 @@ impl Bank {
|
||||
*self.hash.read().unwrap() != Hash::default()
|
||||
}
|
||||
|
||||
fn update_current(&self) {
|
||||
fn update_clock(&self) {
|
||||
self.store_account(
|
||||
¤t::id(),
|
||||
¤t::create_account(
|
||||
&clock::id(),
|
||||
&clock::create_account(
|
||||
1,
|
||||
self.slot,
|
||||
get_segment_from_slot(self.slot, self.slots_per_segment),
|
||||
@ -1461,9 +1461,9 @@ mod tests {
|
||||
use solana_sdk::instruction::InstructionError;
|
||||
use solana_sdk::poh_config::PohConfig;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::syscall::{fees::Fees, rewards::Rewards};
|
||||
use solana_sdk::system_instruction;
|
||||
use solana_sdk::system_transaction;
|
||||
use solana_sdk::sysvar::{fees::Fees, rewards::Rewards};
|
||||
use solana_sdk::timing::DEFAULT_TICKS_PER_SLOT;
|
||||
use solana_vote_api::vote_instruction;
|
||||
use solana_vote_api::vote_state::{VoteState, MAX_LOCKOUT_HISTORY};
|
||||
@ -2252,7 +2252,7 @@ mod tests {
|
||||
let bank0 = Arc::new(Bank::new(&create_genesis_block(10).0));
|
||||
let hash0 = bank0.hash_internal_state();
|
||||
// save hash0 because new_from_parent
|
||||
// updates syscall entries
|
||||
// updates sysvar entries
|
||||
|
||||
let bank1 = Bank::new_from_parent(&bank0, &collector_id, 1);
|
||||
|
||||
|
@ -2,9 +2,9 @@ use log::*;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::instruction::InstructionError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::syscall;
|
||||
use solana_sdk::system_instruction::{SystemError, SystemInstruction};
|
||||
use solana_sdk::system_program;
|
||||
use solana_sdk::sysvar;
|
||||
|
||||
const FROM_ACCOUNT_INDEX: usize = 0;
|
||||
const TO_ACCOUNT_INDEX: usize = 1;
|
||||
@ -33,7 +33,7 @@ fn create_system_account(
|
||||
Err(SystemError::AccountAlreadyInUse)?;
|
||||
}
|
||||
|
||||
if syscall::check_id(&program_id) {
|
||||
if sysvar::check_id(&program_id) {
|
||||
debug!(
|
||||
"CreateAccount: invalid argument; program id {} invalid",
|
||||
program_id
|
||||
@ -41,7 +41,7 @@ fn create_system_account(
|
||||
Err(SystemError::InvalidProgramId)?;
|
||||
}
|
||||
|
||||
if syscall::is_syscall_id(&keyed_accounts[TO_ACCOUNT_INDEX].unsigned_key()) {
|
||||
if sysvar::is_sysvar_id(&keyed_accounts[TO_ACCOUNT_INDEX].unsigned_key()) {
|
||||
debug!(
|
||||
"CreateAccount: invalid argument; account id {} invalid",
|
||||
program_id
|
||||
@ -207,7 +207,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_syscall_invalid_id() {
|
||||
fn test_create_sysvar_invalid_id() {
|
||||
// Attempt to create system account in account already owned by another program
|
||||
let from = Pubkey::new_rand();
|
||||
let mut from_account = Account::new(100, 0, &system_program::id());
|
||||
@ -219,18 +219,18 @@ mod tests {
|
||||
KeyedAccount::new(&from, true, &mut from_account),
|
||||
KeyedAccount::new(&to, false, &mut to_account),
|
||||
];
|
||||
// fail to create a syscall::id() owned account
|
||||
let result = create_system_account(&mut keyed_accounts, 50, 2, &syscall::id());
|
||||
// fail to create a sysvar::id() owned account
|
||||
let result = create_system_account(&mut keyed_accounts, 50, 2, &sysvar::id());
|
||||
assert_eq!(result, Err(SystemError::InvalidProgramId));
|
||||
|
||||
let to = syscall::fees::id();
|
||||
let to = sysvar::fees::id();
|
||||
let mut to_account = Account::default();
|
||||
|
||||
let mut keyed_accounts = [
|
||||
KeyedAccount::new(&from, true, &mut from_account),
|
||||
KeyedAccount::new(&to, false, &mut to_account),
|
||||
];
|
||||
// fail to create an account with a syscall id
|
||||
// fail to create an account with a sysvar id
|
||||
let result = create_system_account(&mut keyed_accounts, 50, 2, &system_program::id());
|
||||
assert_eq!(result, Err(SystemError::InvalidAccountId));
|
||||
|
||||
|
Reference in New Issue
Block a user