Skip to content

Commit bc630c2

Browse files
authored
Merge branch 'main' into julien/catchup-base
2 parents 90b5ee9 + 1da7634 commit bc630c2

35 files changed

Lines changed: 404 additions & 182 deletions

apps/evm/go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ require (
135135
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
136136
github.com/pion/datachannel v1.5.10 // indirect
137137
github.com/pion/dtls/v2 v2.2.12 // indirect
138-
github.com/pion/dtls/v3 v3.0.6 // indirect
138+
github.com/pion/dtls/v3 v3.0.11 // indirect
139139
github.com/pion/ice/v4 v4.0.10 // indirect
140140
github.com/pion/interceptor v0.1.40 // indirect
141-
github.com/pion/logging v0.2.3 // indirect
141+
github.com/pion/logging v0.2.4 // indirect
142142
github.com/pion/mdns/v2 v2.0.7 // indirect
143143
github.com/pion/randutil v0.1.0 // indirect
144144
github.com/pion/rtcp v1.2.15 // indirect
@@ -150,6 +150,7 @@ require (
150150
github.com/pion/stun/v3 v3.0.0 // indirect
151151
github.com/pion/transport/v2 v2.2.10 // indirect
152152
github.com/pion/transport/v3 v3.0.7 // indirect
153+
github.com/pion/transport/v4 v4.0.1 // indirect
153154
github.com/pion/turn/v4 v4.0.2 // indirect
154155
github.com/pion/webrtc/v4 v4.1.2 // indirect
155156
github.com/pkg/errors v0.9.1 // indirect

apps/evm/go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,15 +869,15 @@ github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oL
869869
github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s=
870870
github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk=
871871
github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE=
872-
github.com/pion/dtls/v3 v3.0.6 h1:7Hkd8WhAJNbRgq9RgdNh1aaWlZlGpYTzdqjy9x9sK2E=
873-
github.com/pion/dtls/v3 v3.0.6/go.mod h1:iJxNQ3Uhn1NZWOMWlLxEEHAN5yX7GyPvvKw04v9bzYU=
872+
github.com/pion/dtls/v3 v3.0.11 h1:zqn8YhoAU7d9whsWLhNiQlbB8QdpJj8XQVSc5ImUons=
873+
github.com/pion/dtls/v3 v3.0.11/go.mod h1:YEmmBYIoBsY3jmG56dsziTv/Lca9y4Om83370CXfqJ8=
874874
github.com/pion/ice/v4 v4.0.10 h1:P59w1iauC/wPk9PdY8Vjl4fOFL5B+USq1+xbDcN6gT4=
875875
github.com/pion/ice/v4 v4.0.10/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
876876
github.com/pion/interceptor v0.1.40 h1:e0BjnPcGpr2CFQgKhrQisBU7V3GXK6wrfYrGYaU6Jq4=
877877
github.com/pion/interceptor v0.1.40/go.mod h1:Z6kqH7M/FYirg3frjGJ21VLSRJGBXB/KqaTIrdqnOic=
878878
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
879-
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
880-
github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90=
879+
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
880+
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
881881
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM=
882882
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA=
883883
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
@@ -904,6 +904,8 @@ github.com/pion/transport/v2 v2.2.10 h1:ucLBLE8nuxiHfvkFKnkDQRYWYfp8ejf4YBOPfaQp
904904
github.com/pion/transport/v2 v2.2.10/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E=
905905
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0=
906906
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
907+
github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
908+
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
907909
github.com/pion/turn/v4 v4.0.2 h1:ZqgQ3+MjP32ug30xAbD6Mn+/K4Sxi3SdNOTFf+7mpps=
908910
github.com/pion/turn/v4 v4.0.2/go.mod h1:pMMKP/ieNAG/fN5cZiN4SDuyKsXtNTr0ccN7IToA1zs=
909911
github.com/pion/webrtc/v4 v4.1.2 h1:mpuUo/EJ1zMNKGE79fAdYNFZBX790KE7kQQpLMjjR54=

apps/grpc/go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ require (
114114
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
115115
github.com/pion/datachannel v1.5.10 // indirect
116116
github.com/pion/dtls/v2 v2.2.12 // indirect
117-
github.com/pion/dtls/v3 v3.0.6 // indirect
117+
github.com/pion/dtls/v3 v3.0.11 // indirect
118118
github.com/pion/ice/v4 v4.0.10 // indirect
119119
github.com/pion/interceptor v0.1.40 // indirect
120-
github.com/pion/logging v0.2.3 // indirect
120+
github.com/pion/logging v0.2.4 // indirect
121121
github.com/pion/mdns/v2 v2.0.7 // indirect
122122
github.com/pion/randutil v0.1.0 // indirect
123123
github.com/pion/rtcp v1.2.15 // indirect
@@ -129,6 +129,7 @@ require (
129129
github.com/pion/stun/v3 v3.0.0 // indirect
130130
github.com/pion/transport/v2 v2.2.10 // indirect
131131
github.com/pion/transport/v3 v3.0.7 // indirect
132+
github.com/pion/transport/v4 v4.0.1 // indirect
132133
github.com/pion/turn/v4 v4.0.2 // indirect
133134
github.com/pion/webrtc/v4 v4.1.2 // indirect
134135
github.com/pkg/errors v0.9.1 // indirect

apps/grpc/go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -790,15 +790,15 @@ github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oL
790790
github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s=
791791
github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk=
792792
github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE=
793-
github.com/pion/dtls/v3 v3.0.6 h1:7Hkd8WhAJNbRgq9RgdNh1aaWlZlGpYTzdqjy9x9sK2E=
794-
github.com/pion/dtls/v3 v3.0.6/go.mod h1:iJxNQ3Uhn1NZWOMWlLxEEHAN5yX7GyPvvKw04v9bzYU=
793+
github.com/pion/dtls/v3 v3.0.11 h1:zqn8YhoAU7d9whsWLhNiQlbB8QdpJj8XQVSc5ImUons=
794+
github.com/pion/dtls/v3 v3.0.11/go.mod h1:YEmmBYIoBsY3jmG56dsziTv/Lca9y4Om83370CXfqJ8=
795795
github.com/pion/ice/v4 v4.0.10 h1:P59w1iauC/wPk9PdY8Vjl4fOFL5B+USq1+xbDcN6gT4=
796796
github.com/pion/ice/v4 v4.0.10/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
797797
github.com/pion/interceptor v0.1.40 h1:e0BjnPcGpr2CFQgKhrQisBU7V3GXK6wrfYrGYaU6Jq4=
798798
github.com/pion/interceptor v0.1.40/go.mod h1:Z6kqH7M/FYirg3frjGJ21VLSRJGBXB/KqaTIrdqnOic=
799799
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
800-
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
801-
github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90=
800+
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
801+
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
802802
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM=
803803
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA=
804804
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
@@ -823,6 +823,8 @@ github.com/pion/transport/v2 v2.2.10 h1:ucLBLE8nuxiHfvkFKnkDQRYWYfp8ejf4YBOPfaQp
823823
github.com/pion/transport/v2 v2.2.10/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E=
824824
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0=
825825
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
826+
github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
827+
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
826828
github.com/pion/turn/v4 v4.0.2 h1:ZqgQ3+MjP32ug30xAbD6Mn+/K4Sxi3SdNOTFf+7mpps=
827829
github.com/pion/turn/v4 v4.0.2/go.mod h1:pMMKP/ieNAG/fN5cZiN4SDuyKsXtNTr0ccN7IToA1zs=
828830
github.com/pion/webrtc/v4 v4.1.2 h1:mpuUo/EJ1zMNKGE79fAdYNFZBX790KE7kQQpLMjjR54=

apps/testapp/go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ require (
113113
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
114114
github.com/pion/datachannel v1.5.10 // indirect
115115
github.com/pion/dtls/v2 v2.2.12 // indirect
116-
github.com/pion/dtls/v3 v3.0.6 // indirect
116+
github.com/pion/dtls/v3 v3.0.11 // indirect
117117
github.com/pion/ice/v4 v4.0.10 // indirect
118118
github.com/pion/interceptor v0.1.40 // indirect
119-
github.com/pion/logging v0.2.3 // indirect
119+
github.com/pion/logging v0.2.4 // indirect
120120
github.com/pion/mdns/v2 v2.0.7 // indirect
121121
github.com/pion/randutil v0.1.0 // indirect
122122
github.com/pion/rtcp v1.2.15 // indirect
@@ -128,6 +128,7 @@ require (
128128
github.com/pion/stun/v3 v3.0.0 // indirect
129129
github.com/pion/transport/v2 v2.2.10 // indirect
130130
github.com/pion/transport/v3 v3.0.7 // indirect
131+
github.com/pion/transport/v4 v4.0.1 // indirect
131132
github.com/pion/turn/v4 v4.0.2 // indirect
132133
github.com/pion/webrtc/v4 v4.1.2 // indirect
133134
github.com/pkg/errors v0.9.1 // indirect

apps/testapp/go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -790,15 +790,15 @@ github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oL
790790
github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s=
791791
github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk=
792792
github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE=
793-
github.com/pion/dtls/v3 v3.0.6 h1:7Hkd8WhAJNbRgq9RgdNh1aaWlZlGpYTzdqjy9x9sK2E=
794-
github.com/pion/dtls/v3 v3.0.6/go.mod h1:iJxNQ3Uhn1NZWOMWlLxEEHAN5yX7GyPvvKw04v9bzYU=
793+
github.com/pion/dtls/v3 v3.0.11 h1:zqn8YhoAU7d9whsWLhNiQlbB8QdpJj8XQVSc5ImUons=
794+
github.com/pion/dtls/v3 v3.0.11/go.mod h1:YEmmBYIoBsY3jmG56dsziTv/Lca9y4Om83370CXfqJ8=
795795
github.com/pion/ice/v4 v4.0.10 h1:P59w1iauC/wPk9PdY8Vjl4fOFL5B+USq1+xbDcN6gT4=
796796
github.com/pion/ice/v4 v4.0.10/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
797797
github.com/pion/interceptor v0.1.40 h1:e0BjnPcGpr2CFQgKhrQisBU7V3GXK6wrfYrGYaU6Jq4=
798798
github.com/pion/interceptor v0.1.40/go.mod h1:Z6kqH7M/FYirg3frjGJ21VLSRJGBXB/KqaTIrdqnOic=
799799
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
800-
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
801-
github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90=
800+
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
801+
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
802802
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM=
803803
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA=
804804
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
@@ -823,6 +823,8 @@ github.com/pion/transport/v2 v2.2.10 h1:ucLBLE8nuxiHfvkFKnkDQRYWYfp8ejf4YBOPfaQp
823823
github.com/pion/transport/v2 v2.2.10/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E=
824824
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0=
825825
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
826+
github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
827+
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
826828
github.com/pion/turn/v4 v4.0.2 h1:ZqgQ3+MjP32ug30xAbD6Mn+/K4Sxi3SdNOTFf+7mpps=
827829
github.com/pion/turn/v4 v4.0.2/go.mod h1:pMMKP/ieNAG/fN5cZiN4SDuyKsXtNTr0ccN7IToA1zs=
828830
github.com/pion/webrtc/v4 v4.1.2 h1:mpuUo/EJ1zMNKGE79fAdYNFZBX790KE7kQQpLMjjR54=

block/components_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func TestNewAggregatorComponents_Creation(t *testing.T) {
176176
zerolog.Nop(),
177177
NopMetrics(),
178178
DefaultBlockOptions(),
179-
nil,
179+
nil, // raftNode
180180
)
181181

182182
require.NoError(t, err)
@@ -260,7 +260,7 @@ func TestExecutor_RealExecutionClientFailure_StopsNode(t *testing.T) {
260260
zerolog.Nop(),
261261
NopMetrics(),
262262
DefaultBlockOptions(),
263-
nil,
263+
nil, // raftNode
264264
)
265265
require.NoError(t, err)
266266

block/internal/cache/generic_cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func TestCache_DeleteAllForHeight(t *testing.T) {
225225
assert.True(t, c.isSeen("hash2"))
226226
}
227227

228-
// TestCacheWithConfig tests creating cache with custom config
228+
// TestCache_WithNilStore tests creating cache with nil store
229229
func TestCache_WithNilStore(t *testing.T) {
230230
// Cache without store should work fine
231231
c := NewCache[testItem](nil, "")

block/internal/executing/executor.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ func (e *Executor) initializeState() error {
270270
e.logger.Info().Uint64("height", state.LastBlockHeight).
271271
Str("chain_id", state.ChainID).Msg("initialized state")
272272

273+
// Migrate any old-style pending block (stored at height N+1 via SaveBlockData
274+
// with empty signature) to the new metadata-key format.
275+
// Todo remove in the future: https://github.com/evstack/ev-node/issues/2795
276+
if err := e.migrateLegacyPendingBlock(e.ctx); err != nil {
277+
return fmt.Errorf("failed to migrate legacy pending block: %w", err)
278+
}
279+
273280
// Determine sync target: use Raft height if node is behind Raft consensus
274281
syncTargetHeight := state.LastBlockHeight
275282
if e.raftNode != nil {
@@ -429,12 +436,12 @@ func (e *Executor) ProduceBlock(ctx context.Context) error {
429436

430437
// Check if there's an already stored block at the newHeight
431438
// If there is use that instead of creating a new block
432-
pendingHeader, pendingData, err := e.store.GetBlockData(ctx, newHeight)
433-
if err == nil {
439+
pendingHeader, pendingData, err := e.getPendingBlock(ctx)
440+
if err == nil && pendingHeader != nil && pendingHeader.Height() == newHeight {
434441
e.logger.Info().Uint64("height", newHeight).Msg("using pending block")
435442
header = pendingHeader
436443
data = pendingData
437-
} else if !errors.Is(err, datastore.ErrNotFound) {
444+
} else if err != nil && !errors.Is(err, datastore.ErrNotFound) {
438445
return fmt.Errorf("failed to get block data: %w", err)
439446
} else {
440447
// get batch from sequencer
@@ -452,18 +459,9 @@ func (e *Executor) ProduceBlock(ctx context.Context) error {
452459
if err != nil {
453460
return fmt.Errorf("failed to create block: %w", err)
454461
}
455-
456-
// saved early for crash recovery, will be overwritten later with the final signature
457-
batch, err := e.store.NewBatch(ctx)
458-
if err != nil {
459-
return fmt.Errorf("failed to create batch for early save: %w", err)
460-
}
461-
if err = batch.SaveBlockData(header, data, &types.Signature{}); err != nil {
462+
if err := e.savePendingBlock(ctx, header, data); err != nil {
462463
return fmt.Errorf("failed to save block data: %w", err)
463464
}
464-
if err = batch.Commit(); err != nil {
465-
return fmt.Errorf("failed to commit early save batch: %w", err)
466-
}
467465
}
468466

469467
if e.raftNode != nil && !e.raftNode.HasQuorum() {
@@ -535,6 +533,10 @@ func (e *Executor) ProduceBlock(ctx context.Context) error {
535533
}
536534
e.logger.Debug().Uint64("height", newHeight).Msg("proposed block to raft")
537535
}
536+
if err := e.deletePendingBlock(batch); err != nil {
537+
e.logger.Warn().Err(err).Uint64("height", newHeight).Msg("failed to delete pending block metadata")
538+
}
539+
538540
if err := batch.Commit(); err != nil {
539541
return fmt.Errorf("failed to commit batch: %w", err)
540542
}

block/internal/executing/executor_restart_test.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestExecutor_RestartUsesPendingHeader(t *testing.T) {
7979
require.NoError(t, exec1.initializeState())
8080

8181
// Set up context for first executor
82-
exec1.ctx, exec1.cancel = context.WithCancel(context.Background())
82+
exec1.ctx, exec1.cancel = context.WithCancel(t.Context())
8383

8484
// First executor produces a block normally
8585
mockSeq1.EXPECT().GetNextBatch(mock.Anything, mock.AnythingOfType("sequencer.GetNextBatchRequest")).
@@ -101,12 +101,12 @@ func TestExecutor_RestartUsesPendingHeader(t *testing.T) {
101101
require.NoError(t, err)
102102

103103
// Verify first block was produced
104-
h1, err := memStore.Height(context.Background())
104+
h1, err := memStore.Height(t.Context())
105105
require.NoError(t, err)
106106
assert.Equal(t, uint64(1), h1)
107107

108108
// Store the produced block data for later verification
109-
originalHeader, originalData, err := memStore.GetBlockData(context.Background(), 1)
109+
originalHeader, originalData, err := memStore.GetBlockData(t.Context(), 1)
110110
require.NoError(t, err)
111111
assert.Equal(t, 2, len(originalData.Txs), "first block should have 2 transactions")
112112

@@ -158,11 +158,7 @@ func TestExecutor_RestartUsesPendingHeader(t *testing.T) {
158158
pendingHeader.DataHash = pendingData.DACommitment()
159159

160160
// Save pending block data (this is what would happen during a crash)
161-
batch, err := memStore.NewBatch(context.Background())
162-
require.NoError(t, err)
163-
err = batch.SaveBlockData(pendingHeader, pendingData, &types.Signature{})
164-
require.NoError(t, err)
165-
err = batch.Commit()
161+
err = exec1.savePendingBlock(t.Context(), pendingHeader, pendingData)
166162
require.NoError(t, err)
167163

168164
// Stop first executor (simulating crash/restart)
@@ -199,7 +195,7 @@ func TestExecutor_RestartUsesPendingHeader(t *testing.T) {
199195
require.NoError(t, exec2.initializeState())
200196

201197
// Set up context for second executor
202-
exec2.ctx, exec2.cancel = context.WithCancel(context.Background())
198+
exec2.ctx, exec2.cancel = context.WithCancel(t.Context())
203199
defer exec2.cancel()
204200

205201
// Verify that the state is at height 1 (pending block at height 2 wasn't committed)
@@ -221,12 +217,12 @@ func TestExecutor_RestartUsesPendingHeader(t *testing.T) {
221217
require.NoError(t, err)
222218

223219
// Verify height advanced to 2
224-
h2, err := memStore.Height(context.Background())
220+
h2, err := memStore.Height(t.Context())
225221
require.NoError(t, err)
226222
assert.Equal(t, uint64(2), h2, "height should advance to 2 using pending block")
227223

228224
// Verify the block at height 2 matches the pending block data
229-
finalHeader, finalData, err := memStore.GetBlockData(context.Background(), 2)
225+
finalHeader, finalData, err := memStore.GetBlockData(t.Context(), 2)
230226
require.NoError(t, err)
231227
assert.Equal(t, 3, len(finalData.Txs), "should use pending block with 3 transactions")
232228
assert.Equal(t, []byte("pending_tx1"), []byte(finalData.Txs[0]))
@@ -388,7 +384,7 @@ func TestExecutor_RestartNoPendingHeader(t *testing.T) {
388384
require.NoError(t, err)
389385

390386
// Verify normal operation
391-
h, err := memStore.Height(context.Background())
387+
h, err := memStore.Height(t.Context())
392388
require.NoError(t, err)
393389
assert.Equal(t, uint64(numBlocks+1), h)
394390

0 commit comments

Comments
 (0)