Zondax / filecoin-solidity

Filecoin Solidity API Library
Apache License 2.0
95 stars 43 forks source link

Using staticcall for builtIn actors readonly APIs #289

Closed longfeiWan9 closed 1 year ago

longfeiWan9 commented 1 year ago

This concern is raised in Slack.

Currently, Filecoin.solidity invokes builtIn Actor using DelegateCall() for both readOnly APIs and APIs which might change the state of the blockchain. For readOnly APIs, solidity devs might want to write their solidity functions as view to simple read without sending transactions. But they cannot because it is not allowed to declare functions as view if DelegateCall is used to read data on-chain.

So we would suggest trying to use staticcall to invoke readOnly APIs from builtIn actors and provide those API as view functions.

:link: zboto Link

rllola commented 1 year ago

The precompiles only allow DelegateCall.

https://github.com/filecoin-project/builtin-actors/blob/hyperspace/v10.0.0-rc.2/actors/evm/src/interpreter/precompiles/fvm.rs#L130-L132

Stebalien commented 1 year ago

However, we can set the read-only flag in these cases, just to be safe.

emmanuelm41 commented 1 year ago

Read only flags for methods that don't change the state have been set. So I think this issue can be closed, as we are doing the best we can (use the read only flag)