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

[NEP-591]: global contract usage cost description #595

Merged
merged 1 commit into from
Feb 21, 2025
Merged
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
13 changes: 11 additions & 2 deletions neps/nep-0591.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

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

it doesn't burn tokens, it locks it


* `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

Expand Down