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

refactor: Billing refactor #992

Merged
merged 83 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
b5538c3
refactor: remove-is-next-author
sameh-farouk Jul 18, 2024
5c2acbd
initial balance lock fix
sameh-farouk Jul 19, 2024
4754d5a
temp changes to decide later
sameh-farouk Jul 24, 2024
d8737af
wip
sameh-farouk Jul 28, 2024
36b7984
refactor-billing-logic
sameh-farouk Jul 30, 2024
150f006
handle grace for node contracts under rent-contract
sameh-farouk Jul 30, 2024
dc2a341
fix tests
sameh-farouk Jul 30, 2024
bd2331d
Adjust other tests
sameh-farouk Jul 31, 2024
2094436
fix benchmarks
sameh-farouk Jul 31, 2024
2274df4
claen up the code a bit
sameh-farouk Aug 1, 2024
ded7466
Fix cost of certified capacity
sameh-farouk Aug 2, 2024
47f1b72
Adjust benchmarking
sameh-farouk Aug 2, 2024
14cd8ed
clean comments
sameh-farouk Aug 2, 2024
3dcc930
define a custom SignedExtension for bill_contract_for_block
sameh-farouk Aug 13, 2024
77b3b4a
Adjusting some logs
sameh-farouk Aug 13, 2024
6564009
Adjust logs
sameh-farouk Aug 13, 2024
f5acea5
Add new billing events to go client
sameh-farouk Aug 13, 2024
7d03ead
Add comments
sameh-farouk Aug 14, 2024
6d60e78
fmt: format code
sameh-farouk Aug 14, 2024
a94a7da
Update comment
sameh-farouk Aug 14, 2024
38842d6
chore: update benchmark `weights.rs` file for all pallets
github-actions[bot] Aug 14, 2024
b237b6b
Fix typo
sameh-farouk Aug 15, 2024
4422f08
Extract is_validator into a function
sameh-farouk Aug 15, 2024
7de554d
Merge branch 'development-contracts-billing-refactor' of https://gith…
sameh-farouk Aug 15, 2024
a64f5b7
Change partial_billed_amount to partially_billed_amount
sameh-farouk Aug 15, 2024
0c3f136
fix govet linter
sameh-farouk Aug 15, 2024
cb10db5
fix typo
sameh-farouk Aug 18, 2024
348cfb9
fix typos
sameh-farouk Aug 18, 2024
72d2202
Correct naming convention for ContractPaymentState API
sameh-farouk Aug 18, 2024
44279ff
change ContractPaymentOverdrawn event's field name
sameh-farouk Aug 18, 2024
f8a2073
fix json in contract_events
sameh-farouk Aug 18, 2024
2180827
make ContractPaymentOverdrawn.overdraft represnt new overdrawn amount…
sameh-farouk Aug 18, 2024
4b2d2b0
change transfer_reserved to fail if cant repatriate reserved
sameh-farouk Aug 18, 2024
09cbdd7
Add new ADR
sameh-farouk Aug 18, 2024
e07e8cd
adding unit tests for ContractPaymentState methods
sameh-farouk Aug 18, 2024
f082a8c
fix integration tests
sameh-farouk Aug 18, 2024
927a599
fix ADR formating
sameh-farouk Aug 18, 2024
56a970e
rename has_reserved_amount() to has_reserve()
sameh-farouk Aug 18, 2024
a1af14a
Hardening transfer_reserved
sameh-farouk Aug 18, 2024
ebd6471
Adjsut tests for transfer_reserved changes (slash and deposit events)
sameh-farouk Aug 18, 2024
e200715
Fix cycles count
sameh-farouk Aug 18, 2024
544cbf1
rename some tests
sameh-farouk Aug 18, 2024
d824e59
Add more cases to test_settle_partial_overdraft untit test
sameh-farouk Aug 19, 2024
ba1d0aa
Use EXISTENTIAL_DEPOSIT const inplace of the value
sameh-farouk Aug 19, 2024
6b58587
rename get_reserved to get_reserve
sameh-farouk Aug 19, 2024
8032c96
Use EXISTENTIAL_DEPOSIT const inplace of the value
sameh-farouk Aug 19, 2024
af76619
Optimize transfer_reserved to reduce overhead and improve efficiency
sameh-farouk Aug 20, 2024
7cb0e3e
Add a test to verify that unbilled NU usage is reset when billing a c…
sameh-farouk Aug 20, 2024
0276f86
fix typo
sameh-farouk Aug 20, 2024
74c42bb
update validate_distribution_rewards and resduce duplicated code in t…
sameh-farouk Aug 20, 2024
2d9d644
Remove duplicated code
sameh-farouk Aug 20, 2024
09867df
write payment_state to storage early during migration
sameh-farouk Aug 21, 2024
2af204e
Add new tests and remove obsolete ones
sameh-farouk Aug 21, 2024
154b10f
Write contract payment state to storage during migration
sameh-farouk Aug 21, 2024
3ac6381
replace the lazy migration with a regular storage migration
sameh-farouk Aug 21, 2024
04fd0e7
Update pallet smart contract migration v12
sameh-farouk Aug 21, 2024
37d41db
make sure reservation works if a lock exists on user balance
sameh-farouk Aug 22, 2024
145c577
Avoid unnecessary recalculation of reservable balance
sameh-farouk Aug 22, 2024
9abeb0c
add more logs in billing and defensive check
sameh-farouk Aug 22, 2024
eea2376
fmt: just formating
sameh-farouk Aug 22, 2024
9d51049
fix typos
sameh-farouk Aug 22, 2024
247bc45
rename few functions to make code easier to understand
sameh-farouk Aug 22, 2024
b00b9dd
Ensure advancement of billing cycles in tests is more consistent
sameh-farouk Aug 23, 2024
71e2663
chore: update benchmark `weights.rs` file for all pallets
github-actions[bot] Aug 23, 2024
7361e66
Adjust the distribution of utilization revenue
sameh-farouk Aug 25, 2024
83ccaa4
Adjust imports for polkadot-sdk v1.1.0
sameh-farouk Aug 26, 2024
4251895
Removing solution provider integration test
sameh-farouk Aug 26, 2024
2df78b4
chore: update benchmark `weights.rs` file for all pallets
github-actions[bot] Aug 26, 2024
bfbe519
Merge branch 'development' into development-contracts-billing-refactor
sameh-farouk Aug 26, 2024
b443114
chore: update benchmark `weights.rs` file for all pallets
github-actions[bot] Aug 26, 2024
db42dce
Fixing a typo and adding a comment for clarity
sameh-farouk Aug 26, 2024
c62a30f
Leaving the solution provider test for now and just removing the bill…
sameh-farouk Aug 26, 2024
24e3ac9
Merge branch 'development-contracts-billing-refactor' of https://gith…
sameh-farouk Aug 26, 2024
8585901
chore: update benchmark `weights.rs` file for all pallets
github-actions[bot] Aug 26, 2024
efd76af
Switch storageKind from ValueQuery to OptionQuery for ContractPayment…
sameh-farouk Aug 26, 2024
e19934a
Minor refactor for the smart contract pallet storage migration v12
sameh-farouk Aug 26, 2024
dea3dc5
Improve the migration performance
sameh-farouk Aug 27, 2024
0a52b08
Merge branch 'development-contracts-billing-refactor' of https://gith…
sameh-farouk Aug 27, 2024
deee291
Fix benchmarks
sameh-farouk Aug 27, 2024
4a51902
Avoiding unwrap
sameh-farouk Aug 27, 2024
d48619b
Adding ContractPaymentStateNotExists error to tfchain client
sameh-farouk Aug 27, 2024
24b712f
Weights correction in smart-contract-pallet v12 migration
sameh-farouk Aug 27, 2024
b70501f
chore: update benchmark `weights.rs` file for all pallets
github-actions[bot] Aug 27, 2024
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
30 changes: 30 additions & 0 deletions clients/tfchain-client-go/contract_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,33 @@ type NodeExtraFeeSet struct {
ExtraFee types.U64 `json:"extra_fee"`
Topics []types.Hash
}

type RentWaived struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
Topics []types.Hash
}

type ContractGracePeriodElapsed struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
GracePeriod types.U64 `json:"grace_period"`
Topics []types.Hash
}

type ContractPaymentOverdrawn struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
Timestamp types.U64 `json:"timestamp"`
PartiallyBilledAmount types.U128 `json:"partially_billed_amount"`
Overdraft types.U128 `json:"overdraft"`
Topics []types.Hash
}

type RewardDistributed struct {
Phase types.Phase
ContractID types.U64 `json:"contract_id"`
StandardRewards types.U128 `json:"standard_rewards"`
AdditionalRewards types.U128 `json:"additional_rewards"`
Topics []types.Hash
}
4 changes: 4 additions & 0 deletions clients/tfchain-client-go/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ type EventRecords struct {
SmartContractModule_ServiceContractBilled []ServiceContractBilled //nolint:stylecheck,golint
SmartContractModule_BillingFrequencyChanged []BillingFrequencyChanged //nolint:stylecheck,golint
SmartContractModule_NodeExtraFeeSet []NodeExtraFeeSet //nolint:stylecheck,golint
SmartContractModule_RentWaived []RentWaived //nolint:stylecheck,golint
SmartContractModule_ContractGracePeriodElapsed []ContractGracePeriodElapsed //nolint:stylecheck,golint
SmartContractModule_ContractPaymentOverdrawn []ContractPaymentOverdrawn //nolint:stylecheck,golint
SmartContractModule_RewardDistributed []RewardDistributed //nolint:stylecheck,golint

// farm events
TfgridModule_FarmStored []FarmStored //nolint:stylecheck,golint
Expand Down
3 changes: 2 additions & 1 deletion clients/tfchain-client-go/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ var smartContractModuleErrors = []string{
"WrongAuthority",
"UnauthorizedToChangeSolutionProviderId",
"UnauthorizedToSetExtraFee",
"RewardDistributionError",
}

// https://github.com/threefoldtech/tfchain/blob/development/substrate-node/pallets/pallet-tfgrid/src/lib.rs#L442
Expand Down Expand Up @@ -536,7 +537,7 @@ func (s *Substrate) checkForError(callResponse *CallResponse) error {
if int(errIndex) >= len(moduleErrors[e.DispatchError.ModuleError.Index]) || moduleErrors[e.DispatchError.ModuleError.Index] == nil {
return fmt.Errorf("module error (%d) with unknown code %d occured, please update the module error list", e.DispatchError.ModuleError.Index, e.DispatchError.ModuleError.Error)
}
return fmt.Errorf(moduleErrors[e.DispatchError.ModuleError.Index][errIndex])
return fmt.Errorf("%v", moduleErrors[e.DispatchError.ModuleError.Index][errIndex])
} else {
return fmt.Errorf("unknown module error (%d) with code %d occured, please create the module error list", e.DispatchError.ModuleError.Index, e.DispatchError.ModuleError.Error)
}
Expand Down
48 changes: 48 additions & 0 deletions docs/architecture/0023-billing-refactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 23. Billing Refactor in pallet-smart-contract Module

Date: 2024-08-18

## Status

Accepted

## Context

The billing logic within the pallet-smart-contract module faced several issues, including critical bugs, inefficiencies in handling validators, and inadequate fund reservation mechanisms.
The goal of this refactor was to address these issues while enhancing the overall reliability and robustness of the billing process.

## Decision

The following architectural decisions were made to improve the billing logic:

### Refactoring Billing Logic

- Enhanced Tracking:
Improved tracking mechanisms were introduced for contract payments, especially during grace periods and when handling overdue payments.
The new ContractPaymentState was introduced to accurately manage contract payment states and resolve liquidity issues.
- Overdraft Handling:
Partial payments are now allowed, where users can cover part of their billing due if they lack sufficient funds for the full amount. Overdraft are tracked separately.
- Fund Reservation:
The use of balance locks/freezes was replaced with a more reliable reservation system, reducing issues related to fund availability for reward distribution.

### Improved Off-Chain Worker Logic

- Runtime Verification:
The is_next_block_author function was removed, with verification now occurring at runtime.
This change ensures transaction fees are reliably waived for validators and still prevents duplicate transactions.

### New Events Introduced

- ContractGracePeriodElapsed: Indicates that a contract's grace period has elapsed.
- ContractPaymentOverdrawn: Indicates that a contract's payment is overdrawn.
- RewardDistributed: Indicates that rewards have been distributed.

### Certified vs DIY Capacity

The system now correctly charges certified capacity at a higher rate (25% more) than DIY capacity.

## Consequences

- Increased Robustness: The billing process is now more robust and less prone to errors, particularly in scenarios involving partial payments and fund reservations.
- Better Visibility: The introduction of new events and improved logging provides better visibility into the billing and payment processes, aiding in debugging and monitoring.
- Backward Compatibility: While significant refactoring has been done, efforts were made to ensure backward compatibility where possible, especially concerning contract migration.
4 changes: 3 additions & 1 deletion substrate-node/node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use sp_core::{Encode, Pair};
use sp_inherents::{InherentData, InherentDataProvider};
use sp_keyring::Sr25519Keyring;
use sp_runtime::{OpaqueExtrinsic, SaturatedConversion};
use tfchain_runtime as runtime;
use tfchain_runtime::{self as runtime, pallet_smart_contract};

use std::{sync::Arc, time::Duration};

Expand Down Expand Up @@ -132,6 +132,7 @@ pub fn create_benchmark_extrinsic(
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
pallet_smart_contract::types::ContractIdProvides::<runtime::Runtime>::new(),
);

let raw_payload = runtime::SignedPayload::from_raw(
Expand All @@ -146,6 +147,7 @@ pub fn create_benchmark_extrinsic(
(),
(),
(),
(),
),
);
let signature = raw_payload.using_encoded(|e| sender.sign(e));
Expand Down
12 changes: 6 additions & 6 deletions substrate-node/pallets/pallet-burning/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//! Autogenerated weights for pallet_burning
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-06-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-08-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `4b80713dc969`, CPU: `AMD Ryzen 7 5800X 8-Core Processor`
//! HOSTNAME: `cf971058b257`, CPU: `AMD Ryzen 7 5800X 8-Core Processor`
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -45,8 +45,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `1594`
// Minimum execution time: 26_841_000 picoseconds.
Weight::from_parts(27_372_000, 1594)
// Minimum execution time: 26_180_000 picoseconds.
Weight::from_parts(26_961_000, 1594)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -60,8 +60,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `1594`
// Minimum execution time: 26_841_000 picoseconds.
Weight::from_parts(27_372_000, 1594)
// Minimum execution time: 26_180_000 picoseconds.
Weight::from_parts(26_961_000, 1594)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand Down
36 changes: 18 additions & 18 deletions substrate-node/pallets/pallet-dao/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//! Autogenerated weights for pallet_dao
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-06-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-08-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `4b80713dc969`, CPU: `AMD Ryzen 7 5800X 8-Core Processor`
//! HOSTNAME: `cf971058b257`, CPU: `AMD Ryzen 7 5800X 8-Core Processor`
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -58,8 +58,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `208`
// Estimated: `4687`
// Minimum execution time: 19_196_000 picoseconds.
Weight::from_parts(19_487_000, 4687)
// Minimum execution time: 20_109_000 picoseconds.
Weight::from_parts(20_408_000, 4687)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
Expand All @@ -77,8 +77,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `979`
// Estimated: `4444`
// Minimum execution time: 26_179_000 picoseconds.
Weight::from_parts(26_751_000, 4444)
// Minimum execution time: 27_332_000 picoseconds.
Weight::from_parts(28_063_000, 4444)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -92,8 +92,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `487`
// Estimated: `4687`
// Minimum execution time: 18_154_000 picoseconds.
Weight::from_parts(18_755_000, 4687)
// Minimum execution time: 19_197_000 picoseconds.
Weight::from_parts(19_697_000, 4687)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -111,8 +111,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `521`
// Estimated: `4687`
// Minimum execution time: 24_757_000 picoseconds.
Weight::from_parts(25_268_000, 4687)
// Minimum execution time: 26_009_000 picoseconds.
Weight::from_parts(26_571_000, 4687)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
Expand All @@ -136,8 +136,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `208`
// Estimated: `4687`
// Minimum execution time: 19_196_000 picoseconds.
Weight::from_parts(19_487_000, 4687)
// Minimum execution time: 20_109_000 picoseconds.
Weight::from_parts(20_408_000, 4687)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
Expand All @@ -155,8 +155,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `979`
// Estimated: `4444`
// Minimum execution time: 26_179_000 picoseconds.
Weight::from_parts(26_751_000, 4444)
// Minimum execution time: 27_332_000 picoseconds.
Weight::from_parts(28_063_000, 4444)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -170,8 +170,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `487`
// Estimated: `4687`
// Minimum execution time: 18_154_000 picoseconds.
Weight::from_parts(18_755_000, 4687)
// Minimum execution time: 19_197_000 picoseconds.
Weight::from_parts(19_697_000, 4687)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -189,8 +189,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `521`
// Estimated: `4687`
// Minimum execution time: 24_757_000 picoseconds.
Weight::from_parts(25_268_000, 4687)
// Minimum execution time: 26_009_000 picoseconds.
Weight::from_parts(26_571_000, 4687)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
Expand Down
20 changes: 10 additions & 10 deletions substrate-node/pallets/pallet-kvstore/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//! Autogenerated weights for pallet_kvstore
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-06-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-08-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `4b80713dc969`, CPU: `AMD Ryzen 7 5800X 8-Core Processor`
//! HOSTNAME: `cf971058b257`, CPU: `AMD Ryzen 7 5800X 8-Core Processor`
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -46,8 +46,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_293_000 picoseconds.
Weight::from_parts(7_574_000, 0)
// Minimum execution time: 6_873_000 picoseconds.
Weight::from_parts(7_063_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `TFKVStore::TFKVStore` (r:1 w:1)
Expand All @@ -56,8 +56,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `146`
// Estimated: `3611`
// Minimum execution time: 12_784_000 picoseconds.
Weight::from_parts(13_205_000, 3611)
// Minimum execution time: 12_173_000 picoseconds.
Weight::from_parts(12_564_000, 3611)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -71,8 +71,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_293_000 picoseconds.
Weight::from_parts(7_574_000, 0)
// Minimum execution time: 6_873_000 picoseconds.
Weight::from_parts(7_063_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: `TFKVStore::TFKVStore` (r:1 w:1)
Expand All @@ -81,8 +81,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `146`
// Estimated: `3611`
// Minimum execution time: 12_784_000 picoseconds.
Weight::from_parts(13_205_000, 3611)
// Minimum execution time: 12_173_000 picoseconds.
Weight::from_parts(12_564_000, 3611)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ benchmarks! {

let contract = SmartContractModule::<T>::contracts(contract_id).unwrap();
// Get contract cost before billing to take into account nu
let (cost, discount_level) = contract.calculate_contract_cost_tft(balance_init_amount, elapsed_seconds).unwrap();
let (cost, discount_level) = contract.calculate_contract_cost_tft(balance_init_amount, elapsed_seconds, None).unwrap();
}: _(RawOrigin::Signed(farmer), contract_id)
verify {
let lock = SmartContractModule::<T>::contract_number_of_cylces_billed(contract_id);
assert_eq!(lock.amount_locked, cost);
let contract_payment_state = SmartContractModule::<T>::contract_payment_state(contract_id);
assert_eq!(contract_payment_state.standard_reserve, cost);
let contract_bill = types::ContractBill {
contract_id,
timestamp: SmartContractModule::<T>::get_current_timestamp_in_secs(),
Expand Down
Loading
Loading