Open qimiaoguo opened 6 years ago
agree with this. But it's not an easy change, as it might result in hard-fork or non-replayable chain.
@taokayan Why can it result in a hard-fork? It is a new action that no contract have used before. You can add a new action if you worried. In fact, you don't need worry about the hard-fork, because no transactions will be included in the block if it call the get_resource_limits() method.
@qimiaoguo the issue that creates a hardfork is the change in access to the get_resource_limits
intrinsic. consider a deployed un-privileged contract that uses this intrinsic in an action called forkchain
which does nothing but call this intrinsic.
Any validator/producer that is running a version before this change would consider any transaction that includes forkchain
to be a violation of the protocol as it calls an intrinsic that the software considers to be "privileged-only"
Any validator/producer that is running a version after this change would consider any transaction that includes forchain
valid.
So, any block that includes said transaction is a hard-fork point where any old client will fork out of the network and only new clients will be able to proceed.
additionally get_resource_limits
provides limits, not usage. So it cannot detect when an account has used your accounts resources in an unexpected way.
@wanderingbort correct me if am wrong, I can call this method before and after an action, and calculate the difference, then I can decide to if accept the action. However, my intention is to let the contract know how much resource it has used, you can provide another method for us.
This is a step for contract developers, and I think in the more future, you can try to think how to provide the ability that everybody can set the max resource when call an action.
Thanks, hope the hard-fork can solve the problem.
Agreed that getters like get_resource_limits
and get_blockchain_parameters_packed
should be available to everyone.
Now only the privileged account can access the privileged api, this is true. However, I think the get_resource_limits should be take out of it because it is just a get-action.
Two reasons:
Now we can only get account usage with the RPC, but not in the contract, is it right?