Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/beacon_root/main.eas
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ loadtime:
calldataload ;; [input_timestamp]
dup1 ;; [input_timestamp, input_timestamp]

;; Verify input timestamp is non-zero.
iszero ;; [input_timestamp == 0, input_timestamp]
push1 @throw ;; [throw_lbl, input_timestamp == 0, input_timestamp]
;; Jump to continue if timestamp is non-zero, otherwise revert.
push1 @time_ok ;; [time_ok_lbl, input_timestamp, input_timestamp]
jumpi ;; [input_timestamp]
%do_revert() ;; []

time_ok:
;; Compute the timestamp index and load from storage.
push3 BUFLEN ;; [buflen, input_timestamp]
dup2 ;; [input_timestamp, buflen, input_timestamp]
Expand Down Expand Up @@ -108,10 +109,6 @@ loadroot:
push0 ;; [offset, size]
return ;; []

throw:
;; Reverts current execution with no return data.
%do_revert()

submit:
;; Calculate the index the timestamp should be stored at, e.g.
;; time_index = (time % buflen).
Expand All @@ -134,5 +131,3 @@ submit:
push3 BUFLEN ;; [buflen, time_index, root]
add ;; [root_index, root]
sstore ;; []

stop ;; []