Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build warnings + clippy errors from latest nightly #686

Merged
merged 11 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ fuzz-tests:
<<: *docker-env
variables:
# The QUICKCHECK_TESTS default is 100
QUICKCHECK_TESTS: 50000
QUICKCHECK_TESTS: 40000
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
Expand Down
3 changes: 3 additions & 0 deletions crates/env/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ blake2 = { version = "0.9", optional = true }
rand = { version = "0.8", default-features = false, features = ["alloc"], optional = true }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[features]
default = ["std"]
std = [
Expand Down
12 changes: 6 additions & 6 deletions crates/env/src/chain_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ where
self.func_id,
input,
ErrorCode::from_status_code,
|output| scale::Decode::decode(&mut &output[..]).map_err(Into::into),
|mut output| scale::Decode::decode(&mut output).map_err(Into::into),
)
})
}
Expand Down Expand Up @@ -323,7 +323,7 @@ where
self.func_id,
input,
|_status_code| Ok(()),
|output| scale::Decode::decode(&mut &output[..]).map_err(Into::into),
|mut output| scale::Decode::decode(&mut output).map_err(Into::into),
)
})
}
Expand Down Expand Up @@ -380,8 +380,8 @@ where
self.func_id,
input,
ErrorCode::from_status_code,
|output| {
let decoded = <O as scale::Decode>::decode(&mut &output[..])
|mut output| {
let decoded = <O as scale::Decode>::decode(&mut output)
.expect("encountered error while decoding chain extension method call return value");
Ok(decoded)
},
Expand Down Expand Up @@ -429,8 +429,8 @@ where
self.func_id,
input,
|_status_code| Ok(()),
|output| {
let decoded = <O as scale::Decode>::decode(&mut &output[..])
|mut output| {
let decoded = <O as scale::Decode>::decode(&mut output)
.expect("encountered error while decoding chain extension method call return value");
Ok(decoded)
},
Expand Down
6 changes: 3 additions & 3 deletions crates/env/src/engine/off_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ impl EnvBackend for EnvInstance {
D: FnOnce(&[u8]) -> ::core::result::Result<T, E>,
{
let encoded_input = input.encode();
let (status_code, output) = self
let (status_code, mut output) = self
.chain_extension_handler
.eval(func_id, &encoded_input)
.expect("encountered unexpected missing chain extension method");
status_to_result(status_code)?;
let decoded = decode_to_result(&mut &output[..])?;
let decoded = decode_to_result(&mut output)?;
Ok(decoded)
}
}
Expand Down Expand Up @@ -277,7 +277,7 @@ impl EnvInstance {
beneficiary,
transferred: all,
};
panic!(scale::Encode::encode(&res));
panic!("{:?}", scale::Encode::encode(&res));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this actually should be converted into an unimplemented! with a proper message stating why it is still unimeplemented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so I'm not sure.

I mean, even if we implement setting a tombstone, clearing storage, etc. we would still like to return the result of the contract eviction and it seems that panic! is the right way to go.

From my pov your suggestion would just be a semantic change of having something like unimplemented!("we have not yet implemented everything, but anyway here's the result: …") instead and changing that back to panic!(…) once we have implemented it would then be a breaking change.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well hopefully this discussion is not needed soon due to the works on the upcoming off-chain environment. :P But since contract termination is not really properly implemented in the current off-chain environment I would not dare to actually just mark it as unimplemented. But yeah let's keep it as it is for now.

}
}

Expand Down
14 changes: 11 additions & 3 deletions crates/env/src/engine/off_chain/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use crate::{
Result,
};
use ink_prelude::string::String;
use std::str::FromStr;

/// Pushes a contract execution context.
///
Expand Down Expand Up @@ -420,11 +421,18 @@ pub fn assert_contract_termination<T, F>(
{
let value_any = ::std::panic::catch_unwind(should_terminate)
.expect_err("contract did not terminate");
let encoded_input: &Vec<u8> = value_any
.downcast_ref::<Vec<u8>>()
let encoded_input = value_any
.downcast_ref::<String>()
.expect("panic object can not be cast");
let deserialized_vec = encoded_input
.replace("[", "")
.replace("]", "")
.split(", ")
.map(|s| u8::from_str(s).expect("u8 cannot be extracted from str"))
.collect::<Vec<u8>>();
Copy link
Collaborator Author

@cmichi cmichi Feb 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike this hacky way of deserializing, but AFAIK it's the simplest way of getting the inverse of a panic!("{:?}", Vec<u8>). We can get rid of this as soon as panic_any is stablized, which should be with the next stable release soonish.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create an issue for that so that we do not forget?

let res: ContractTerminationResult<T> =
scale::Decode::decode(&mut &encoded_input[..]).expect("input can not be decoded");
scale::Decode::decode(&mut &deserialized_vec[..])
.expect("input can not be decoded");

assert_eq!(res.beneficiary, expected_beneficiary);
assert_eq!(res.transferred, expected_balance);
Expand Down
3 changes: 3 additions & 0 deletions crates/lang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ scale = { package = "parity-scale-codec", version = "2.0", default-features = fa
derive_more = { version = "0.99", default-features = false, features = ["from"] }
static_assertions = "1.1"

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[features]
default = ["std"]
std = [
Expand Down
3 changes: 3 additions & 0 deletions crates/lang/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ heck = "0.3.1"
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive", "full"] }
impl-serde = "0.3.1"

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[features]
default = ["std"]
std = [
Expand Down
3 changes: 3 additions & 0 deletions crates/lang/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ scale = { package = "parity-scale-codec", version = "2.0", default-features = fa
syn = "1"
proc-macro2 = "1"

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[dev-dependencies]
ink_metadata = { version = "3.0.0-rc2", path = "../../metadata/" }
ink_env = { version = "3.0.0-rc2", path = "../../env/" }
Expand Down
3 changes: 3 additions & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ ink_prelude = { version = "3.0.0-rc2", path = "../prelude/", default-features =
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive", "full"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[dev-dependencies]
criterion = "0.3.1"

Expand Down
3 changes: 3 additions & 0 deletions crates/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ array-init = { version = "1.0", default-features = false, features = ["const-gen
# We haven't found a better solution yet.
criterion = { version = "0.3", optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[dev-dependencies]
quickcheck = "1.0"
quickcheck_macros = "1.0"
Expand Down
2 changes: 2 additions & 0 deletions examples/contract-terminate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ink_lang = { version = "3.0.0-rc1", path = "../../crates/lang", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "contract_terminate"
Expand Down
2 changes: 2 additions & 0 deletions examples/contract-transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ink_lang = { version = "3.0.0-rc1", path = "../../crates/lang", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "contract_transfer"
Expand Down
3 changes: 3 additions & 0 deletions examples/delegator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ subber = { version = "3.0.0-rc2", path = "subber", default-features = false, fea
accumulator = { version = "3.0.0-rc2", path = "accumulator", default-features = false, features = ["ink-as-dependency"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "delegator"
path = "lib.rs"
Expand Down
2 changes: 2 additions & 0 deletions examples/delegator/accumulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ink_lang = { version = "3.0.0-rc2", path = "../../../crates/lang", default-featu
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "accumulator"
Expand Down
2 changes: 2 additions & 0 deletions examples/delegator/adder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ accumulator = { version = "3.0.0-rc2", path = "../accumulator", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "adder"
Expand Down
2 changes: 2 additions & 0 deletions examples/delegator/subber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ accumulator = { version = "3.0.0-rc2", path = "../accumulator", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "subber"
Expand Down
2 changes: 2 additions & 0 deletions examples/dns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ink_lang = { version = "3.0.0-rc2", path = "../../crates/lang", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "dns"
Expand Down
2 changes: 2 additions & 0 deletions examples/erc20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ink_lang = { version = "3.0.0-rc2", path = "../../crates/lang", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "erc20"
Expand Down
2 changes: 2 additions & 0 deletions examples/erc721/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ink_lang = { version = "3.0.0-rc2", path = "../../crates/lang", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "erc721"
Expand Down
2 changes: 2 additions & 0 deletions examples/flipper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ink_lang = { version = "3.0.0-rc2", path = "../../crates/lang", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "flipper"
Expand Down
2 changes: 2 additions & 0 deletions examples/incrementer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ink_lang = { version = "3.0.0-rc2", path = "../../crates/lang", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "incrementer"
Expand Down
2 changes: 2 additions & 0 deletions examples/multisig_plain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ ink_prelude = { version = "3.0.0-rc2", path = "../../crates/prelude", default-fe
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "multisig_plain"
Expand Down
3 changes: 3 additions & 0 deletions examples/rand-extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ ink_lang = { path = "../../crates/lang", default-features = false }
scale = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "rand_extension"
path = "lib.rs"
Expand Down
2 changes: 2 additions & 0 deletions examples/trait-erc20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ink_lang = { version = "3.0.0-rc2", path = "../../crates/lang", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "erc20"
Expand Down
3 changes: 3 additions & 0 deletions examples/trait-flipper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ ink_lang = { version = "3.0.0-rc2", path = "../../crates/lang", default-features
scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive"] }
scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }

# Should be removed once bitvecto-rs/bitvec#105 is resolved
funty = "=1.1.0"

[lib]
name = "flipper"
path = "lib.rs"
Expand Down