@@ -4,11 +4,14 @@ import (
44 "context"
55 "fmt"
66
7+ "github.com/rs/zerolog"
8+
79 "github.com/onflow/flow-go/admin"
810 "github.com/onflow/flow-go/admin/commands"
911 "github.com/onflow/flow-go/engine/access/ingestion/tx_error_messages"
1012 "github.com/onflow/flow-go/model/flow"
1113 "github.com/onflow/flow-go/model/flow/filter"
14+ "github.com/onflow/flow-go/module/util"
1215 "github.com/onflow/flow-go/state/protocol"
1316)
1417
@@ -25,16 +28,19 @@ type backfillTxErrorMessagesRequest struct {
2528// BackfillTxErrorMessagesCommand executes a command to backfill
2629// transaction error messages by fetching them from execution nodes.
2730type BackfillTxErrorMessagesCommand struct {
31+ log zerolog.Logger
2832 state protocol.State
2933 txErrorMessagesCore * tx_error_messages.TxErrorMessagesCore
3034}
3135
3236// NewBackfillTxErrorMessagesCommand creates a new instance of BackfillTxErrorMessagesCommand
3337func NewBackfillTxErrorMessagesCommand (
38+ log zerolog.Logger ,
3439 state protocol.State ,
3540 txErrorMessagesCore * tx_error_messages.TxErrorMessagesCore ,
3641) commands.AdminCommand {
3742 return & BackfillTxErrorMessagesCommand {
43+ log : log .With ().Str ("command" , "backfill-tx-error-messages" ).Logger (),
3844 state : state ,
3945 txErrorMessagesCore : txErrorMessagesCore ,
4046 }
@@ -147,6 +153,17 @@ func (b *BackfillTxErrorMessagesCommand) Handler(ctx context.Context, request *a
147153
148154 data := request .ValidatorData .(* backfillTxErrorMessagesRequest )
149155
156+ total := data .endHeight - data .startHeight + 1
157+ progress := util .LogProgress (b .log ,
158+ util .DefaultLogProgressConfig ("backfilling" , int (total )),
159+ )
160+
161+ b .log .Info ().
162+ Uint64 ("start_height" , data .startHeight ).
163+ Uint64 ("end_height" , data .endHeight ).
164+ Uint64 ("blocks" , total ).
165+ Msgf ("starting backfill" )
166+
150167 for height := data .startHeight ; height <= data .endHeight ; height ++ {
151168 header , err := b .state .AtHeight (height ).Head ()
152169 if err != nil {
@@ -158,6 +175,8 @@ func (b *BackfillTxErrorMessagesCommand) Handler(ctx context.Context, request *a
158175 if err != nil {
159176 return nil , fmt .Errorf ("error encountered while processing transaction result error message for block: %d, %w" , height , err )
160177 }
178+
179+ progress (1 )
161180 }
162181
163182 return nil , nil
@@ -170,13 +189,18 @@ func (b *BackfillTxErrorMessagesCommand) Handler(ctx context.Context, request *a
170189// - admin.InvalidAdminReqParameterError - if execution-node-ids is empty or has an invalid format.
171190func (b * BackfillTxErrorMessagesCommand ) parseExecutionNodeIds (executionNodeIdsIn interface {}, allIdentities flow.IdentityList ) (flow.IdentitySkeletonList , error ) {
172191 var ids flow.IdentityList
173-
174192 switch executionNodeIds := executionNodeIdsIn .(type ) {
175- case []string :
193+ case []any :
176194 if len (executionNodeIds ) == 0 {
177195 return nil , admin .NewInvalidAdminReqParameterError ("execution-node-ids" , "must be a non empty list of strings" , executionNodeIdsIn )
178196 }
179- requestedENIdentifiers , err := flow .IdentifierListFromHex (executionNodeIds )
197+
198+ idStrings := make ([]string , len (executionNodeIds ))
199+ for i , id := range executionNodeIds {
200+ idStrings [i ] = id .(string )
201+ }
202+
203+ requestedENIdentifiers , err := flow .IdentifierListFromHex (idStrings )
180204 if err != nil {
181205 return nil , admin .NewInvalidAdminReqParameterError ("execution-node-ids" , err .Error (), executionNodeIdsIn )
182206 }
0 commit comments