-
Notifications
You must be signed in to change notification settings - Fork 443
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
Temporarily add Determinism
enum from pallet-contracts
#1547
Changes from all commits
db7059d
9ca8f53
fb0eba6
b80419a
056a352
18b8b02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,11 +75,32 @@ pub struct Call<E: Environment, B> { | |
data: Vec<u8>, | ||
} | ||
|
||
#[derive( | ||
Debug, Clone, Copy, scale::Encode, scale::Decode, PartialEq, Eq, serde::Serialize, | ||
)] | ||
pub enum Determinism { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing docs |
||
/// The execution should be deterministic and hence no indeterministic instructions are | ||
/// allowed. | ||
/// | ||
/// Dispatchables always use this mode in order to make on-chain execution deterministic. | ||
Deterministic, | ||
/// Allow calling or uploading an indeterministic code. | ||
/// | ||
/// This is only possible when calling into `pallet-contracts` directly via | ||
/// [`crate::Pallet::bare_call`]. | ||
/// | ||
/// # Note | ||
/// | ||
/// **Never** use this mode for on-chain execution. | ||
AllowIndeterminism, | ||
} | ||
|
||
/// A raw call to `pallet-contracts`'s `upload`. | ||
#[derive(Debug, scale::Encode, scale::Decode)] | ||
pub struct UploadCode<B> { | ||
code: Vec<u8>, | ||
storage_deposit_limit: Option<B>, | ||
determinism: Determinism, | ||
} | ||
|
||
/// A struct that encodes RPC parameters required to instantiate a new smart contract. | ||
|
@@ -105,6 +126,7 @@ where | |
origin: C::AccountId, | ||
code: Vec<u8>, | ||
storage_deposit_limit: Option<E::Balance>, | ||
determinism: Determinism, | ||
} | ||
|
||
/// A struct that encodes RPC parameters required for a call to a smart contract. | ||
|
@@ -278,6 +300,7 @@ where | |
origin: signer.account_id().clone(), | ||
code, | ||
storage_deposit_limit, | ||
determinism: Determinism::Deterministic, | ||
}; | ||
let func = "ContractsApi_upload_code"; | ||
let params = rpc_params![func, Bytes(scale::Encode::encode(&call_request))]; | ||
|
@@ -308,6 +331,7 @@ where | |
UploadCode::<E::Balance> { | ||
code, | ||
storage_deposit_limit, | ||
determinism: Determinism::Deterministic, | ||
}, | ||
Default::default(), | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
error[E0201]: duplicate definitions with name `message_checked`: | ||
error[E0592]: duplicate definitions with name `message_checked` | ||
--> tests/ui/contract/fail/message-hygiene-checked.rs:16:9 | ||
| | ||
1 | #[ink::contract] | ||
| ---------------- previous definition of `message_checked` here | ||
| ---------------- other definition for `message_checked` | ||
... | ||
16 | pub fn message_checked(&self) {} | ||
| ^^^ duplicate definition | ||
| ^^^ duplicate definitions for `message_checked` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ pub mod flipper { | |
|
||
/// Creates a new flipper smart contract initialized to `false`. | ||
#[ink(constructor)] | ||
pub fn default() -> Self { | ||
pub fn new_default() -> Self { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New clippy lints do not allow methods with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this lint's been around a very long time, why is it only being triggered now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Can you open a follow up issue for this please? |
||
Self::new(Default::default()) | ||
} | ||
|
||
|
@@ -39,7 +39,7 @@ pub mod flipper { | |
|
||
#[ink::test] | ||
fn default_works() { | ||
let flipper = Flipper::default(); | ||
let flipper = Flipper::new_default(); | ||
assert!(!flipper.get()); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should've been rolled back before merging