mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-10-29 15:09:53 +00:00
Add missing 63/64 rule documentation and a test (#462)
- Prominently point out the important differences of the `pallet-revive` runtime. - Add a test case illustrating the problem. See also: https://github.com/paritytech/contract-issues/issues/257 --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
1 parent
99b73ec083
commit
95ae938ddf
29 files changed
+172
-30
No files matched your search
@@ -18,6 +18,10 @@ Therefore, in EVM terminology, the deploy code equals the runtime code.
|
||||
|
||||
We are aware of the following differences in the translation of Solidity code.
|
||||
|
||||
### The `63/64` gas rule
|
||||
|
||||
`pallet-revive` **doesn't apply the `63/64` gas rule**. We strongly advice to change any code calling untrusted contracts to supply a limited amount of gas only!
|
||||
|
||||
### `address.creationCode`
|
||||
|
||||
This returns the bytecode keccak256 hash instead.
|
||||
@@ -28,7 +32,7 @@ The below list contains noteworthy differences in the translation of YUL functio
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> Many functions receive memory buffer offset pointer or size arguments. Since the PVM pointer size is 32 bit, supplying memory offset or buffer size values above `2^32-1` will trap the contract immediately.
|
||||
> Many functions receive memory buffer offset pointer or size arguments. The PVM pointer size is 32 bit, supplying memory offset or buffer size values above `2^32-1` may lead to `OutOfGas` errors trap contract execution.
|
||||
|
||||
The `solc` compiler ought to always emit valid memory references, so Solidity dApp authors don't need to worry about this unless they deal with low level `assembly` code.
|
||||
|
||||
@@ -43,6 +47,10 @@ In general, revive preserves the memory layout, meaning low level memory operati
|
||||
|
||||
In the constructor code, the offset is ignored and this always returns `0`.
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> `pallet-revive` restricts the calldata size (to 128kb at the time of writing).
|
||||
|
||||
### `codecopy`
|
||||
|
||||
Only supported in constructor code.
|
||||
@@ -70,6 +78,10 @@ Returns the contract hash.
|
||||
|
||||
Returns the contract hash size (constant value of `32`).
|
||||
|
||||
### `revert`, `return`
|
||||
|
||||
`pallet-revive` restricts the returndata size (to 128kb at the time of writing).
|
||||
|
||||
### `prevrandao`, `difficulty`
|
||||
|
||||
Translates to a constant value of `2500000000000000`.
|
||||
|
||||
@@ -2,6 +2,18 @@
|
||||
|
||||
Hello and a warm welcome to the `revive` Solidity compiler book!
|
||||
|
||||
> [!WARNING]
|
||||
>
|
||||
> Solidity on PVM is running on the `pallet-revive` runtime. This introduces **observable semantic differences** in comparison with the EVM.
|
||||
>
|
||||
> Study the [differences](https://paritytech.github.io/revive/user_guide/differences.html) section carefully. **Ignoring these differences may lead to defunct contracts.**
|
||||
>
|
||||
> Notable examples:
|
||||
> - The 63/64 gas rule isn't implemented in the pallet (introduces potential DoS vector when calling other contracts)
|
||||
> - Contract instantiation works differently (by hash instead of by code)
|
||||
> - The gas model implemented by `pallet-revive` differs from Ethereum
|
||||
> - The heap size is fixed instead of gas-metered and there's a fixed amount of stack size (contracts working fine on EVM may trap on PVM)
|
||||
|
||||
## Target audience
|
||||
|
||||
- **Solidity dApp developers** should read the [user guide](./user_guide.md). Solidity on PolkaVM introduces important differences to EVM which should be well understood.
|
||||
|
||||
Reference in new issue
Block a user