mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 19:51:05 +00:00
Weight v1.5: Opaque Struct (#12138)
* initial idea * update frame_support * update a bunch more * add ord * adjust RuntimeDbWeight * frame_system builds * re-export * frame_support tests pass * frame_executive compile * frame_executive builds * frame_system tests passing * pallet-utility tests pass * fix a bunch of pallets * more * phragmen * state-trie-migration * scheduler and referenda * pallet-election-provider-multi-phase * aura * staking * more * babe * balances * bunch more * sudo * transaction-payment * asset-tx-payment * last pallets * fix alliance merge * fix node template runtime * fix pallet-contracts cc @athei * fix node runtime * fix compile on runtime-benchmarks feature * comment * fix frame-support-test * fix more tests * weight regex * frame system works * fix a bunch * more * more * more * more * more * more fixes * update templates * fix contracts benchmarks * Update lib.rs * Update lib.rs * fix ui * make scalar saturating mul const * more const functions * scalar div * refactor using constant functions * move impl * fix overhead template * use compactas * Update lib.rs
This commit is contained in:
@@ -664,7 +664,7 @@ where
|
||||
debug_message: Option<&'a mut Vec<u8>>,
|
||||
) -> Result<(Self, E), ExecError> {
|
||||
let (first_frame, executable, nonce) =
|
||||
Self::new_frame(args, value, gas_meter, storage_meter, 0, schedule)?;
|
||||
Self::new_frame(args, value, gas_meter, storage_meter, Weight::zero(), schedule)?;
|
||||
let stack = Self {
|
||||
origin,
|
||||
schedule,
|
||||
@@ -1089,7 +1089,7 @@ where
|
||||
delegated_call: Some(DelegatedCall { executable, caller: self.caller().clone() }),
|
||||
},
|
||||
value,
|
||||
0,
|
||||
Weight::zero(),
|
||||
)?;
|
||||
self.run(executable, input_data)
|
||||
}
|
||||
@@ -1825,7 +1825,7 @@ mod tests {
|
||||
let value = Default::default();
|
||||
let recurse_ch = MockLoader::insert(Call, |ctx, _| {
|
||||
// Try to call into yourself.
|
||||
let r = ctx.ext.call(0, BOB, 0, vec![], true);
|
||||
let r = ctx.ext.call(Weight::zero(), BOB, 0, vec![], true);
|
||||
|
||||
REACHED_BOTTOM.with(|reached_bottom| {
|
||||
let mut reached_bottom = reached_bottom.borrow_mut();
|
||||
@@ -1880,7 +1880,7 @@ mod tests {
|
||||
.with(|caller| *caller.borrow_mut() = Some(ctx.ext.caller().clone()));
|
||||
|
||||
// Call into CHARLIE contract.
|
||||
assert_matches!(ctx.ext.call(0, CHARLIE, 0, vec![], true), Ok(_));
|
||||
assert_matches!(ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], true), Ok(_));
|
||||
exec_success()
|
||||
});
|
||||
let charlie_ch = MockLoader::insert(Call, |ctx, _| {
|
||||
@@ -2011,7 +2011,7 @@ mod tests {
|
||||
// ALICE is the origin of the call stack
|
||||
assert!(ctx.ext.caller_is_origin());
|
||||
// BOB calls CHARLIE
|
||||
ctx.ext.call(0, CHARLIE, 0, vec![], true)
|
||||
ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], true)
|
||||
});
|
||||
|
||||
ExtBuilder::default().build().execute_with(|| {
|
||||
@@ -2041,7 +2041,7 @@ mod tests {
|
||||
assert_eq!(*ctx.ext.address(), BOB);
|
||||
|
||||
// Call into charlie contract.
|
||||
assert_matches!(ctx.ext.call(0, CHARLIE, 0, vec![], true), Ok(_));
|
||||
assert_matches!(ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], true), Ok(_));
|
||||
exec_success()
|
||||
});
|
||||
let charlie_ch = MockLoader::insert(Call, |ctx, _| {
|
||||
@@ -2190,7 +2190,7 @@ mod tests {
|
||||
let (address, output) = ctx
|
||||
.ext
|
||||
.instantiate(
|
||||
0,
|
||||
Weight::zero(),
|
||||
dummy_ch,
|
||||
<Test as Config>::Currency::minimum_balance(),
|
||||
vec![],
|
||||
@@ -2250,7 +2250,7 @@ mod tests {
|
||||
// Instantiate a contract and save it's address in `instantiated_contract_address`.
|
||||
assert_matches!(
|
||||
ctx.ext.instantiate(
|
||||
0,
|
||||
Weight::zero(),
|
||||
dummy_ch,
|
||||
<Test as Config>::Currency::minimum_balance(),
|
||||
vec![],
|
||||
@@ -2342,13 +2342,13 @@ mod tests {
|
||||
let info = ctx.ext.contract_info();
|
||||
assert_eq!(info.storage_deposit, 0);
|
||||
info.storage_deposit = 42;
|
||||
assert_eq!(ctx.ext.call(0, CHARLIE, 0, vec![], true), exec_trapped());
|
||||
assert_eq!(ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], true), exec_trapped());
|
||||
assert_eq!(ctx.ext.contract_info().storage_deposit, 42);
|
||||
}
|
||||
exec_success()
|
||||
});
|
||||
let code_charlie = MockLoader::insert(Call, |ctx, _| {
|
||||
assert!(ctx.ext.call(0, BOB, 0, vec![99], true).is_ok());
|
||||
assert!(ctx.ext.call(Weight::zero(), BOB, 0, vec![99], true).is_ok());
|
||||
exec_trapped()
|
||||
});
|
||||
|
||||
@@ -2377,7 +2377,7 @@ mod tests {
|
||||
fn recursive_call_during_constructor_fails() {
|
||||
let code = MockLoader::insert(Constructor, |ctx, _| {
|
||||
assert_matches!(
|
||||
ctx.ext.call(0, ctx.ext.address().clone(), 0, vec![], true),
|
||||
ctx.ext.call(Weight::zero(), ctx.ext.address().clone(), 0, vec![], true),
|
||||
Err(ExecError{error, ..}) if error == <Error<Test>>::ContractNotFound.into()
|
||||
);
|
||||
exec_success()
|
||||
@@ -2479,7 +2479,7 @@ mod tests {
|
||||
// call the contract passed as input with disabled reentry
|
||||
let code_bob = MockLoader::insert(Call, |ctx, _| {
|
||||
let dest = Decode::decode(&mut ctx.input_data.as_ref()).unwrap();
|
||||
ctx.ext.call(0, dest, 0, vec![], false)
|
||||
ctx.ext.call(Weight::zero(), dest, 0, vec![], false)
|
||||
});
|
||||
|
||||
let code_charlie = MockLoader::insert(Call, |_, _| exec_success());
|
||||
@@ -2524,7 +2524,7 @@ mod tests {
|
||||
fn call_deny_reentry() {
|
||||
let code_bob = MockLoader::insert(Call, |ctx, _| {
|
||||
if ctx.input_data[0] == 0 {
|
||||
ctx.ext.call(0, CHARLIE, 0, vec![], false)
|
||||
ctx.ext.call(Weight::zero(), CHARLIE, 0, vec![], false)
|
||||
} else {
|
||||
exec_success()
|
||||
}
|
||||
@@ -2532,7 +2532,7 @@ mod tests {
|
||||
|
||||
// call BOB with input set to '1'
|
||||
let code_charlie =
|
||||
MockLoader::insert(Call, |ctx, _| ctx.ext.call(0, BOB, 0, vec![1], true));
|
||||
MockLoader::insert(Call, |ctx, _| ctx.ext.call(Weight::zero(), BOB, 0, vec![1], true));
|
||||
|
||||
ExtBuilder::default().build().execute_with(|| {
|
||||
let schedule = <Test as Config>::Schedule::get();
|
||||
@@ -2695,18 +2695,30 @@ mod tests {
|
||||
let success_code = MockLoader::insert(Constructor, |_, _| exec_success());
|
||||
let succ_fail_code = MockLoader::insert(Constructor, move |ctx, _| {
|
||||
ctx.ext
|
||||
.instantiate(0, fail_code, ctx.ext.minimum_balance() * 100, vec![], &[])
|
||||
.instantiate(
|
||||
Weight::zero(),
|
||||
fail_code,
|
||||
ctx.ext.minimum_balance() * 100,
|
||||
vec![],
|
||||
&[],
|
||||
)
|
||||
.ok();
|
||||
exec_success()
|
||||
});
|
||||
let succ_succ_code = MockLoader::insert(Constructor, move |ctx, _| {
|
||||
let (account_id, _) = ctx
|
||||
.ext
|
||||
.instantiate(0, success_code, ctx.ext.minimum_balance() * 100, vec![], &[])
|
||||
.instantiate(
|
||||
Weight::zero(),
|
||||
success_code,
|
||||
ctx.ext.minimum_balance() * 100,
|
||||
vec![],
|
||||
&[],
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// a plain call should not influence the account counter
|
||||
ctx.ext.call(0, account_id, 0, vec![], false).unwrap();
|
||||
ctx.ext.call(Weight::zero(), account_id, 0, vec![], false).unwrap();
|
||||
|
||||
exec_success()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user