From 386973588251df64e5c7ad17e14fd3e0c840c25c Mon Sep 17 00:00:00 2001 From: Stefan Neamtu Date: Fri, 21 Feb 2025 13:03:02 +0100 Subject: [PATCH] describe usage costs --- neps/nep-0591.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/neps/nep-0591.md b/neps/nep-0591.md index 3176e396e..4003cd491 100644 --- a/neps/nep-0591.md +++ b/neps/nep-0591.md @@ -134,7 +134,7 @@ Applying `UseGlobalContractAction` updates user account `contract` field accordi ### Costs -For global contracts we burn tokens for storage instead of locking like what we do regular contracts today. +For global contracts deployment we burn tokens for storage instead of locking like what we do regular contracts today. The cost per byte of global contract code `global_contract_storage_amount_per_byte` is set as 10x the storage staking cost `storage_amount_per_byte`. Additionally we add action costs for the global contract related actions: @@ -147,7 +147,16 @@ Additionally we add action costs for the global contract related actions: * we still want to be able to fit max allowed contracts size into single chunk space: `max_gas_burnt = 300_000_000_000_000`, `max_contract_size = 4_194_304`, so it should be at most `max_gas_burnt / max_contract_size = 71_525_573` * we need to allow for some margin for other costs, so we can round it down to `70_000_000` -TODO(stedfn): cover costs for using global contracts +Referencing a global contract burns tokens for storage in accordance with `storage_amount_per_byte`. Additionally, the usage action incurs two costs, as follows: + +* `action_use_global_contract` + * mirrors `action_deploy_contract` + * base cost for processing a usage action +* `action_use_global_contract_per_identifier_byte` + * mirrors `action_deploy_contract_per_byte` + * introduced because the `AccountId` in `GlobalByAccount(AccountId)` variant can vary in length, unlike `Global(CryptoHash)` with a fixed size of 32 bytes + +Although the cost structure is similar to that of single shard contract deployments, the overall fees are significantly lower because only a few bytes are stored for the reference. This is desired, because referencing a global contract is not an expensive operation for the network. ## Security Implications