Resources

The GlobalForce blockchain relies on two system resources: CPU and RAM. Every GlobalForce account needs system resources to interact with smart contracts deployed on the blockchain.

RAM

RAM, just like in a computer, is a limited resource. It is a fast memory storage space that is used by the blockchain to store data. Unlike your computer which has eventual persistence to a hard drive, the GlobalForce blockchain stores all of its data in RAM.

Because of this, RAM is a very limited and in-demand resource. Every piece of state data that is stored on the blockchain must be stored in RAM. This includes account balances, contract code, and contract data.

RAM can be purchased by users on the GlobalForce blockchain. The price of RAM is regulated by consensus through the eosio system smart contract.

CPU

CPU is a system resource that provides processing power to blockchain accounts. When a transaction is executed on the blockchain, it consumes CPU. To ensure transactions are completed successfully, the payer account must have enough CPU allocated to it.

The amount of CPU available to an account is measured in microseconds.

Buying RAM & CPU

The eosio system contract provides the billuserres action to buy RAM & CPU.

Want to know how CPU is calculated?

Transactions executed by the blockchain contain one or more actions. Each transaction must consume an amount of CPU within the limits predefined by the minimum and maximum transaction CPU usage values. For GlobalForce these limits are set in the blockchain's configuration. You can find out these limits by running the following command and consult the min_transaction_cpu_usage and the max_transaction_cpu_usage which are expressed in microseconds.

For accounts that execute transactions, the blockchain calculates and updates the remaining resources with each block before each transaction is executed. When a transaction is prepared for execution, the blockchain determines whether the payer account has enough CPU to cover the transaction execution. To calculate the necessary CPU, the node that actively builds the current block measures the time to execute the transaction. If the account has enough CPU, the transaction is executed; otherwise it is rejected. For technical details please refer to the following links:

Want to know how the RAM price is calculated?

The necessary RAM needed for a smart contract to store its data is calculated from the used blockchain state.

As a developer, to understand the amount of RAM your smart contract needs, pay attention to the data structure underlying the multi-index tables your smart contract instantiates and uses. The data structure underlying one multi-index table defines a row in the table. Each data member of the data structure corresponds with a row cell of the table. To approximate the amount of RAM one multi-index row needs to store on the blockchain, you have to add the size of the type of each data member and the memory overheads for each of the defined indexes, if any. Find below the overheads defined by the GlobalForce code for multi-index tables, indexes, and data types:

Resources

The GlobalForce blockchain relies on two system resources: `CPU` and `RAM`. Every GlobalForce account needs system resources to interact with smart contracts d

Loading...