@@ -28,18 +28,15 @@ const watchForwarderBuffer = 64
2828// finalised block; used as the "block number" arg to HeaderByNumber.
2929var gethFinalizedBlockNumber = new (big.Int ).SetInt64 (rpc .FinalizedBlockNumber .Int64 ())
3030
31- // GethSettlement is the go-ethereum-backed implementation of
32- // SettlementLayer. It wraps go-ethereum's ethclient plus the abigen-
33- // generated StarknetFilterer to talk to the Starknet core L1 bridge.
31+ // GethSettlement is the go-ethereum-backed SettlementLayer, wrapping
32+ // ethclient plus the abigen StarknetFilterer to talk to the Starknet
33+ // core L1 bridge. It also satisfies rpccore.L1Client (via
34+ // TransactionReceipt), so node.go hands one instance to both the L1
35+ // sync loop and the RPC handlers.
3436//
35- // The same instance also satisfies rpccore.L1Client via
36- // TransactionReceipt, so node.go can construct one client and hand it
37- // to both the L1 sync loop and the RPC handlers.
38- //
39- // go-ethereum's rpc.Client transparently reconnects unary calls over
40- // the WS transport, and any active subscription propagates the drop
41- // via its Err() channel, which the upper-layer resubscribe loop in
42- // l1.Client.watchL1StateUpdates already handles.
37+ // WS connection drops are recovered below this layer: rpc.Client
38+ // reconnects unary calls, and subscription drops surface on Err() for
39+ // l1.Client.watchL1StateUpdates to resubscribe.
4340type GethSettlement struct {
4441 contractAddress eth.Address
4542 url string
@@ -94,19 +91,16 @@ type gethSettlementOptions struct {
9491 listener EventListener
9592}
9693
97- // WithSettlementListener sets the EventListener that fires OnL1Call for
98- // every Ethereum RPC method. Defaults to a no-op SelectiveListener.
99- //
100- // The listener is supplied at construction because the field is read
101- // unlocked from every RPC method, so it must not be mutated once the
102- // settlement is handed off to a goroutine (i.e. l1.NewClient in node.go).
94+ // WithSettlementListener sets the EventListener that fires OnL1Call on
95+ // every Ethereum RPC method (default: no-op). Set at construction: the
96+ // listener field is read unlocked from every RPC method, so it must not
97+ // be mutated once the settlement is shared with a goroutine.
10398func WithSettlementListener (l EventListener ) GethSettlementOption {
10499 return func (o * gethSettlementOptions ) { o .listener = l }
105100}
106101
107- // observe wraps an RPC call so OnL1Call fires on both success and
108- // failure paths — error rates and latency under failure are as
109- // interesting to monitor as success.
102+ // observe reports OnL1Call latency on return, on both success and
103+ // failure paths.
110104func (s * GethSettlement ) observe (method string ) func () {
111105 t := time .Now ()
112106 return func () { s .listener .OnL1Call (method , time .Since (t )) }
@@ -224,9 +218,8 @@ func stateUpdateFromGethContract(ev *contract.StarknetLogStateUpdate) *StateUpda
224218 }
225219}
226220
227- // gethReceiptToEth shallow-copies the fields of a geth receipt that juno
228- // actually reads. Today only Logs is consumed, but every nested Log is
229- // converted so the shape matches juno's own eth.Receipt type exactly.
221+ // gethReceiptToEth copies the receipt fields juno reads. Only Logs is
222+ // consumed today; a consumer needing other fields must extend this.
230223func gethReceiptToEth (r * types.Receipt ) * eth.Receipt {
231224 logs := make ([]eth.Log , len (r .Logs ))
232225 for i , l := range r .Logs {
@@ -248,12 +241,11 @@ func gethLogToEth(l *types.Log) eth.Log {
248241 }
249242}
250243
251- // forwardStateUpdates returns a subscription whose goroutine decodes each
252- // contract.StarknetLogStateUpdate event into a neutral StateUpdate and
253- // forwards it to sink, until the inner subscription errors or the caller
254- // unsubscribes. The subscription lifecycle (once-only close, idempotent
255- // Unsubscribe, error delivery, goroutine teardown) is handled by
256- // event.NewSubscription; this only owns the type translation.
244+ // forwardStateUpdates returns a subscription that decodes each raw event
245+ // into a StateUpdate and forwards it to sink, until inner errors or the
246+ // caller unsubscribes. Lifecycle (close, Unsubscribe, error delivery,
247+ // teardown) is owned by event.NewSubscription; this adds only the type
248+ // translation and the stall-vs-quit select.
257249func forwardStateUpdates (
258250 inner event.Subscription ,
259251 raw <- chan * contract.StarknetLogStateUpdate ,
@@ -278,8 +270,7 @@ func forwardStateUpdates(
278270 })
279271}
280272
281- // Compile-time assertions: GethSettlement satisfies both interfaces it
282- // is intended to serve.
273+ // GethSettlement must satisfy both interfaces it serves.
283274var (
284275 _ SettlementLayer = (* GethSettlement )(nil )
285276 _ rpccore.L1Client = (* GethSettlement )(nil )
0 commit comments