skalenetwork / skaled

Running more than 20 production blockchains, SKALED is Ethereum-compatible, high performance C++ Proof-of-Stake client, tools and libraries. Uses SKALE consensus as a blockchain consensus core. Includes dynamic Oracle. Implements file storage and retrieval as an EVM extension.
https://skale.network
GNU General Public License v3.0
85 stars 39 forks source link

Investigate resource calculation for contracts #1883

Open PolinaKiporenko opened 4 months ago

PolinaKiporenko commented 4 months ago

Add functionality to monitor amount of resources used by contracts. Resources: gas usage(cumulative amount of gas used during execution in this contract), tx usage(amount of txs which interacted with this contract - only write), state/storage usage(amount of state taken by this contract). By day/month/year and total

dimalit commented 1 month ago

Clarifications:

  1. This info should be accessible from contracts.
  2. It should somehow appear in contract on Europa hub (to be linked with payments).
dimalit commented 1 month ago

Simple solution:

  1. skale remembers storage usage, gas usage and transaction count for each contract;
  2. these data is accessible through precompiled contract;
  3. daily/monthly/early numbers can be computed using historic node;
  4. to get it all to Europa chain we need IMA arbitrary call functionality.

TBD:

  1. How indirect calls should be counted.
  2. How multiple calls to same contract from 1 transaction should be counted.
  3. Maybe we don't need this info on-chain, and can access it via oracle.
  4. If stored on-chain - is accessing it via historic node a viable solution?
dimalit commented 1 month ago

Blocked: need either understanding of overall architecture of hub pricing, or exact specs for this particular task. Otherwise it's impossible to make any architectural decisions.