diff --git a/programs/native/system/src/lib.rs b/programs/native/system/src/lib.rs index e91a3de51d..7745efedb9 100644 --- a/programs/native/system/src/lib.rs +++ b/programs/native/system/src/lib.rs @@ -59,7 +59,6 @@ pub fn entrypoint( keyed_accounts[to].account.owner = program_id; keyed_accounts[to].account.userdata = vec![0; space as usize]; keyed_accounts[to].account.executable = false; - keyed_accounts[to].account.loader = Pubkey::default(); } SystemInstruction::Assign { program_id } => { if !system_program::check_id(&keyed_accounts[from].account.owner) { @@ -83,11 +82,10 @@ pub fn entrypoint( } SystemInstruction::Spawn => { if !keyed_accounts[from].account.executable - || keyed_accounts[from].account.loader != Pubkey::default() + || keyed_accounts[from].account.owner != Pubkey::default() { Err(ProgramError::AccountNotFinalized)?; } - keyed_accounts[from].account.loader = keyed_accounts[from].account.owner; keyed_accounts[from].account.owner = *keyed_accounts[from].signer_key().unwrap(); } } diff --git a/sdk/src/account.rs b/sdk/src/account.rs index 480c47672a..b721613637 100644 --- a/sdk/src/account.rs +++ b/sdk/src/account.rs @@ -8,13 +8,10 @@ pub struct Account { pub tokens: u64, /// data held in this account pub userdata: Vec, - /// the program that owns this account + /// the program that owns this account. If executable, the program that loads this account. pub owner: Pubkey, /// this account's userdata contains a loaded program (and is now read-only) pub executable: bool, - /// the loader for this account - /// (Pubkey::default() if the account is not executable and thus was never 'loaded') - pub loader: Pubkey, } impl Account { @@ -25,7 +22,6 @@ impl Account { userdata: vec![0u8; space], owner, executable: false, - loader: Pubkey::default(), } } } diff --git a/sdk/src/native_loader.rs b/sdk/src/native_loader.rs index a1c0abec57..d25796050b 100644 --- a/sdk/src/native_loader.rs +++ b/sdk/src/native_loader.rs @@ -20,6 +20,5 @@ pub fn create_program_account(name: &str) -> Account { owner: id(), userdata: name.as_bytes().to_vec(), executable: true, - loader: id(), } } diff --git a/src/accounts.rs b/src/accounts.rs index b1f1791c77..b0670289b9 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -192,7 +192,7 @@ impl AccountsDB { return Err(BankError::AccountNotFound); } }; - if !program.executable || program.loader == Pubkey::default() { + if !program.executable || program.owner == Pubkey::default() { error_counters.account_not_found += 1; return Err(BankError::AccountNotFound); } @@ -200,7 +200,7 @@ impl AccountsDB { // add loader to chain accounts.insert(0, (program_id, program.clone())); - program_id = program.loader; + program_id = program.owner; } Ok(accounts) } @@ -616,32 +616,32 @@ mod tests { let mut account = Account::new(40, 1, Pubkey::default()); account.executable = true; - account.loader = native_loader::id(); + account.owner = native_loader::id(); accounts.push((key1, account)); let mut account = Account::new(41, 1, Pubkey::default()); account.executable = true; - account.loader = key1; + account.owner = key1; accounts.push((key2, account)); let mut account = Account::new(42, 1, Pubkey::default()); account.executable = true; - account.loader = key2; + account.owner = key2; accounts.push((key3, account)); let mut account = Account::new(43, 1, Pubkey::default()); account.executable = true; - account.loader = key3; + account.owner = key3; accounts.push((key4, account)); let mut account = Account::new(44, 1, Pubkey::default()); account.executable = true; - account.loader = key4; + account.owner = key4; accounts.push((key5, account)); let mut account = Account::new(45, 1, Pubkey::default()); account.executable = true; - account.loader = key5; + account.owner = key5; accounts.push((key6, account)); let instructions = vec![Instruction::new(0, &(), vec![0])]; @@ -675,7 +675,7 @@ mod tests { let mut account = Account::new(40, 1, Pubkey::default()); account.executable = true; - account.loader = Pubkey::default(); + account.owner = Pubkey::default(); accounts.push((key1, account)); let instructions = vec![Instruction::new(0, &(), vec![0])]; @@ -708,7 +708,7 @@ mod tests { accounts.push((key0, account)); let mut account = Account::new(40, 1, Pubkey::default()); - account.loader = native_loader::id(); + account.owner = native_loader::id(); accounts.push((key1, account)); let instructions = vec![Instruction::new(0, &(), vec![0])]; @@ -744,17 +744,17 @@ mod tests { let mut account = Account::new(40, 1, Pubkey::default()); account.executable = true; - account.loader = native_loader::id(); + account.owner = native_loader::id(); accounts.push((key1, account)); let mut account = Account::new(41, 1, Pubkey::default()); account.executable = true; - account.loader = key1; + account.owner = key1; accounts.push((key2, account)); let mut account = Account::new(42, 1, Pubkey::default()); account.executable = true; - account.loader = key2; + account.owner = key2; accounts.push((key3, account)); let instructions = vec![ diff --git a/src/bank.rs b/src/bank.rs index 9c30c78d3e..042480c853 100644 --- a/src/bank.rs +++ b/src/bank.rs @@ -191,7 +191,6 @@ impl Bank { userdata: vec![0; vote_program::get_max_size() as usize], owner: vote_program::id(), executable: false, - loader: Pubkey::default(), }; let mut vote_state = vote_program::VoteState::new( diff --git a/src/rpc.rs b/src/rpc.rs index 85a7705071..af99301215 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -599,8 +599,7 @@ mod tests { "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], "tokens": 20, "userdata": [], - "executable": false, - "loader": [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] + "executable": false }, "id":1} "#; diff --git a/src/rpc_pubsub.rs b/src/rpc_pubsub.rs index a1b05e96c6..bb29fbaa34 100644 --- a/src/rpc_pubsub.rs +++ b/src/rpc_pubsub.rs @@ -507,7 +507,6 @@ mod tests { let contract_funds = Keypair::new(); let contract_state = Keypair::new(); let budget_program_id = budget_program::id(); - let loader = Pubkey::default(); // TODO let executable = false; // TODO let bank = Bank::new(&genesis_block); let arc_bank = Arc::new(bank); @@ -565,7 +564,6 @@ mod tests { "tokens": 1, "userdata": expected_userdata, "executable": executable, - "loader": loader, }, "subscription": 0, @@ -605,7 +603,6 @@ mod tests { "tokens": 51, "userdata": expected_userdata, "executable": executable, - "loader": loader, }, "subscription": 0, } @@ -644,7 +641,6 @@ mod tests { "tokens": 1, "userdata": expected_userdata, "executable": executable, - "loader": loader, }, "subscription": 0, } @@ -736,7 +732,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,"loader":[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],"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],"tokens":1,"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":{{"executable":false,"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],"tokens":1,"userdata":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},"subscription":0}}}}"#); assert_eq!(expected, response); }