Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit bf9db06

Browse files
committed
Merge
2 parents d453530 + 2614189 commit bf9db06

12 files changed

+170
-170
lines changed

ci/test-stable-perf.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if ! ci/version-check.sh stable; then
99
ci/version-check.sh stable
1010
fi
1111
export RUST_BACKTRACE=1
12+
export RUSTFLAGS="-D warnings"
1213

1314
./fetch-perf-libs.sh
1415
export LD_LIBRARY_PATH=$PWD/target/perf-libs:/usr/local/cuda/lib64:$LD_LIBRARY_PATH

ci/test-stable.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ cd "$(dirname "$0")/.."
44

55
ci/version-check.sh stable
66
export RUST_BACKTRACE=1
7+
export RUSTFLAGS="-D warnings"
78

89
_() {
910
echo "--- $*"

doc/json-rpc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Returns all information associated with the account of provided Pubkey
107107
The result field will be a JSON object with the following sub fields:
108108

109109
* `tokens`, number of tokens assigned to this account, as a signed 64-bit integer
110-
* `contract_id`, array of 32 bytes representing the program this account has been assigned to
110+
* `program_id`, array of 32 bytes representing the program this account has been assigned to
111111
* `userdata`, array of bytes representing any userdata associated with the account
112112

113113
##### Example:
@@ -116,7 +116,7 @@ The result field will be a JSON object with the following sub fields:
116116
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getAccountInfo", "params":["FVxxngPx368XvMCoeskdd6U8cZJFsfa1BEtGWqyAxRj4"]}' http://localhost:8899
117117

118118
// Result
119-
{"jsonrpc":"2.0","result":{"contract_id":[1,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":[3,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,50,48,53,48,45,48,49,45,48,49,84,48,48,58,48,48,58,48,48,90,252,10,7,28,246,140,88,177,98,82,10,227,89,81,18,30,194,101,199,16,11,73,133,20,246,62,114,39,20,113,189,32,50,0,0,0,0,0,0,0,247,15,36,102,167,83,225,42,133,127,82,34,36,224,207,130,109,230,224,188,163,33,213,13,5,117,211,251,65,159,197,51,0,0,0,0,0,0]},"id":1}
119+
{"jsonrpc":"2.0","result":{"program_id":[1,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":[3,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,20,0,0,0,0,0,0,0,50,48,53,48,45,48,49,45,48,49,84,48,48,58,48,48,58,48,48,90,252,10,7,28,246,140,88,177,98,82,10,227,89,81,18,30,194,101,199,16,11,73,133,20,246,62,114,39,20,113,189,32,50,0,0,0,0,0,0,0,247,15,36,102,167,83,225,42,133,127,82,34,36,224,207,130,109,230,224,188,163,33,213,13,5,117,211,251,65,159,197,51,0,0,0,0,0,0]},"id":1}
120120
```
121121

122122
---

src/bank.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
use bincode::deserialize;
77
use bincode::serialize;
8-
use budget_contract::BudgetContract;
8+
use budget_program::BudgetState;
99
use counter::Counter;
1010
use dynamic_contract::{DynamicContract, KeyedAccount};
1111
use entry::Entry;
@@ -22,7 +22,7 @@ use std::result;
2222
use std::sync::atomic::{AtomicUsize, Ordering};
2323
use std::sync::RwLock;
2424
use std::time::Instant;
25-
use system_contract::SystemContract;
25+
use system_program::SystemProgram;
2626
use timing::{duration_as_us, timestamp};
2727
use transaction::Transaction;
2828
use window::WINDOW_SIZE;
@@ -36,14 +36,14 @@ pub struct Account {
3636
/// A transaction can write to its userdata
3737
pub userdata: Vec<u8>,
3838
/// contract id this contract belongs to
39-
pub contract_id: Pubkey,
39+
pub program_id: Pubkey,
4040
}
4141
impl Account {
42-
pub fn new(tokens: i64, space: usize, contract_id: Pubkey) -> Account {
42+
pub fn new(tokens: i64, space: usize, program_id: Pubkey) -> Account {
4343
Account {
4444
tokens,
4545
userdata: vec![0u8; space],
46-
contract_id,
46+
program_id,
4747
}
4848
}
4949
}
@@ -53,7 +53,7 @@ impl Default for Account {
5353
Account {
5454
tokens: 0,
5555
userdata: vec![],
56-
contract_id: SystemContract::id(),
56+
program_id: SystemProgram::id(),
5757
}
5858
}
5959
}
@@ -289,7 +289,7 @@ impl Bank {
289289
} else {
290290
error_counters.account_not_found_leader += 1;
291291
}
292-
if BudgetContract::check_id(&tx.contract_id) {
292+
if BudgetState::check_id(&tx.program_id) {
293293
use instruction::Instruction;
294294
if let Some(Instruction::NewVote(_vote)) = tx.instruction() {
295295
error_counters.account_not_found_vote += 1;
@@ -325,21 +325,21 @@ impl Bank {
325325

326326
pub fn verify_transaction(
327327
tx: &Transaction,
328-
pre_contract_id: &Pubkey,
328+
pre_program_id: &Pubkey,
329329
pre_tokens: i64,
330330
account: &Account,
331331
) -> Result<()> {
332332
// Verify the transaction
333-
// make sure that contract_id is still the same or this was just assigned by the system call contract
334-
if !((*pre_contract_id == account.contract_id)
335-
|| (SystemContract::check_id(&tx.contract_id)
336-
&& SystemContract::check_id(&pre_contract_id)))
333+
// make sure that program_id is still the same or this was just assigned by the system call contract
334+
if !((*pre_program_id == account.program_id)
335+
|| (SystemProgram::check_id(&tx.program_id)
336+
&& SystemProgram::check_id(&pre_program_id)))
337337
{
338338
//TODO, this maybe redundant bpf should be able to guarantee this property
339339
return Err(BankError::ModifiedContractId(tx.signature));
340340
}
341341
// For accounts unassigned to the contract, the individual balance of each accounts cannot decrease.
342-
if tx.contract_id != account.contract_id && pre_tokens > account.tokens {
342+
if tx.program_id != account.program_id && pre_tokens > account.tokens {
343343
return Err(BankError::ExternalAccountTokenSpend(tx.signature));
344344
}
345345
if account.tokens < 0 {
@@ -377,24 +377,24 @@ impl Bank {
377377
let pre_total: i64 = accounts.iter().map(|a| a.tokens).sum();
378378
let pre_data: Vec<_> = accounts
379379
.iter_mut()
380-
.map(|a| (a.contract_id, a.tokens))
380+
.map(|a| (a.program_id, a.tokens))
381381
.collect();
382382

383383
// Call the contract method
384384
// It's up to the contract to implement its own rules on moving funds
385385
if SystemContract::check_id(&tx.contract_id) {
386386
SystemContract::process_transaction(&tx, accounts, &self.loaded_contracts)
387-
} else if BudgetContract::check_id(&tx.contract_id) {
387+
} else if BudgetState::check_id(&tx.contract_id) {
388388
// TODO: the runtime should be checking read/write access to memory
389389
// we are trusting the hard coded contracts not to clobber or allocate
390-
BudgetContract::process_transaction(&tx, accounts)
390+
BudgetState::process_transaction(&tx, accounts)
391391
} else if self.loaded_contract(&tx, accounts) {
392392
} else {
393-
return Err(BankError::UnknownContractId(tx.contract_id));
393+
return Err(BankError::UnknownContractId(tx.program_id));
394394
}
395395
// Verify the transaction
396-
for ((pre_contract_id, pre_tokens), post_account) in pre_data.iter().zip(accounts.iter()) {
397-
Self::verify_transaction(&tx, pre_contract_id, *pre_tokens, post_account)?;
396+
for ((pre_program_id, pre_tokens), post_account) in pre_data.iter().zip(accounts.iter()) {
397+
Self::verify_transaction(&tx, pre_program_id, *pre_tokens, post_account)?;
398398
}
399399
// The total sum of all the tokens in all the pages cannot change.
400400
let post_total: i64 = accounts.iter().map(|a| a.tokens).sum();
@@ -590,9 +590,9 @@ impl Bank {
590590
.expect("invalid ledger: need at least 2 entries");
591591
{
592592
let tx = &entry1.transactions[0];
593-
assert!(SystemContract::check_id(&tx.contract_id), "Invalid ledger");
594-
let instruction: SystemContract = deserialize(&tx.userdata).unwrap();
595-
let deposit = if let SystemContract::Move { tokens } = instruction {
593+
assert!(SystemProgram::check_id(&tx.program_id), "Invalid ledger");
594+
let instruction: SystemProgram = deserialize(&tx.userdata).unwrap();
595+
let deposit = if let SystemProgram::Move { tokens } = instruction {
596596
Some(tokens)
597597
} else {
598598
None
@@ -637,10 +637,10 @@ impl Bank {
637637
}
638638

639639
pub fn read_balance(account: &Account) -> i64 {
640-
if SystemContract::check_id(&account.contract_id) {
641-
SystemContract::get_balance(account)
642-
} else if BudgetContract::check_id(&account.contract_id) {
643-
BudgetContract::get_balance(account)
640+
if SystemProgram::check_id(&account.program_id) {
641+
SystemProgram::get_balance(account)
642+
} else if BudgetState::check_id(&account.program_id) {
643+
BudgetState::get_balance(account)
644644
} else {
645645
account.tokens
646646
}

0 commit comments

Comments
 (0)