Conversation
|
This still needs tests and requires an updated version of cpp-ethereum. |
Changelog.md
Outdated
|
|
||
| Features: | ||
| * Parser: Better error message for unexpected trailing comma in parameter lists. | ||
| * Code Generator: Use STATICCALL opcode for calling pure functions. |
There was a problem hiding this comment.
Oh right. I'm not yet fully awake...
| if (isDelegateCall) | ||
| solAssert(!_functionType.valueSet(), "Value set for delegatecall"); | ||
| else if (isStaticCall) | ||
| solAssert(!_functionType.valueSet(), "Value set for delegatecall"); |
7b13960 to
e0f6c38
Compare
| bool returnSuccessCondition = funKind == FunctionType::Kind::BareCall || funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::BareDelegateCall; | ||
| bool isCallCode = funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::CallCode; | ||
| bool isDelegateCall = funKind == FunctionType::Kind::BareDelegateCall || funKind == FunctionType::Kind::DelegateCall; | ||
| bool isStaticCall = (_functionType.stateMutability() <= StateMutability::View); |
There was a problem hiding this comment.
I'd prefer to have an experimental pragma for this.
e0f6c38 to
c10c6fa
Compare
| bool isDelegateCall = funKind == FunctionType::Kind::BareDelegateCall || funKind == FunctionType::Kind::DelegateCall; | ||
| bool useStaticCall = | ||
| _functionType.stateMutability() <= StateMutability::View && | ||
| m_context.experimentalFeatureActive(ExperimentalFeature::STATICCALL; |
Changelog.md
Outdated
| (previously, some amount was retained in order to work in pre-tangerine whistle | ||
| EVM versions) | ||
| * Code Generator: Use STATICCALL opcode for calling view and pure functions. Enable | ||
| via `pragma experimental STATICCALL;`. |
There was a problem hiding this comment.
Why don't we go for pragma experimental Byzantium;?
| bool returnSuccessCondition = funKind == FunctionType::Kind::BareCall || funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::BareDelegateCall; | ||
| bool isCallCode = funKind == FunctionType::Kind::BareCallCode || funKind == FunctionType::Kind::CallCode; | ||
| bool isDelegateCall = funKind == FunctionType::Kind::BareDelegateCall || funKind == FunctionType::Kind::DelegateCall; | ||
| bool useStaticCall = |
There was a problem hiding this comment.
I think use suits this better, but the other two are named is so perhaps just go with isStaticCall or alternatively rename the other two to use?
There was a problem hiding this comment.
It's a different thing. I would call it isStaticCall out of the function type, but useStaticCall tells whether the compiler is also allowed to use the opcode due to pragmas.
axic
left a comment
There was a problem hiding this comment.
Needs tests, changelog update and a rebase.
e952b6f to
1e04cc3
Compare
|
Still needs tests. |
1e04cc3 to
29a7cb6
Compare
|
Added tests and documentation. Should be ready to merge. |
|
Perhaps we should have a target pragma specifying the chain (related #1117). The question there becomes wether we enforce the latest chain and allow to go back to the previous one or we stay on longer on the "old chain". In example:
|
|
I would prefer a |
|
Decision from discussion: add a homestead could also be used to force gas calculation for calls (which is currently still the default). |
|
Should use the new |
|
@axic this only requires the evm target check, or is something else missing? |
29a7cb6 to
583a931
Compare
e98d4e6 to
9955015
Compare
Changelog.md
Outdated
| Features: | ||
| * C99/C++-style scoping rules (instead of JavaScript function scoping) take effect as experimental v0.5.0 feature. | ||
| * Code Generator: Assert that ``k != 0`` for ``molmod(a, b, k)`` and ``addmod(a, b, k)`` as experimental 0.5.0 feature. | ||
| * Code Generator: Use STATICCALL opcode for calling view and pure functions as experimenal 0.5.0 feature. |
There was a problem hiding this comment.
``STATICCALL`` :)
Also could fix the molmod above here.
| You can switch the compiler to use STATICCALL when calling such functions and thus | ||
| prevent modifications to the state on the level of the EVM by adding | ||
| ``pragma experimental "v0.5.0";`` | ||
| It is not possible to prevent functions from reading the state at the level |
There was a problem hiding this comment.
Should this be a separate warning block?
|
The static call changes look good. |
axic
left a comment
There was a problem hiding this comment.
Apart from the changelog comment the staticcall changes looks fine. (Should of course merge the dependant PRs first.)
01390b2 to
bec98c6
Compare
| bool isDelegateCall = funKind == FunctionType::Kind::BareDelegateCall || funKind == FunctionType::Kind::DelegateCall; | ||
| bool useStaticCall = | ||
| _functionType.stateMutability() <= StateMutability::View && | ||
| m_context.experimentalFeatureActive(ExperimentalFeature::V050) && |
There was a problem hiding this comment.
Do we really need this line? We should just enable it based on the EMV version (which we also have as a condition below).
There was a problem hiding this comment.
We perform changes in codegen from time to time without requiring a breaking release. The condition for that is that the actual semantics visible from outside do not change. This is only the case if people do not perform invalid type conversions and if they use the most recent EVM version. I think it is fine to assume the latter, so we can just remove it. We should highlight that in the release notes.
There was a problem hiding this comment.
Ok but actually arguing the other way around: If we remove this condition, then we actually assume that it is perfectly fine to use. This means it is not an experimental feature. In turn, we don't have to warn about using experimental 0.5.0.
There was a problem hiding this comment.
Copying this from the channel for the record:
The argument is that we specifically state in the changelog that
pragma experimental v0.5.0is analysis only and won’t change the codegen phase.The second argument is whether
staticcallis experiemental or not and I’m leaning towards to say it isn’t experimental. That code should work, if it doesn’t that is a broken VM or a broken implementation in the codegen.There is one case where this could cause an issue if the user disregards the warnings from the
ViewPureCheckerand does expected state modification in a view function and calls it externally in another contract.
Luckily, the ViewPureChecker reports a warning for these cases (https://github.com/ethereum/solidity/blob/develop/libsolidity/analysis/ViewPureChecker.cpp#L254) so it should only fail as a matter of programmer error.
Though it is kind of a breaking change because if they disregard the warning the output will not work.
|
Rebased it. |
No description provided.