@@ -88,37 +88,8 @@ func (d *executionRewardsFinalizer) maintainTable() (err error) {
8888 log .Debugf ("no new finalized slots to export" )
8989 return nil
9090 }
91- // sanity check, check if any non-missed block has a fee_recipient_reward that is NULL
92- var count struct {
93- Total int64 `db:"total"`
94- NonNull int64 `db:"non_null"`
95- }
96- gc := goqu .Dialect ("postgres" ).From ("blocks" ).
97- Select (
98- goqu .Func ("count" , goqu .Star ()).As ("total" ),
99- goqu .Func ("count" , goqu .I ("ep.fee_recipient_reward" )).As ("non_null" ),
100- ).
101- LeftJoin (
102- goqu .T ("execution_payloads" ).As ("ep" ),
103- goqu .On (goqu .I ("ep.block_hash" ).Eq (goqu .I ("blocks.exec_block_hash" ))),
104- ).
105- Where (
106- goqu .I ("slot" ).Gt (lastExportedSlot ),
107- goqu .I ("slot" ).Lte (latestFinalizedSlot ),
108- goqu .I ("status" ).Eq ("1" ),
109- )
110- query , args , err := gc .Prepared (true ).ToSQL ()
111- if err != nil {
112- return fmt .Errorf ("error preparing query: %w" , err )
113- }
114- err = db .ReaderDb .Get (& count , query , args ... )
115- if err != nil {
116- return fmt .Errorf ("error getting count of non-missed blocks: %w" , err )
117- }
118- if count .Total != count .NonNull {
119- return fmt .Errorf ("only %v out of %v blocks have non-null fee_recipient_reward" , count .NonNull , count .Total )
120- }
12191 log .Infof ("finalized rewards = last exported slot: %v, latest finalized slot: %v" , lastExportedSlot , latestFinalizedSlot )
92+
12293 start := time .Now ()
12394 ds := goqu .Dialect ("postgres" ).Insert ("execution_rewards_finalized" ).FromQuery (
12495 goqu .From (goqu .T ("blocks" ).As ("b" )).
@@ -151,11 +122,12 @@ func (d *executionRewardsFinalizer) maintainTable() (err error) {
151122
152123 log .Debugf ("writing execution rewards finalized data" )
153124
154- query , args , err = ds .Prepared (true ).ToSQL ()
125+ query , args , err : = ds .Prepared (true ).ToSQL ()
155126 if err != nil {
156127 return fmt .Errorf ("error preparing query: %w" , err )
157128 }
158129 _ , err = db .WriterDb .Exec (query , args ... )
130+
159131 if err != nil {
160132 return fmt .Errorf ("error inserting data: %w" , err )
161133 }
0 commit comments