From 9c58f840fbf81e8cfbfb14142db2a5ee2baa1f50 Mon Sep 17 00:00:00 2001 From: Adam Boudj Date: Sat, 8 Jun 2024 19:49:26 +0400 Subject: [PATCH 1/2] Update Assembly --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 596a81e..33564e7 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,18 @@ Interfaces separate NatSpec from contract logic, requiring readers to do more wo ##### C. Avoid using assembly. -Assembly code is hard to read and audit. We should avoid it unless the gas savings are very consequential, e.g. > 25%. +Use inline assembly with extreme care. Ensure that it is well-documented with inline comments explaining what the assembly code does. Avoid using assembly unless it adds significant value (e.g., gas savings > 25%) and there are no better alternatives. + +**Example:** + +```solidity +function add(uint x, uint y) public pure returns (uint result) { + assembly { + // Add x and y and store the result in the `result` variable + result := add(x, y) + } +} +``` #### 4. Versioning From f996651605498f61d1982050957b4bddfb0b7afb Mon Sep 17 00:00:00 2001 From: Adam Boudj Date: Sat, 8 Jun 2024 19:50:36 +0400 Subject: [PATCH 2/2] Update Assembly rule --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 33564e7..5309b35 100644 --- a/README.md +++ b/README.md @@ -186,8 +186,6 @@ Interfaces separate NatSpec from contract logic, requiring readers to do more wo Use inline assembly with extreme care. Ensure that it is well-documented with inline comments explaining what the assembly code does. Avoid using assembly unless it adds significant value (e.g., gas savings > 25%) and there are no better alternatives. -**Example:** - ```solidity function add(uint x, uint y) public pure returns (uint result) { assembly {