-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
68 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,7 @@ | ||
(defn retOne [] :uint256 :external | ||
(defvar x :uint256 0) | ||
(venom (mstore 64 1)) | ||
x) | ||
(ir :uint256 (seq 1))) | ||
|
||
|
||
;; this works as-is but unecessary variable costs gas | ||
(defn addTwoNums [:uint256 x y] :uint256 :external | ||
(defvar z :uint256 0) ;; first variable is at offset 64 | ||
(venom (mstore 64 (add (calldataload 4) (calldataload 36)))) | ||
z) | ||
|
||
;; ;; this might be ideal, removing implicit returns around venom blocks | ||
;; (defn addTwoNums2 [:uint256 x y] :uint256 :external | ||
;; (venom (seq | ||
;; (mstore 64 (add (calldataload 4) (calldataload 36)))))) | ||
(ir :uint256 | ||
(add (calldataload 4) | ||
(calldataload 36)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
@external | ||
def retOne() -> uint256: | ||
x: uint256 = 0 | ||
x = 1 | ||
return x | ||
return 1 | ||
|
||
|
||
# 71 gas | ||
@external | ||
def addTwoNums(a: uint256, b: uint256) -> uint256: | ||
return unsafe_add(a, b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters