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:
xermicus authored and GitHub committed 2026-01-27 19:43:14 +01:00
1 parent 99b73ec083
commit 95ae938ddf
29 files changed
+172 -30

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@
const path_to_root = "../";
const default_light_theme = "light";
const default_dark_theme = "navy";
window.path_to_searchindex_js = "../searchindex-4ae832c1.js";
window.path_to_searchindex_js = "../searchindex-c7304031.js";
</script>
<!-- Start loading toc.js asap -->
<script src="../toc-6f3f265e.js"></script>
+10 -2
View File
@@ -35,7 +35,7 @@
const path_to_root = "../";
const default_light_theme = "light";
const default_dark_theme = "navy";
window.path_to_searchindex_js = "../searchindex-4ae832c1.js";
window.path_to_searchindex_js = "../searchindex-c7304031.js";
</script>
<!-- Start loading toc.js asap -->
<script src="../toc-6f3f265e.js"></script>
@@ -187,13 +187,15 @@ Therefore, in EVM terminology, the deploy code equals the runtime code.</p>
</blockquote>
<h2 id="solidity"><a class="header" href="#solidity">Solidity</a></h2>
<p>We are aware of the following differences in the translation of Solidity code.</p>
<h3 id="the-6364-gas-rule"><a class="header" href="#the-6364-gas-rule">The <code>63/64</code> gas rule</a></h3>
<p><code>pallet-revive</code> <strong>doesn’t apply the <code>63/64</code> gas rule</strong>. We strongly advice to change any code calling untrusted contracts to supply a limited amount of gas only!</p>
<h3 id="addresscreationcode"><a class="header" href="#addresscreationcode"><code>address.creationCode</code></a></h3>
<p>This returns the bytecode keccak256 hash instead.</p>
<h2 id="yul-functions"><a class="header" href="#yul-functions">YUL functions</a></h2>
<p>The below list contains noteworthy differences in the translation of YUL functions.</p>
<blockquote class="blockquote-tag blockquote-tag-note">
<p class="blockquote-tag-title"><svg viewbox="0 0 16 16" width="18" height="18"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"></path></svg>Note</p>
<p>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 <code>2^32-1</code> will trap the contract immediately.</p>
<p>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 <code>2^32-1</code> may lead to <code>OutOfGas</code> errors trap contract execution.</p>
</blockquote>
<p>The <code>solc</code> 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 <code>assembly</code> code.</p>
<h3 id="mload-mstore-msize-mcopy-memory-related-functions"><a class="header" href="#mload-mstore-msize-mcopy-memory-related-functions"><code>mload</code>, <code>mstore</code>, <code>msize</code>, <code>mcopy</code> (memory related functions)</a></h3>
@@ -205,6 +207,10 @@ Therefore, in EVM terminology, the deploy code equals the runtime code.</p>
</ul>
<h3 id="calldataload-calldatacopy"><a class="header" href="#calldataload-calldatacopy"><code>calldataload</code>, <code>calldatacopy</code></a></h3>
<p>In the constructor code, the offset is ignored and this always returns <code>0</code>.</p>
<blockquote class="blockquote-tag blockquote-tag-warning">
<p class="blockquote-tag-title"><svg viewbox="0 0 16 16" width="18" height="18"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg>Warning</p>
<p><code>pallet-revive</code> restricts the calldata size (to 128kb at the time of writing).</p>
</blockquote>
<h3 id="codecopy"><a class="header" href="#codecopy"><code>codecopy</code></a></h3>
<p>Only supported in constructor code.</p>
<h3 id="create-create2"><a class="header" href="#create-create2"><code>create</code>, <code>create2</code></a></h3>
@@ -225,6 +231,8 @@ Thus, <code>revive</code> is able to supply the expected code hash and construct
<p>Returns the contract hash.</p>
<h3 id="datasize"><a class="header" href="#datasize"><code>datasize</code></a></h3>
<p>Returns the contract hash size (constant value of <code>32</code>).</p>
<h3 id="revert-return"><a class="header" href="#revert-return"><code>revert</code>, <code>return</code></a></h3>
<p><code>pallet-revive</code> restricts the returndata size (to 128kb at the time of writing).</p>
<h3 id="prevrandao-difficulty"><a class="header" href="#prevrandao-difficulty"><code>prevrandao</code>, <code>difficulty</code></a></h3>
<p>Translates to a constant value of <code>2500000000000000</code>.</p>
<h3 id="pc-extcodecopy"><a class="header" href="#pc-extcodecopy"><code>pc</code>, <code>extcodecopy</code></a></h3>
+1 -1
View File
@@ -35,7 +35,7 @@
const path_to_root = "../";
const default_light_theme = "light";
const default_dark_theme = "navy";
window.path_to_searchindex_js = "../searchindex-4ae832c1.js";
window.path_to_searchindex_js = "../searchindex-c7304031.js";
</script>
<!-- Start loading toc.js asap -->
<script src="../toc-6f3f265e.js"></script>
+1 -1
View File
@@ -35,7 +35,7 @@
const path_to_root = "../";
const default_light_theme = "light";
const default_dark_theme = "navy";
window.path_to_searchindex_js = "../searchindex-4ae832c1.js";
window.path_to_searchindex_js = "../searchindex-c7304031.js";
</script>
<!-- Start loading toc.js asap -->
<script src="../toc-6f3f265e.js"></script>
+1 -1
View File
@@ -35,7 +35,7 @@
const path_to_root = "../";
const default_light_theme = "light";
const default_dark_theme = "navy";
window.path_to_searchindex_js = "../searchindex-4ae832c1.js";
window.path_to_searchindex_js = "../searchindex-c7304031.js";
</script>
<!-- Start loading toc.js asap -->
<script src="../toc-6f3f265e.js"></script>
+1 -1
View File
@@ -35,7 +35,7 @@
const path_to_root = "../";
const default_light_theme = "light";
const default_dark_theme = "navy";
window.path_to_searchindex_js = "../searchindex-4ae832c1.js";
window.path_to_searchindex_js = "../searchindex-c7304031.js";
</script>
<!-- Start loading toc.js asap -->
<script src="../toc-6f3f265e.js"></script>
+1 -1
View File
@@ -35,7 +35,7 @@
const path_to_root = "../";
const default_light_theme = "light";
const default_dark_theme = "navy";
window.path_to_searchindex_js = "../searchindex-4ae832c1.js";
window.path_to_searchindex_js = "../searchindex-c7304031.js";
</script>
<!-- Start loading toc.js asap -->
<script src="../toc-6f3f265e.js"></script>