Skip to content

Commit da58a70

Browse files
HUB heartbeat overhaul for system transactions (#699)
Signed-off-by: F Bojarski <[email protected]> Co-authored-by: François Bojarski <[email protected]> Co-authored-by: F Bojarski <[email protected]>
1 parent a03d212 commit da58a70

File tree

88 files changed

+1591
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1591
-486
lines changed

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ LIBRARY := library
4343

4444
LOG_DATA := logdata
4545

46-
LOG_INFO := loginfo
46+
LOG_INFO_PRE_CANCUN := loginfo/pre-cancun
47+
48+
LOG_INFO_CANCUN := loginfo/cancun
4749

4850
MMU := mmu
4951

@@ -113,7 +115,6 @@ ZKEVM_MODULES_COMMON := ${CONSTANTS} \
113115
${GAS} \
114116
${LIBRARY} \
115117
${LOG_DATA} \
116-
${LOG_INFO} \
117118
${MMU} \
118119
${RLP_ADDR} \
119120
${RLP_TXRCPT} \
@@ -129,6 +130,7 @@ ZKEVM_MODULES_LONDON := ${ZKEVM_MODULES_COMMON} \
129130
${TABLES_LONDON} \
130131
${BLOCKDATA_LONDON} \
131132
${HUB_LONDON} \
133+
${LOG_INFO_PRE_CANCUN} \
132134
${MMIO_LONDON} \
133135
${MXP_LONDON} \
134136
${OOB_LONDON} \
@@ -139,6 +141,7 @@ ZKEVM_MODULES_PARIS := ${ZKEVM_MODULES_COMMON} \
139141
${TABLES_LONDON} \
140142
${BLOCKDATA_PARIS} \
141143
${HUB_LONDON} \
144+
${LOG_INFO_PRE_CANCUN} \
142145
${MMIO_LONDON} \
143146
${MXP_LONDON} \
144147
${OOB_LONDON} \
@@ -149,6 +152,7 @@ ZKEVM_MODULES_SHANGHAI := ${ZKEVM_MODULES_COMMON} \
149152
${TABLES_LONDON} \
150153
${BLOCKDATA_PARIS} \
151154
${HUB_SHANGHAI} \
155+
${LOG_INFO_PRE_CANCUN} \
152156
${MMIO_LONDON} \
153157
${MXP_LONDON} \
154158
${OOB_SHANGHAI} \
@@ -159,6 +163,7 @@ ZKEVM_MODULES_CANCUN := ${ZKEVM_MODULES_COMMON} \
159163
${TABLES_CANCUN} \
160164
${BLOCKDATA_CANCUN} \
161165
${HUB_CANCUN} \
166+
${LOG_INFO_CANCUN} \
162167
${MMIO_CANCUN} \
163168
${MXP_CANCUN} \
164169
${OOB_SHANGHAI} \

constants/constants.lisp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@
252252
UNPROTECTED_V_PO (+ UNPROTECTED_V 1)
253253
PROTECTED_BASE_V 35
254254
PROTECTED_BASE_V_PO (+ PROTECTED_BASE_V 1)
255-
HISTORY_BUFFER_LENGTH 8191
255+
HISTORY_BUFFER_LENGTH 8191 ;; EIP-4788
256+
HISTORY_SERVE_WINDOW 8191 ;; EIP-2935
256257
BEACON_ROOTS_ADDRESS_HI 0x000f3df6
257258
BEACON_ROOTS_ADDRESS_LO 0xd732807ef1319fb7b8bb8522d0beac02
258259
HISTORY_STORAGE_ADDRESS_HI 0x0000f908
@@ -525,4 +526,4 @@
525526
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
526527
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
527528
WCP_INST_GEQ 0x0E
528-
WCP_INST_LEQ 0x0F)
529+
WCP_INST_LEQ 0x0F)

hub/cancun/columns/shared.lisp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
(module hub)
22

33
(defcolumns
4-
( ABSOLUTE_TRANSACTION_NUMBER :i16 ) ;;TODO to delete
5-
( RELATIVE_BLOCK_NUMBER :i16 ) ;;TODO to delete
4+
5+
;; system transactions vs user transaction flags
66
( SYSI :binary@prove )
77
( USER :binary@prove )
88
( SYSF :binary@prove )
9+
10+
;; block and transaction accounting
11+
( BLK_NUMBER :i24 )
12+
;; ( TOTL_TXN_NUMBER :i24 )
13+
( SYSI_TXN_NUMBER :i24 )
14+
( USER_TXN_NUMBER :i24 )
15+
( SYSF_TXN_NUMBER :i24 )
16+
17+
;; transaction processing phases
918
( TX_SKIP :binary@prove )
1019
( TX_WARM :binary@prove )
1120
( TX_INIT :binary@prove )
1221
( TX_EXEC :binary@prove )
1322
( TX_FINL :binary@prove )
14-
( BLK_NUMBER :i24 )
15-
( TOTL_TXN_NUMBER :i24 )
16-
( SYSI_TXN_NUMBER :i24 )
17-
( USER_TXN_NUMBER :i24 )
18-
( SYSF_TXN_NUMBER :i24 )
1923
( HUB_STAMP :i32 )
2024
( HUB_STAMP_TRANSACTION_END :i32 )
2125
( CONTEXT_MAY_CHANGE :binary@prove )
@@ -77,8 +81,6 @@
7781

7882
(defalias
7983
;;
80-
ABS_TX_NUM ABSOLUTE_TRANSACTION_NUMBER
81-
REL_BLK_NUM RELATIVE_BLOCK_NUMBER
8284
CMC CONTEXT_MAY_CHANGE
8385
XAHOY EXCEPTION_AHOY
8486
TX_END_STAMP HUB_STAMP_TRANSACTION_END

hub/cancun/columns/transaction.lisp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545

4646
;; related to system transaction
4747
( NOOP :binary@prove)
48-
( EIP4788 :binary@prove)
49-
( EIP2935 :binary@prove) ;; should be Pectra only
50-
( SYST_TXN_DATA :array [4] :i128 ) ;; TODO: review typing
48+
( EIP_4788 :binary@prove)
49+
( EIP_2935 :binary@prove) ;; should be Pectra only
50+
( SYST_TXN_DATA :array [4] :i128 )
5151
)
5252
)

hub/cancun/constraints/consistency/account/columns.lisp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
acp_DOM_STAMP
1919
acp_SUB_STAMP
2020
;;
21-
acp_REL_BLK_NUM
22-
acp_ABS_TX_NUM
21+
acp_BLK_NUMBER
22+
acp_TOTL_TXN_NUMBER
2323
acp_CODE_FRAGMENT_INDEX
2424
acp_BALANCE
2525
acp_BALANCE_NEW
@@ -55,8 +55,8 @@
5555
(↓ DOM_STAMP )
5656
(↑ SUB_STAMP )
5757
;;
58-
REL_BLK_NUM
59-
ABSOLUTE_TRANSACTION_NUMBER
58+
BLK_NUMBER
59+
TOTL_TXN_NUMBER
6060
account/CODE_FRAGMENT_INDEX
6161
account/BALANCE
6262
account/BALANCE_NEW

hub/cancun/constraints/consistency/account/computed.lisp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@
3838
(fwd-changes-within acp_PEEK_AT_ACCOUNT ;; perspective
3939
acp_ADDRESS_HI ;; columns
4040
acp_ADDRESS_LO
41-
acp_REL_BLK_NUM
41+
acp_BLK_NUMBER
4242
))
4343
(defcomputed
4444
(acp_AGAIN_IN_BLK)
4545
(fwd-unchanged-within acp_PEEK_AT_ACCOUNT ;; perspective
4646
acp_ADDRESS_HI ;; columns
4747
acp_ADDRESS_LO
48-
acp_REL_BLK_NUM
48+
acp_BLK_NUMBER
4949
))
5050
(defcomputed
5151
(acp_FINAL_IN_BLK)
5252
(bwd-changes-within acp_PEEK_AT_ACCOUNT ;; perspective
5353
acp_ADDRESS_HI ;; columns
5454
acp_ADDRESS_LO
55-
acp_REL_BLK_NUM
55+
acp_BLK_NUMBER
5656
))
5757

5858
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -66,21 +66,21 @@
6666
(fwd-changes-within acp_PEEK_AT_ACCOUNT ;; perspective
6767
acp_ADDRESS_HI ;; columns
6868
acp_ADDRESS_LO
69-
acp_ABS_TX_NUM
69+
acp_TOTL_TXN_NUMBER
7070
))
7171
(defcomputed
7272
(acp_AGAIN_IN_TXN)
7373
(fwd-unchanged-within acp_PEEK_AT_ACCOUNT ;; perspective
7474
acp_ADDRESS_HI ;; columns
7575
acp_ADDRESS_LO
76-
acp_ABS_TX_NUM
76+
acp_TOTL_TXN_NUMBER
7777
))
7878
(defcomputed
7979
(acp_FINAL_IN_TXN)
8080
(bwd-changes-within acp_PEEK_AT_ACCOUNT ;; perspective
8181
acp_ADDRESS_HI ;; columns
8282
acp_ADDRESS_LO
83-
acp_ABS_TX_NUM
83+
acp_TOTL_TXN_NUMBER
8484
))
8585

8686

hub/cancun/constraints/consistency/account/constraints.lisp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@
6363
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6464
(begin
6565
(if-not (remained-constant! (acp_full_address)) (eq! (account-consistency---transition-block) 2))
66-
(if-not (remained-constant! acp_REL_BLK_NUM) (eq! (account-consistency---transition-block) 2))
66+
(if-not (remained-constant! acp_BLK_NUMBER) (eq! (account-consistency---transition-block) 2))
6767
(if (remained-constant! (acp_full_address))
68-
(if (remained-constant! acp_REL_BLK_NUM) (eq! (account-consistency---transition-block) 0)))))
68+
(if (remained-constant! acp_BLK_NUMBER) (eq! (account-consistency---transition-block) 0)))))
6969

7070
(defconstraint account-consistency---FIRST-AGAIN-FINAL---repeat-encounter---transaction-level
7171
(:guard (account-consistency---repeat-account-row))
7272
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7373
(begin
7474
(if-not (remained-constant! (acp_full_address)) (eq! (account-consistency---transition-transaction) 2))
75-
(if-not (remained-constant! acp_ABS_TX_NUM) (eq! (account-consistency---transition-transaction) 2))
75+
(if-not (remained-constant! acp_TOTL_TXN_NUMBER) (eq! (account-consistency---transition-transaction) 2))
7676
(if (remained-constant! (acp_full_address))
77-
(if (remained-constant! acp_ABS_TX_NUM) (eq! (account-consistency---transition-transaction) 0)))))
77+
(if (remained-constant! acp_TOTL_TXN_NUMBER) (eq! (account-consistency---transition-transaction) 0)))))
7878

7979
(defconstraint account-consistency---FIRST-AGAIN-FINAL---final-row-with-room-to-spare ()
8080
(if-not-zero (prev acp_PEEK_AT_ACCOUNT)

hub/cancun/constraints/consistency/storage/columns.lisp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
scp_DOM_STAMP
1515
scp_SUB_STAMP
1616
;;
17-
scp_ABS_TX_NUM
18-
scp_REL_BLK_NUM
17+
scp_TOTL_TXN_NUMBER
18+
scp_BLK_NUMBER
1919
scp_VALUE_ORIG_HI
2020
scp_VALUE_ORIG_LO
2121
scp_VALUE_CURR_HI
@@ -43,8 +43,8 @@
4343
(↓ DOM_STAMP )
4444
(↑ SUB_STAMP )
4545
;;
46-
ABSOLUTE_TRANSACTION_NUMBER
47-
REL_BLK_NUM
46+
TOTL_TXN_NUMBER
47+
BLK_NUMBER
4848
storage/VALUE_ORIG_HI
4949
storage/VALUE_ORIG_LO
5050
storage/VALUE_CURR_HI

hub/cancun/constraints/consistency/storage/computed.lisp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
scp_ADDRESS_LO
4646
scp_STORAGE_KEY_HI
4747
scp_STORAGE_KEY_LO
48-
scp_REL_BLK_NUM
48+
scp_BLK_NUMBER
4949
))
5050
(defcomputed
5151
(scp_AGAIN_IN_BLK)
@@ -54,7 +54,7 @@
5454
scp_ADDRESS_LO
5555
scp_STORAGE_KEY_HI
5656
scp_STORAGE_KEY_LO
57-
scp_REL_BLK_NUM
57+
scp_BLK_NUMBER
5858
))
5959
(defcomputed
6060
(scp_FINAL_IN_BLK)
@@ -63,7 +63,7 @@
6363
scp_ADDRESS_LO
6464
scp_STORAGE_KEY_HI
6565
scp_STORAGE_KEY_LO
66-
scp_REL_BLK_NUM
66+
scp_BLK_NUMBER
6767
))
6868

6969
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -79,7 +79,7 @@
7979
scp_ADDRESS_LO
8080
scp_STORAGE_KEY_HI
8181
scp_STORAGE_KEY_LO
82-
scp_ABS_TX_NUM
82+
scp_TOTL_TXN_NUMBER
8383
))
8484
(defcomputed
8585
(scp_AGAIN_IN_TXN)
@@ -88,7 +88,7 @@
8888
scp_ADDRESS_LO
8989
scp_STORAGE_KEY_HI
9090
scp_STORAGE_KEY_LO
91-
scp_ABS_TX_NUM
91+
scp_TOTL_TXN_NUMBER
9292
))
9393
(defcomputed
9494
(scp_FINAL_IN_TXN)
@@ -97,7 +97,7 @@
9797
scp_ADDRESS_LO
9898
scp_STORAGE_KEY_HI
9999
scp_STORAGE_KEY_LO
100-
scp_ABS_TX_NUM
100+
scp_TOTL_TXN_NUMBER
101101
))
102102

103103

@@ -119,7 +119,7 @@
119119
;; target key columns
120120
scp_ADDRESS_HI
121121
scp_ADDRESS_LO
122-
scp_REL_BLK_NUM
122+
scp_BLK_NUMBER
123123

124124
;; source perspective and key/value columns
125125
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -129,7 +129,7 @@
129129
;; source key columns
130130
acp_ADDRESS_HI
131131
acp_ADDRESS_LO
132-
acp_REL_BLK_NUM
132+
acp_BLK_NUMBER
133133
;; source value column
134134
acp_DEPLOYMENT_NUMBER_FIRST_IN_BLOCK
135135
)
@@ -146,7 +146,7 @@
146146
;; target key columns
147147
scp_ADDRESS_HI
148148
scp_ADDRESS_LO
149-
scp_REL_BLK_NUM
149+
scp_BLK_NUMBER
150150

151151
;; source perspective and key/value columns
152152
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -156,7 +156,7 @@
156156
;; source key columns
157157
acp_ADDRESS_HI
158158
acp_ADDRESS_LO
159-
acp_REL_BLK_NUM
159+
acp_BLK_NUMBER
160160
;; source value column
161161
acp_DEPLOYMENT_NUMBER_FINAL_IN_BLOCK
162162
)
@@ -174,7 +174,7 @@
174174
;; target key columns
175175
scp_ADDRESS_HI
176176
scp_ADDRESS_LO
177-
scp_REL_BLK_NUM
177+
scp_BLK_NUMBER
178178

179179
;; source perspective and key/value columns
180180
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -184,7 +184,7 @@
184184
;; source key columns
185185
acp_ADDRESS_HI
186186
acp_ADDRESS_LO
187-
acp_REL_BLK_NUM
187+
acp_BLK_NUMBER
188188
;; source value column
189189
acp_EXISTS_FIRST_IN_BLOCK
190190
)
@@ -201,7 +201,7 @@
201201
;; target key columns
202202
scp_ADDRESS_HI
203203
scp_ADDRESS_LO
204-
scp_REL_BLK_NUM
204+
scp_BLK_NUMBER
205205

206206
;; source perspective and key/value columns
207207
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -211,7 +211,7 @@
211211
;; source key columns
212212
acp_ADDRESS_HI
213213
acp_ADDRESS_LO
214-
acp_REL_BLK_NUM
214+
acp_BLK_NUMBER
215215
;; source value column
216216
acp_EXISTS_FINAL_IN_BLOCK
217217
)

hub/cancun/constraints/consistency/storage/constraints.lisp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262

6363
(defconstraint storage-consistency---FIRST-AGAIN-FINAL---repeat-encounter-of-storage-slot (:guard (* scp_PEEK_AT_STORAGE (- 1 scp_FIRST_IN_CNF)))
6464
(begin
65-
(if-not (remained-constant! scp_REL_BLK_NUM)
65+
(if-not (remained-constant! scp_BLK_NUMBER)
6666
(eq! (storage-consistency---transtion-block) 2)
6767
(eq! (storage-consistency---transtion-block) 0))
68-
(if-not (remained-constant! scp_ABS_TX_NUM)
68+
(if-not (remained-constant! scp_TOTL_TXN_NUMBER)
6969
(eq! (storage-consistency---transtion-transaction) 2)
7070
(eq! (storage-consistency---transtion-transaction) 0))))
7171

0 commit comments

Comments
 (0)