forked from febe19/bazo-miner
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblock_validation.go
592 lines (508 loc) · 21 KB
/
block_validation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
package miner
import (
"errors"
"fmt"
"github.com/julwil/bazo-miner/crypto"
"github.com/julwil/bazo-miner/p2p"
"github.com/julwil/bazo-miner/protocol"
"github.com/julwil/bazo-miner/storage"
"strconv"
"time"
)
// This function is split into block syntax/PoS check and actual state change
// because there is the case that we might need to go fetch several blocks
// and have to check the blocks first before changing the state in the correct order.
func validate(b *protocol.Block, initialSetup bool) error {
//This mutex is necessary that own-mined blocks and received blocks from the network are not
//validated concurrently.
blockValidation.Lock()
defer blockValidation.Unlock()
if storage.ReadClosedBlock(b.Hash) != nil {
logger.Printf("Received block (%x) has already been validated.\n", b.Hash[0:8])
return errors.New("Received Block has already been validated.")
}
//Get the right branch, and a list of blocks to rollback (if necessary).
blocksToRollback, blocksToValidate, err := getBlockSequences(b)
if err != nil {
return err
}
if len(blocksToRollback) > 0 {
logger.Printf(" _____________________")
logger.Printf("| Blocks To Rollback: |________________________________________________")
for _, block := range blocksToRollback {
logger.Printf("| - %x |", block.Hash)
}
logger.Printf("|______________________________________________________________________|")
logger.Printf(" _____________________")
logger.Printf("| Blocks To Validate: |________________________________________________")
for _, block := range blocksToValidate {
logger.Printf("| - %x |", block.Hash)
}
logger.Printf("|______________________________________________________________________|")
}
//Verify block time is dynamic and corresponds to system time at the time of retrieval.
//If we are syncing or far behind, we cannot do this dynamic check,
//therefore we include a boolean uptodate. If it's true we consider ourselves uptodate and
//do dynamic time checking.
uptodate = len(blocksToValidate) < DELAYED_BLOCKS
//Prepare datastructure to fill tx payloads.
blockDataMap := make(map[[32]byte]blockData)
// First perform rollback (if necessary)
for _, block := range blocksToRollback {
if err := rollback(block); err != nil {
return err
}
}
// Secondly, perform the validation.
for _, block := range blocksToValidate {
// We need to allocate slice space for the underlying array when we pass them as reference.
accTxs := make([]*protocol.AccTx, block.NrAccTx)
fundsTxs := make([]*protocol.FundsTx, block.NrFundsTx) // TODO: Duplicate?
configTxs := make([]*protocol.ConfigTx, block.NrConfigTx)
stakeTxs := make([]*protocol.StakeTx, block.NrStakeTx)
aggTxs := make([]*protocol.AggTx, block.NrAggTx)
updateTxs := make([]*protocol.UpdateTx, block.NrUpdateTx)
var aggregatedFundsTxs []*protocol.FundsTx // TODO: Duplicate?
err = preValidate(block, initialSetup)
if err != nil {
return err
}
// Fetching payload data from the txs (if necessary, ask other miners).
err = fetchTransactions(
initialSetup,
block,
&accTxs,
&fundsTxs,
&configTxs,
&stakeTxs,
&aggTxs,
&aggregatedFundsTxs,
&updateTxs,
)
if err != nil {
return err
}
//Check if the validator that added the block has previously voted on different competing chains (find slashing proof).
//The proof will be stored in the global slashing dictionary.
if block.Height > 0 {
seekSlashingProof(block)
}
if err != nil {
return err
}
blockDataMap[block.Hash] = blockData{
accTxs,
fundsTxs,
configTxs,
stakeTxs,
aggTxs,
aggregatedFundsTxs,
updateTxs,
block,
}
if err := validateState(blockDataMap[block.Hash], initialSetup); err != nil {
return err
}
postValidate(blockDataMap[block.Hash], initialSetup)
logString := "After rollback for"
if len(blocksToRollback) == 0 {
logString = "During Validation of other"
}
logger.Printf("Validated block (%s block %v): %vState:\n%s", logString, b.Hash[0:8], block, getState())
}
return nil
}
//Doesn't involve any state changes.
func preValidate(block *protocol.Block, initialSetup bool) error {
//Check state contains beneficiary.
beneficiaryAcc, err := storage.GetAccount(block.Beneficiary)
if err != nil {
return err
}
// Check if node is part of the validator set.
if !beneficiaryAcc.IsStaking {
return errors.New("Validator is not part of the validator set.")
}
//This dynamic check is only done if we're up-to-date with syncing, otherwise timestamp is not checked.
//Other miners (which are up-to-date) made sure that this is correct.
if !initialSetup && uptodate {
if err := timestampCheck(block.Timestamp); err != nil {
return err
}
}
//Check block size.
if block.GetSize() > activeParameters.BlockSize {
return errors.New("Block size too large.")
}
err = validateNoDuplicateTx(block)
if err != nil {
return err
}
//First, initialize an RSA Public Key instance with the modulus of the proposer of the block (beneficiaryAcc)
//Second, check if the commitment proof of the proposed block can be verified with the public key
//Invalid if the commitment proof can not be verified with the public key of the proposer
commitmentPubKey, err := crypto.CreateRSAPubKeyFromBytes(beneficiaryAcc.CommitmentKey)
if err != nil {
return errors.New("Invalid commitment key in account.")
}
err = crypto.VerifyMessageWithRSAKey(commitmentPubKey, fmt.Sprint(block.Height), block.CommitmentProof)
if err != nil {
return errors.New("The submitted commitment proof can not be verified.")
}
//Invalid if PoS calculation is not correct.
prevProofs := GetLatestProofs(activeParameters.numIncludedPrevProofs, block)
//PoS validation
if !initialSetup && !validateProofOfStake(getDifficulty(), prevProofs, block.Height, beneficiaryAcc.Balance, block.CommitmentProof, block.Timestamp) {
logger.Printf("____________________NONCE (%x) in block %x is problematic", block.Nonce, block.Hash[0:8])
logger.Printf("| block.Height: %d, beneficiaryAcc.Address %x, beneficiaryAcc.txCount %v, beneficiaryAcc.Balance %v, block.CommitmentProf: %x, block.Timestamp %v ", block.Height, beneficiaryAcc.Address[0:8], beneficiaryAcc.TxCnt, beneficiaryAcc.Balance, block.CommitmentProof[0:8], block.Timestamp)
logger.Printf("|_____________________________________________________")
return errors.New("The nonce is incorrect.")
}
//Invalid if PoS is too far in the future.
now := time.Now()
if block.Timestamp > now.Unix()+int64(activeParameters.AcceptedTimeDiff) {
return errors.New("The timestamp is too far in the future. " + string(block.Timestamp) + " vs " + string(now.Unix()))
}
//Check for minimum waiting time.
if block.Height-beneficiaryAcc.StakingBlockHeight < uint32(activeParameters.WaitingMinimum) {
return errors.New(
"The miner must wait a minimum amount of blocks before start validating. " +
"Block Height:" + fmt.Sprint(block.Height) + " - Height when started validating " +
string(beneficiaryAcc.StakingBlockHeight) + " MinWaitingTime: " + string(activeParameters.WaitingMinimum))
}
//Check if block contains a proof for two conflicting block hashes, else no proof provided.
if block.SlashedAddress != [32]byte{} {
if _, err = slashingCheck(
block.SlashedAddress,
block.ConflictingBlockHash1,
block.ConflictingBlockHash2,
block.ConflictingBlockHashWithoutTx1,
block.ConflictingBlockHashWithoutTx2); err != nil {
return err
}
}
//Merkle Tree validation
if block.Aggregated == false && protocol.BuildMerkleTree(block).MerkleRoot() != block.MerkleRoot {
return errors.New("Merkle Root is incorrect.")
}
return nil
}
//Dynamic state check.
func validateState(data blockData, initialSetup bool) error {
//The sequence of validation matters. If we start with accs, then fund/stake transactions can be done in the same block
//even though the accounts did not exist before the block validation.
if err := accStateChange(data.accTxSlice); err != nil {
return err
}
if err := fundsStateChange(data.fundsTxSlice, initialSetup); err != nil {
accStateChangeRollback(data.accTxSlice)
return err
}
if err := aggTxStateChange(data.aggregatedFundsTxSlice, initialSetup); err != nil {
fundsStateChangeRollback(data.fundsTxSlice)
accStateChangeRollback(data.accTxSlice)
return err
}
if err := stakeStateChange(data.stakeTxSlice, data.block.Height, initialSetup); err != nil {
fundsStateChangeRollback(data.fundsTxSlice)
accStateChangeRollback(data.accTxSlice)
aggregatedStateRollback(data.aggTxSlice, data.block.HashWithoutTx, data.block.Beneficiary)
return err
}
if err := collectTxFees(data.accTxSlice, data.fundsTxSlice, data.configTxSlice, data.stakeTxSlice, data.aggTxSlice, data.block.Beneficiary, initialSetup); err != nil {
stakeStateChangeRollback(data.stakeTxSlice)
fundsStateChangeRollback(data.fundsTxSlice)
aggregatedStateRollback(data.aggTxSlice, data.block.HashWithoutTx, data.block.Beneficiary)
accStateChangeRollback(data.accTxSlice)
return err
}
if err := collectBlockReward(activeParameters.BlockReward, data.block.Beneficiary, initialSetup); err != nil {
collectTxFeesRollback(data.accTxSlice, data.fundsTxSlice, data.configTxSlice, data.stakeTxSlice, data.block.Beneficiary)
stakeStateChangeRollback(data.stakeTxSlice)
fundsStateChangeRollback(data.fundsTxSlice)
aggregatedStateRollback(data.aggTxSlice, data.block.HashWithoutTx, data.block.Beneficiary)
accStateChangeRollback(data.accTxSlice)
return err
}
if err := collectSlashReward(activeParameters.SlashReward, data.block); err != nil {
collectBlockRewardRollback(activeParameters.BlockReward, data.block.Beneficiary)
collectTxFeesRollback(data.accTxSlice, data.fundsTxSlice, data.configTxSlice, data.stakeTxSlice, data.block.Beneficiary)
stakeStateChangeRollback(data.stakeTxSlice)
fundsStateChangeRollback(data.fundsTxSlice)
aggregatedStateRollback(data.aggTxSlice, data.block.HashWithoutTx, data.block.Beneficiary)
accStateChangeRollback(data.accTxSlice)
return err
}
if err := updateStakingHeight(data.block); err != nil {
collectSlashRewardRollback(activeParameters.SlashReward, data.block)
collectBlockRewardRollback(activeParameters.BlockReward, data.block.Beneficiary)
collectTxFeesRollback(data.accTxSlice, data.fundsTxSlice, data.configTxSlice, data.stakeTxSlice, data.block.Beneficiary)
stakeStateChangeRollback(data.stakeTxSlice)
fundsStateChangeRollback(data.fundsTxSlice)
aggregatedStateRollback(data.aggTxSlice, data.block.HashWithoutTx, data.block.Beneficiary)
accStateChangeRollback(data.accTxSlice)
return err
}
return nil
}
func postValidate(data blockData, initialSetup bool) {
//The new system parameters get active if the block was successfully validated
//This is done after state validation (in contrast to accTx/fundsTx).
//Conversely, if blocks are rolled back, the system parameters are changed first.
configStateChange(data.configTxSlice, data.block.Hash)
//Collects meta information about the block (and handled difficulty adaption).
collectStatistics(data.block)
//When starting a miner there are various scenarios how to PostValidate a block
// 1. Bootstrapping Miner on InitialSetup --> All Tx Are already in closedBucket
// 2. Bootstrapping Miner after InitialSetup --> PostValidate normal, writing tx into closed bucket.
// 3. Normal Miner on InitialSetup --> Write All Tx Into Closed Tx
// 4. Normal Miner after InitialSetup --> Write All Tx Into Closed Tx
if !p2p.IsBootstrap() || !initialSetup {
//Write all open transactions to closed/validated storage.
for _, tx := range data.accTxSlice {
storage.WriteClosedTx(tx)
storage.DeleteOpenTx(tx)
}
for _, tx := range data.fundsTxSlice {
storage.WriteClosedTx(tx)
tx.Block = data.block.HashWithoutTx
storage.DeleteOpenTx(tx)
storage.DeleteINVALIDOpenTx(tx)
}
for _, tx := range data.configTxSlice {
storage.WriteClosedTx(tx)
storage.DeleteOpenTx(tx)
}
for _, tx := range data.stakeTxSlice {
storage.WriteClosedTx(tx)
storage.DeleteOpenTx(tx)
}
for _, tx := range data.updateTxSlice {
storage.WriteClosedTx(tx)
storage.DeleteOpenTx(tx)
}
//Store all recursively fetched funds transactions.
if initialSetup {
for _, tx := range data.aggregatedFundsTxSlice {
tx.Aggregated = true
storage.WriteClosedTx(tx)
storage.DeleteOpenTx(tx)
}
}
for _, tx := range data.aggTxSlice {
//delete FundsTx per aggTx in open storage and write them to the closed storage.
for _, aggregatedTxHash := range tx.AggregatedTxSlice {
trx := storage.ReadClosedTx(aggregatedTxHash)
if trx != nil {
switch trx.(type) {
case *protocol.AggTx:
trx.(*protocol.AggTx).Aggregated = true
case *protocol.FundsTx:
trx.(*protocol.FundsTx).Aggregated = true
}
} else {
trx = storage.ReadOpenTx(aggregatedTxHash)
if trx == nil {
for _, i := range data.aggregatedFundsTxSlice {
if i.Hash() == aggregatedTxHash {
trx = i
}
}
}
switch trx.(type) {
case *protocol.AggTx:
trx.(*protocol.AggTx).Aggregated = true
case *protocol.FundsTx:
trx.(*protocol.FundsTx).Block = data.block.HashWithoutTx
trx.(*protocol.FundsTx).Aggregated = true
}
}
if trx == nil {
break
}
storage.WriteClosedTx(trx)
storage.DeleteOpenTx(trx)
storage.DeleteINVALIDOpenTx(tx)
}
//Delete AggTx and write it to closed Tx.
tx.Block = data.block.HashWithoutTx
tx.Aggregated = false
storage.WriteClosedTx(tx)
storage.DeleteOpenTx(tx)
storage.DeleteINVALIDOpenTx(tx)
}
if len(data.fundsTxSlice) > 0 {
broadcastVerifiedFundsTxs(data.fundsTxSlice)
//Current sending mechanism is not fast enough to broadcast all validated transactions...
//broadcastVerifiedFundsTxsToOtherMiners(data.fundsTxSlice)
//broadcastVerifiedFundsTxsToOtherMiners(data.aggregatedFundsTxSlice)
}
//Broadcast AggTx to the neighbors, such that they do not have to request them later.
if len(data.aggTxSlice) > 0 {
//broadcastVerifiedAggTxsToOtherMiners(data.aggTxSlice)
}
//It might be that block is not in the openblock storage, but this doesn't matter.
storage.DeleteOpenBlock(data.block.Hash)
storage.WriteClosedBlock(data.block)
//Do not empty last three blocks and only if it not aggregated already.
for _, block := range storage.ReadAllClosedBlocks() {
//Empty all blocks despite the last NO_AGGREGATION_LENGTH and genesis block.
if !block.Aggregated && block.Height > 0 {
if (int(block.Height)) < (int(data.block.Height) - NO_EMPTYING_LENGTH) {
storage.UpdateBlocksToBlocksWithoutTx(block)
}
}
}
// Write last block to db and delete last block's ancestor.
storage.DeleteAllLastClosedBlock()
storage.WriteLastClosedBlock(data.block)
}
}
//Only blocks with timestamp not diverging from system time (past or future) more than one hour are accepted.
func timestampCheck(timestamp int64) error {
systemTime := p2p.ReadSystemTime()
if timestamp > systemTime {
if timestamp-systemTime > int64(2*time.Hour.Seconds()) {
return errors.New("Timestamp was too far in the future.System time: " + strconv.FormatInt(systemTime, 10) + " vs. timestamp " + strconv.FormatInt(timestamp, 10) + "\n")
}
} else {
if systemTime-timestamp > int64(10*time.Hour.Seconds()) {
return errors.New("Timestamp was too far in the past. System time: " + strconv.FormatInt(systemTime, 10) + " vs. timestamp " + strconv.FormatInt(timestamp, 10) + "\n")
}
}
return nil
}
func slashingCheck(slashedAddress, conflictingBlockHash1, conflictingBlockHash2, conflictingBlockHashWithoutTx1, conflictingBlockHashWithoutTx2 [32]byte) (bool, error) {
prefix := "Invalid slashing proof: "
if conflictingBlockHash1 == [32]byte{} || conflictingBlockHash2 == [32]byte{} {
return false, errors.New(fmt.Sprintf(prefix + "Invalid conflicting block hashes provided."))
}
if conflictingBlockHash1 == conflictingBlockHash2 {
return false, errors.New(fmt.Sprintf(prefix + "Conflicting block hashes are the same."))
}
//Fetch the blocks for the provided block hashes.
conflictingBlock1 := storage.ReadClosedBlock(conflictingBlockHash1)
conflictingBlock2 := storage.ReadClosedBlock(conflictingBlockHash2)
//Try fetching the block from the Blocks Without Transactions.
if conflictingBlock1 == nil {
conflictingBlock1 = storage.ReadClosedBlockWithoutTx(conflictingBlockHashWithoutTx1)
}
if conflictingBlock2 == nil {
conflictingBlock2 = storage.ReadClosedBlockWithoutTx(conflictingBlockHashWithoutTx2)
}
if IsInSameChain(conflictingBlock1, conflictingBlock2) {
return false, errors.New(fmt.Sprintf(prefix + "Conflicting block hashes are on the same chain."))
}
//TODO Optimize code (duplicated)
//If this block is unknown we need to check if its in the openblock storage or we must request it.
if conflictingBlock1 == nil {
conflictingBlock1 = storage.ReadOpenBlock(conflictingBlockHash1)
if conflictingBlock1 == nil {
//Fetch the block we apparently missed from the network.
p2p.BlockReq(conflictingBlockHash1, conflictingBlockHashWithoutTx1)
//Blocking wait
select {
case encodedBlock := <-p2p.BlockReqChan:
conflictingBlock1 = conflictingBlock1.Decode(encodedBlock)
//Limit waiting time to BLOCKFETCH_TIMEOUT seconds before aborting.
case <-time.After(BLOCKFETCH_TIMEOUT * time.Second):
if p2p.BlockAlreadyReceived(storage.ReadReceivedBlockStash(), conflictingBlockHash1) {
for _, block := range storage.ReadReceivedBlockStash() {
if block.Hash == conflictingBlockHash1 {
conflictingBlock1 = block
break
}
}
logger.Printf("Block %x received Before", conflictingBlockHash1)
break
}
return false, errors.New(fmt.Sprintf(prefix + "Could not find a block with the provided conflicting hash (1)."))
}
}
ancestor, _ := getNewChain(conflictingBlock1)
if ancestor == nil {
return false, errors.New(fmt.Sprintf(prefix + "Could not find a ancestor for the provided conflicting hash (1)."))
}
}
//TODO Optimize code (duplicated)
//If this block is unknown we need to check if its in the openblock storage or we must request it.
if conflictingBlock2 == nil {
conflictingBlock2 = storage.ReadOpenBlock(conflictingBlockHash2)
if conflictingBlock2 == nil {
//Fetch the block we apparently missed from the network.
p2p.BlockReq(conflictingBlockHash2, conflictingBlockHashWithoutTx2)
//Blocking wait
select {
case encodedBlock := <-p2p.BlockReqChan:
conflictingBlock2 = conflictingBlock2.Decode(encodedBlock)
//Limit waiting time to BLOCKFETCH_TIMEOUT seconds before aborting.
case <-time.After(BLOCKFETCH_TIMEOUT * time.Second):
if p2p.BlockAlreadyReceived(storage.ReadReceivedBlockStash(), conflictingBlockHash2) {
for _, block := range storage.ReadReceivedBlockStash() {
if block.Hash == conflictingBlockHash2 {
conflictingBlock2 = block
break
}
}
logger.Printf("Block %x received Before", conflictingBlockHash2)
break
}
return false, errors.New(fmt.Sprintf(prefix + "Could not find a block with the provided conflicting hash (2)."))
}
}
ancestor, _ := getNewChain(conflictingBlock2)
if ancestor == nil {
return false, errors.New(fmt.Sprintf(prefix + "Could not find a ancestor for the provided conflicting hash (2)."))
}
}
// We found the height of the blocks and the height of the blocks can be checked.
// If the height is not within the active slashing window size, we must throw an error. If not, the proof is valid.
if !(conflictingBlock1.Height < uint32(activeParameters.SlashingWindowSize)+conflictingBlock2.Height) {
return false, errors.New(fmt.Sprintf(prefix + "Could not find a ancestor for the provided conflicting hash (2)."))
}
//Delete the proof from local slashing dictionary. If proof has not existed yet, nothing will be deleted.
delete(slashingDict, slashedAddress)
return true, nil
}
// Validate whether the given block doesn't contain duplicate txs.
// Duplicate txs are not allowed and result in a failed validation.
func validateNoDuplicateTx(block *protocol.Block) error {
seenTxs := make(map[[32]byte]bool)
for _, txHash := range block.AccTxData {
if _, exists := seenTxs[txHash]; exists {
return errors.New("Duplicate Account Transaction Hash detected.")
}
seenTxs[txHash] = true
}
for _, txHash := range block.FundsTxData {
if _, exists := seenTxs[txHash]; exists {
return errors.New("Duplicate Funds Transaction Hash detected.")
}
seenTxs[txHash] = true
}
for _, txHash := range block.ConfigTxData {
if _, exists := seenTxs[txHash]; exists {
return errors.New("Duplicate Config Transaction Hash detected.")
}
seenTxs[txHash] = true
}
for _, txHash := range block.StakeTxData {
if _, exists := seenTxs[txHash]; exists {
return errors.New("Duplicate Stake Transaction Hash detected.")
}
seenTxs[txHash] = true
}
for _, txHash := range block.AggTxData {
if _, exists := seenTxs[txHash]; exists {
return errors.New("Duplicate Aggregation Transaction Hash detected.")
}
seenTxs[txHash] = true
}
for _, txHash := range block.UpdateTxData {
if _, exists := seenTxs[txHash]; exists {
return errors.New("Duplicate Delete Transaction Hash detected.")
}
seenTxs[txHash] = true
}
return nil
}