Skip to content

Commit

Permalink
Upgrade to Rust 1.31.0 (solana-labs#2052)
Browse files Browse the repository at this point in the history
* Upgrade to Rust 1.31.0
* Upgrade nightly
* Fix all clippy warnings
* Revert relaxed version check and update
  • Loading branch information
garious authored Dec 8, 2018
1 parent 2bad658 commit 0a83b17
Show file tree
Hide file tree
Showing 70 changed files with 487 additions and 298 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Rust coding conventions
* All Rust code is linted with Clippy. If you'd prefer to ignore its advice, do so explicitly:

```rust
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[allow(clippy::too_many_arguments)]
```

Note: Clippy defaults can be overridden in the top-level file `.clippy.toml`.
Expand Down
3 changes: 2 additions & 1 deletion benches/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ fn bench_process_transaction(bencher: &mut Bencher) {

// Finally, return the transaction to the benchmark.
tx
}).collect();
})
.collect();

let mut id = bank.last_id();

Expand Down
12 changes: 8 additions & 4 deletions benches/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {
new.account_keys[1] = Pubkey::new(&to[0..32]);
new.signatures = vec![Signature::new(&sig[0..64])];
new
}).collect();
})
.collect();
// fund all the accounts
transactions.iter().for_each(|tx| {
let fund = Transaction::system_move(
Expand Down Expand Up @@ -98,7 +99,8 @@ fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {
.map(|x| {
let len = x.read().unwrap().packets.len();
(x, iter::repeat(1).take(len).collect())
}).collect();
})
.collect();
let (_stage, signal_receiver) = BankingStage::new(
&bank,
verified_receiver,
Expand Down Expand Up @@ -170,7 +172,8 @@ fn bench_banking_stage_multi_programs(bencher: &mut Bencher) {
assert_eq!(new.instructions.len(), progs);
new.signatures = vec![Signature::new(&sig[0..64])];
new
}).collect();
})
.collect();
transactions.iter().for_each(|tx| {
let fund = Transaction::system_move(
&mint.keypair(),
Expand Down Expand Up @@ -198,7 +201,8 @@ fn bench_banking_stage_multi_programs(bencher: &mut Bencher) {
.map(|x| {
let len = x.read().unwrap().packets.len();
(x, iter::repeat(1).take(len).collect())
}).collect();
})
.collect();
let (_stage, signal_receiver) = BankingStage::new(
&bank,
verified_receiver,
Expand Down
6 changes: 3 additions & 3 deletions ci/buildkite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ steps:
- command: "ci/shellcheck.sh"
name: "shellcheck [public]"
timeout_in_minutes: 20
- command: "ci/docker-run.sh solanalabs/rust:1.30.1 ci/test-checks.sh"
- command: "ci/docker-run.sh solanalabs/rust:1.31.0 ci/test-checks.sh"
name: "checks [public]"
env:
CARGO_TARGET_CACHE_NAME: "checks"
Expand All @@ -20,12 +20,12 @@ steps:
env:
CARGO_TARGET_CACHE_NAME: "nightly"
timeout_in_minutes: 30
- command: "ci/docker-run.sh solanalabs/rust:1.30.1 ci/test-stable.sh"
- command: "ci/docker-run.sh solanalabs/rust:1.31.0 ci/test-stable.sh"
name: "stable [public]"
env:
CARGO_TARGET_CACHE_NAME: "stable"
timeout_in_minutes: 30
- command: "ci/docker-run.sh solanalabs/rust-nightly:2018-11-12 ci/test-nightly.sh"
- command: "ci/docker-run.sh solanalabs/rust-nightly:2018-12-05 ci/test-nightly.sh"
name: "nightly [public]"
env:
CARGO_TARGET_CACHE_NAME: "nightly"
Expand Down
6 changes: 3 additions & 3 deletions ci/docker-rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Note: when the rust version is changed also modify
# ci/buildkite.yml to pick up the new image tag
FROM rust:1.30.1
FROM rust:1.31.0

RUN set -x && \
apt update && \
Expand All @@ -20,8 +20,8 @@ RUN set -x && \
rsync \
sudo \
&& \
rustup component add rustfmt-preview && \
rustup component add clippy-preview && \
rustup component add rustfmt && \
rustup component add clippy && \
rm -rf /var/lib/apt/lists/* && \
rustc --version && \
cargo --version
4 changes: 2 additions & 2 deletions ci/version-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ nightly)
require cargo 1.32.[0-9]+-nightly
;;
stable)
require rustc 1.3[01].[0-9]+
require cargo 1.3[01].[0-9]+
require rustc 1.31.[0-9]+
require cargo 1.31.[0-9]+
;;
*)
echo Error: unknown argument: "$1"
Expand Down
12 changes: 8 additions & 4 deletions drone/src/bin/drone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@ fn main() -> Result<(), Box<error::Error>> {
.takes_value(true)
.required(true)
.help("File from which to read the mint's keypair"),
).arg(
)
.arg(
Arg::with_name("slice")
.long("slice")
.value_name("SECS")
.takes_value(true)
.help("Time slice over which to limit requests to drone"),
).arg(
)
.arg(
Arg::with_name("cap")
.long("cap")
.value_name("NUM")
.takes_value(true)
.help("Request limit for time slice"),
).get_matches();
)
.get_matches();

let mint_keypair =
read_keypair(matches.value_of("keypair").unwrap()).expect("failed to read client keypair");
Expand Down Expand Up @@ -139,7 +142,8 @@ fn main() -> Result<(), Box<error::Error>> {
io::ErrorKind::Other,
format!("Drone response: {:?}", err),
))
})).then(|_| Ok(()));
}))
.then(|_| Ok(()));
tokio::spawn(server)
});
tokio::run(done);
Expand Down
6 changes: 4 additions & 2 deletions drone/src/drone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ impl Drone {
.add_field(
"request_current",
influxdb::Value::Integer(self.request_current as i64),
).to_owned(),
)
.to_owned(),
);

info!("Requesting airdrop of {} to {:?}", tokens, to);
Expand Down Expand Up @@ -283,7 +284,8 @@ pub fn run_local_drone(mint_keypair: Keypair, sender: Sender<SocketAddr>) {
io::ErrorKind::Other,
format!("Drone response: {:?}", err),
))
})).then(|_| Ok(()));
}))
.then(|_| Ok(()));
tokio::spawn(server)
});
tokio::run(done);
Expand Down
12 changes: 8 additions & 4 deletions metrics/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,15 @@ pub fn set_panic_hook(program: &'static str) {
// TODO: use ono.message() when it becomes stable
ono.to_string(),
),
).add_field(
)
.add_field(
"location",
influxdb::Value::String(match ono.location() {
Some(location) => location.to_string(),
None => "?".to_string(),
}),
).add_field("host_id", influxdb::Value::Integer(*HOST_ID))
)
.add_field("host_id", influxdb::Value::Integer(*HOST_ID))
.to_owned(),
);
// Flush metrics immediately in case the process exits immediately
Expand Down Expand Up @@ -359,10 +361,12 @@ mod test {
.add_field(
"random_bool",
influxdb::Value::Boolean(random::<u8>() < 128),
).add_field(
)
.add_field(
"random_int",
influxdb::Value::Integer(random::<u8>() as i64),
).to_owned();
)
.to_owned();
agent.submit(point);
}

Expand Down
3 changes: 2 additions & 1 deletion programs/native/budget/src/budget_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ mod test {
let index = index as usize;
let key = &tx.account_keys[index];
(key, index < tx.signatures.len())
}).zip(program_accounts.iter_mut())
})
.zip(program_accounts.iter_mut())
.map(|((key, is_signer), account)| KeyedAccount::new(key, is_signer, account))
.collect();

Expand Down
5 changes: 3 additions & 2 deletions programs/native/erc20/src/token_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Default for TokenProgram {
}

impl TokenProgram {
#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))]
#[allow(clippy::needless_pass_by_value)]
fn map_to_invalid_args(err: std::boxed::Box<bincode::ErrorKind>) -> Error {
warn!("invalid argument: {:?}", err);
Error::InvalidArgument
Expand Down Expand Up @@ -424,7 +424,8 @@ impl TokenProgram {
} else {
TokenProgram::Invalid
}
}).collect();
})
.collect();

for program_account in &input_program_accounts {
info!("input_program_account: userdata={:?}", program_account);
Expand Down
9 changes: 6 additions & 3 deletions programs/native/lua_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ mod tests {
local tokens, _ = string.unpack("I", data)
accounts[1].tokens = accounts[1].tokens - tokens
accounts[2].tokens = accounts[2].tokens + tokens
"#.as_bytes()
"#
.as_bytes()
.to_vec();

let alice_pubkey = Pubkey::default();
Expand Down Expand Up @@ -214,7 +215,8 @@ mod tests {
let userdata = r#"
local serialize = load(accounts[2].userdata)().serialize
accounts[3].userdata = serialize({a=1, b=2, c=3}, nil, "s")
"#.as_bytes()
"#
.as_bytes()
.to_vec();
let owner = Pubkey::default();
let program_account = Account {
Expand Down Expand Up @@ -295,7 +297,8 @@ mod tests {
let data = format!(
r#"{{m=2, n={{"{}","{}","{}"}}, tokens=100}}"#,
carol_pubkey, dan_pubkey, erin_pubkey
).as_bytes()
)
.as_bytes()
.to_vec();

process(&owner, &mut keyed_accounts, &data, 0).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ pub struct Hasher {
}

impl Hasher {
pub fn hash(&mut self, val: &[u8]) -> () {
pub fn hash(&mut self, val: &[u8]) {
self.hasher.input(val);
}
pub fn hashv(&mut self, vals: &[&[u8]]) -> () {
pub fn hashv(&mut self, vals: &[&[u8]]) {
for val in vals {
self.hash(val);
}
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/system_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ impl SystemTransaction for Transaction {
.map(|(i, (_, amount))| {
let spend = SystemInstruction::Move { tokens: *amount };
Instruction::new(0, &spend, vec![0, i as u8 + 1])
}).collect();
})
.collect();
let to_keys: Vec<_> = moves.iter().map(|(to_key, _)| *to_key).collect();

Transaction::new_with_instructions(
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ mod tests {
14, 229, 239, 119, 93, 5, 218, 161, 35, 3, 33, 0, 36, 100, 158, 252, 33, 161, 97, 185,
62, 89, 99, 195, 250, 249, 187, 189, 171, 118, 241, 90, 248, 14, 68, 219, 231, 62, 157,
5, 142, 27, 210, 117,
])).expect("fu");
]))
.unwrap();
let to = Pubkey::new(&[
1, 1, 1, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 6, 5, 4,
1, 1, 1,
Expand Down
Loading

0 comments on commit 0a83b17

Please sign in to comment.