Reorg
Now clients can use all the libraries to create transactions and disect account data without needing to be constrained about what can be compiled into a shared object or BPF. Likewise, program development can move forward without being concerned with bloating the shared object.
This commit is contained in:
parent
7f3aca15dd
commit
d35b3754a2
|
@ -2202,6 +2202,16 @@ dependencies = [
|
|||
"solana-sdk 0.12.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-rewards-api"
|
||||
version = "0.12.0"
|
||||
dependencies = [
|
||||
"bincode 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-sdk 0.12.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solana-rewards-program"
|
||||
version = "0.12.0"
|
||||
|
@ -2212,6 +2222,7 @@ dependencies = [
|
|||
"serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solana-logger 0.12.0",
|
||||
"solana-metrics 0.12.0",
|
||||
"solana-rewards-api 0.12.0",
|
||||
"solana-runtime 0.12.0",
|
||||
"solana-sdk 0.12.0",
|
||||
"solana-vote-program 0.12.0",
|
||||
|
|
|
@ -108,6 +108,7 @@ members = [
|
|||
"programs/native/native_loader",
|
||||
"programs/native/noop",
|
||||
"programs/native/rewards",
|
||||
"programs/native/rewards_api",
|
||||
"programs/native/storage",
|
||||
"programs/native/system",
|
||||
"programs/native/vote",
|
||||
|
|
|
@ -16,6 +16,7 @@ serde_derive = "1.0.87"
|
|||
solana-logger = { path = "../../../logger", version = "0.12.0" }
|
||||
solana-metrics = { path = "../../../metrics", version = "0.12.0" }
|
||||
solana-sdk = { path = "../../../sdk", version = "0.12.0" }
|
||||
solana-rewards-api = { path = "../rewards_api", version = "0.12.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
solana-vote-program = { path = "../vote", version = "0.12.0" }
|
||||
|
@ -24,4 +25,3 @@ solana-runtime = { path = "../../../runtime", version = "0.12.0" }
|
|||
[lib]
|
||||
name = "solana_rewards_program"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
//! Rewards program
|
||||
//! Exchanges validation and storage proofs for lamports
|
||||
|
||||
pub mod rewards_instruction;
|
||||
pub mod rewards_program;
|
||||
pub mod rewards_transaction;
|
||||
|
||||
use crate::rewards_instruction::RewardsInstruction;
|
||||
use bincode::deserialize;
|
||||
use log::*;
|
||||
use solana_rewards_api::rewards_instruction::RewardsInstruction;
|
||||
use solana_sdk::account::KeyedAccount;
|
||||
use solana_sdk::native_program::ProgramError;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
@ -95,7 +91,7 @@ fn entrypoint(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::rewards_program;
|
||||
use solana_rewards_api::rewards_program;
|
||||
use solana_sdk::account::Account;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::vote_program::{self, Vote};
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
//! The `rewards_transaction` module provides functionality for creating a global
|
||||
//! rewards account and enabling stakers to redeem credits from their vote accounts.
|
||||
|
||||
use crate::rewards_instruction::RewardsInstruction;
|
||||
use crate::rewards_program;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::Keypair;
|
||||
use solana_sdk::system_transaction::SystemTransaction;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
|
||||
pub struct RewardsTransaction {}
|
||||
|
||||
impl RewardsTransaction {
|
||||
pub fn new_account(
|
||||
from_keypair: &Keypair,
|
||||
rewards_id: Pubkey,
|
||||
last_id: Hash,
|
||||
num_tokens: u64,
|
||||
fee: u64,
|
||||
) -> Transaction {
|
||||
SystemTransaction::new_program_account(
|
||||
from_keypair,
|
||||
rewards_id,
|
||||
last_id,
|
||||
num_tokens,
|
||||
rewards_program::get_max_size() as u64,
|
||||
rewards_program::id(),
|
||||
fee,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_redeem_credits(
|
||||
keypair: &Keypair,
|
||||
vote_id: Pubkey,
|
||||
to_id: Pubkey,
|
||||
last_id: Hash,
|
||||
fee: u64,
|
||||
) -> Transaction {
|
||||
let instruction = RewardsInstruction::RedeemVoteCredits;
|
||||
Transaction::new(
|
||||
keypair,
|
||||
&[vote_id, to_id],
|
||||
rewards_program::id(),
|
||||
&instruction,
|
||||
last_id,
|
||||
fee,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::rewards_program;
|
||||
//use solana_runtime::execute_transaction;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::native_loader::create_program_account;
|
||||
use solana_sdk::signature::KeypairUtil;
|
||||
use solana_sdk::system_program;
|
||||
use solana_sdk::vote_program;
|
||||
|
||||
#[test]
|
||||
fn test_execute_rewards_transaction() {
|
||||
let system_program_account = create_program_account("solana_system_program");
|
||||
let mut _new_account_loaders = vec![vec![(system_program::id(), system_program_account)]];
|
||||
let from_keypair = Keypair::new();
|
||||
let rewards_id = Keypair::new().pubkey();
|
||||
let last_id = Hash::default();
|
||||
let _tx = RewardsTransaction::new_account(&from_keypair, rewards_id, last_id, 10_000, 0);
|
||||
//execute_transaction(&tx, &mut new_account_loaders[..], accounts, 0).unwrap();
|
||||
|
||||
let vote_program_account = create_program_account("solana_vote_program");
|
||||
let rewards_program_account = create_program_account("solana_rewards_program");
|
||||
let mut _new_redeem_credits_loaders = vec![
|
||||
vec![(rewards_program::id(), rewards_program_account)],
|
||||
vec![(vote_program::id(), vote_program_account)],
|
||||
];
|
||||
|
||||
let vote_id = Keypair::new().pubkey();
|
||||
let to_id = from_keypair.pubkey();
|
||||
//let to_tokens = to_account.tokens;
|
||||
let _tx = RewardsTransaction::new_redeem_credits(&from_keypair, vote_id, to_id, last_id, 0);
|
||||
//execute_transaction(&tx, &mut new_redeem_credits_loaders[..], accounts, 0).unwrap();
|
||||
//assert!(to_account.tokens > to_tokens);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "solana-rewards-api"
|
||||
version = "0.12.0"
|
||||
description = "Solana rewards API"
|
||||
authors = ["Solana Maintainers <maintainers@solana.com>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bincode = "1.0.0"
|
||||
serde = "1.0.87"
|
||||
serde_derive = "1.0.87"
|
||||
solana-sdk = { path = "../../../sdk", version = "0.12.0" }
|
||||
|
||||
[lib]
|
||||
name = "solana_rewards_api"
|
||||
crate-type = ["lib"]
|
|
@ -0,0 +1,3 @@
|
|||
pub mod rewards_instruction;
|
||||
pub mod rewards_program;
|
||||
pub mod rewards_transaction;
|
|
@ -0,0 +1,50 @@
|
|||
//! The `rewards_transaction` module provides functionality for creating a global
|
||||
//! rewards account and enabling stakers to redeem credits from their vote accounts.
|
||||
|
||||
use crate::rewards_instruction::RewardsInstruction;
|
||||
use crate::rewards_program;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::Keypair;
|
||||
use solana_sdk::system_transaction::SystemTransaction;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
|
||||
pub struct RewardsTransaction {}
|
||||
|
||||
impl RewardsTransaction {
|
||||
pub fn new_account(
|
||||
from_keypair: &Keypair,
|
||||
rewards_id: Pubkey,
|
||||
last_id: Hash,
|
||||
num_tokens: u64,
|
||||
fee: u64,
|
||||
) -> Transaction {
|
||||
SystemTransaction::new_program_account(
|
||||
from_keypair,
|
||||
rewards_id,
|
||||
last_id,
|
||||
num_tokens,
|
||||
rewards_program::get_max_size() as u64,
|
||||
rewards_program::id(),
|
||||
fee,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_redeem_credits(
|
||||
keypair: &Keypair,
|
||||
vote_id: Pubkey,
|
||||
to_id: Pubkey,
|
||||
last_id: Hash,
|
||||
fee: u64,
|
||||
) -> Transaction {
|
||||
let instruction = RewardsInstruction::RedeemVoteCredits;
|
||||
Transaction::new(
|
||||
keypair,
|
||||
&[vote_id, to_id],
|
||||
rewards_program::id(),
|
||||
&instruction,
|
||||
last_id,
|
||||
fee,
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue