@@ -1094,6 +1094,51 @@ func (eval *BlockEvaluator) endOfBlock() error {
1094
1094
return err
1095
1095
}
1096
1096
1097
+ eval .state .mods .OptimizeAllocatedMemory (eval .proto )
1098
+
1099
+ if eval .validate {
1100
+ // check commitments
1101
+ txnRoot , err := eval .block .PaysetCommit ()
1102
+ if err != nil {
1103
+ return err
1104
+ }
1105
+ if txnRoot != eval .block .TxnRoot {
1106
+ return fmt .Errorf ("txn root wrong: %v != %v" , txnRoot , eval .block .TxnRoot )
1107
+ }
1108
+
1109
+ var expectedTxnCount uint64
1110
+ if eval .proto .TxnCounter {
1111
+ expectedTxnCount = eval .state .txnCounter ()
1112
+ }
1113
+ if eval .block .TxnCounter != expectedTxnCount {
1114
+ return fmt .Errorf ("txn count wrong: %d != %d" , eval .block .TxnCounter , expectedTxnCount )
1115
+ }
1116
+
1117
+ expectedVoters , expectedVotersWeight , err := eval .compactCertVotersAndTotal ()
1118
+ if err != nil {
1119
+ return err
1120
+ }
1121
+ if eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertVoters != expectedVoters {
1122
+ return fmt .Errorf ("CompactCertVoters wrong: %v != %v" , eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertVoters , expectedVoters )
1123
+ }
1124
+ if eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertVotersTotal != expectedVotersWeight {
1125
+ return fmt .Errorf ("CompactCertVotersTotal wrong: %v != %v" , eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertVotersTotal , expectedVotersWeight )
1126
+ }
1127
+ if eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertNextRound != eval .state .compactCertNext () {
1128
+ return fmt .Errorf ("CompactCertNextRound wrong: %v != %v" , eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertNextRound , eval .state .compactCertNext ())
1129
+ }
1130
+ for ccType := range eval .block .CompactCert {
1131
+ if ccType != protocol .CompactCertBasic {
1132
+ return fmt .Errorf ("CompactCertType %d unexpected" , ccType )
1133
+ }
1134
+ }
1135
+ }
1136
+
1137
+ err = eval .state .CalculateTotals ()
1138
+ if err != nil {
1139
+ return err
1140
+ }
1141
+
1097
1142
return nil
1098
1143
}
1099
1144
@@ -1189,7 +1234,6 @@ func (eval *BlockEvaluator) validateExpiredOnlineAccounts() error {
1189
1234
1190
1235
// resetExpiredOnlineAccountsParticipationKeys after all transactions and rewards are processed, modify the accounts so that their status is offline
1191
1236
func (eval * BlockEvaluator ) resetExpiredOnlineAccountsParticipationKeys () error {
1192
-
1193
1237
expectedMaxNumberOfExpiredAccounts := eval .proto .MaxProposedExpiredOnlineAccounts
1194
1238
lengthOfExpiredParticipationAccounts := len (eval .block .ParticipationUpdates .ExpiredParticipationAccounts )
1195
1239
@@ -1218,51 +1262,6 @@ func (eval *BlockEvaluator) resetExpiredOnlineAccountsParticipationKeys() error
1218
1262
return nil
1219
1263
}
1220
1264
1221
- // FinalValidation does the validation that must happen after the block is built and all state updates are computed
1222
- func (eval * BlockEvaluator ) finalValidation () error {
1223
- eval .state .mods .OptimizeAllocatedMemory (eval .proto )
1224
- if eval .validate {
1225
- // check commitments
1226
- txnRoot , err := eval .block .PaysetCommit ()
1227
- if err != nil {
1228
- return err
1229
- }
1230
- if txnRoot != eval .block .TxnRoot {
1231
- return fmt .Errorf ("txn root wrong: %v != %v" , txnRoot , eval .block .TxnRoot )
1232
- }
1233
-
1234
- var expectedTxnCount uint64
1235
- if eval .proto .TxnCounter {
1236
- expectedTxnCount = eval .state .txnCounter ()
1237
- }
1238
- if eval .block .TxnCounter != expectedTxnCount {
1239
- return fmt .Errorf ("txn count wrong: %d != %d" , eval .block .TxnCounter , expectedTxnCount )
1240
- }
1241
-
1242
- expectedVoters , expectedVotersWeight , err := eval .compactCertVotersAndTotal ()
1243
- if err != nil {
1244
- return err
1245
- }
1246
- if eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertVoters != expectedVoters {
1247
- return fmt .Errorf ("CompactCertVoters wrong: %v != %v" , eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertVoters , expectedVoters )
1248
- }
1249
- if eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertVotersTotal != expectedVotersWeight {
1250
- return fmt .Errorf ("CompactCertVotersTotal wrong: %v != %v" , eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertVotersTotal , expectedVotersWeight )
1251
- }
1252
- if eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertNextRound != eval .state .compactCertNext () {
1253
- return fmt .Errorf ("CompactCertNextRound wrong: %v != %v" , eval .block .CompactCert [protocol .CompactCertBasic ].CompactCertNextRound , eval .state .compactCertNext ())
1254
- }
1255
- for ccType := range eval .block .CompactCert {
1256
- if ccType != protocol .CompactCertBasic {
1257
- return fmt .Errorf ("CompactCertType %d unexpected" , ccType )
1258
- }
1259
- }
1260
-
1261
- }
1262
-
1263
- return eval .state .CalculateTotals ()
1264
- }
1265
-
1266
1265
// GenerateBlock produces a complete block from the BlockEvaluator. This is
1267
1266
// used during proposal to get an actual block that will be proposed, after
1268
1267
// feeding in tentative transactions into this block evaluator.
@@ -1284,11 +1283,6 @@ func (eval *BlockEvaluator) GenerateBlock() (*ledgercore.ValidatedBlock, error)
1284
1283
return nil , err
1285
1284
}
1286
1285
1287
- err = eval .finalValidation ()
1288
- if err != nil {
1289
- return nil , err
1290
- }
1291
-
1292
1286
vb := ledgercore .MakeValidatedBlock (eval .block , eval .state .deltas ())
1293
1287
eval .blockGenerated = true
1294
1288
proto , ok := config .Consensus [eval .block .BlockHeader .CurrentProtocol ]
@@ -1450,11 +1444,6 @@ transactionGroupLoop:
1450
1444
}
1451
1445
}
1452
1446
1453
- err = eval .finalValidation ()
1454
- if err != nil {
1455
- return ledgercore.StateDelta {}, err
1456
- }
1457
-
1458
1447
return eval .state .deltas (), nil
1459
1448
}
1460
1449
0 commit comments