diff --git a/app/protocol/flows/v5/blockrelay/handle_ibd_block_requests.go b/app/protocol/flows/v5/blockrelay/handle_ibd_block_requests.go index aa69b82a0..45ccc6c44 100644 --- a/app/protocol/flows/v5/blockrelay/handle_ibd_block_requests.go +++ b/app/protocol/flows/v5/blockrelay/handle_ibd_block_requests.go @@ -27,18 +27,15 @@ func HandleIBDBlockRequests(context HandleIBDBlockRequestsContext, incomingRoute log.Debugf("Got request for %d ibd blocks", len(msgRequestIBDBlocks.Hashes)) for i, hash := range msgRequestIBDBlocks.Hashes { // Fetch the block from the database. - blockInfo, err := context.Domain().Consensus().GetBlockInfo(hash) - if err != nil { - return err - } - if !blockInfo.HasBody() { - return protocolerrors.Errorf(true, "block %s not found (v5)", hash) - } - block, err := context.Domain().Consensus().GetBlock(hash) + block, found, err := context.Domain().Consensus().GetBlock(hash) if err != nil { return errors.Wrapf(err, "unable to fetch requested block hash %s", hash) } + if !found { + return protocolerrors.Errorf(false, "IBD block %s not found", hash) + } + // TODO (Partial nodes): Convert block to partial block if needed blockMessage := appmessage.DomainBlockToMsgBlock(block) diff --git a/app/protocol/flows/v5/blockrelay/handle_pruning_point_and_its_anticone_requests.go b/app/protocol/flows/v5/blockrelay/handle_pruning_point_and_its_anticone_requests.go index cecfc93a0..4c0a11202 100644 --- a/app/protocol/flows/v5/blockrelay/handle_pruning_point_and_its_anticone_requests.go +++ b/app/protocol/flows/v5/blockrelay/handle_pruning_point_and_its_anticone_requests.go @@ -119,11 +119,15 @@ func HandlePruningPointAndItsAnticoneRequests(context PruningPointAndItsAnticone } for i, blockHash := range pointAndItsAnticone { - block, err := context.Domain().Consensus().GetBlock(blockHash) + block, found, err := context.Domain().Consensus().GetBlock(blockHash) if err != nil { return err } + if !found { + return protocolerrors.Errorf(false, "pruning point anticone block %s not found", blockHash) + } + err = outgoingRoute.Enqueue(appmessage.DomainBlockWithTrustedDataToBlockWithTrustedDataV4(block, trustedDataDAABlockIndexes[*blockHash], trustedDataGHOSTDAGDataIndexes[*blockHash])) if err != nil { return err diff --git a/app/protocol/flows/v5/blockrelay/handle_relay_block_requests.go b/app/protocol/flows/v5/blockrelay/handle_relay_block_requests.go index 552f5f103..f82fd43f4 100644 --- a/app/protocol/flows/v5/blockrelay/handle_relay_block_requests.go +++ b/app/protocol/flows/v5/blockrelay/handle_relay_block_requests.go @@ -28,18 +28,15 @@ func HandleRelayBlockRequests(context RelayBlockRequestsContext, incomingRoute * log.Debugf("Got request for relay blocks with hashes %s", getRelayBlocksMessage.Hashes) for _, hash := range getRelayBlocksMessage.Hashes { // Fetch the block from the database. - blockInfo, err := context.Domain().Consensus().GetBlockInfo(hash) - if err != nil { - return err - } - if !blockInfo.HasBody() { - return protocolerrors.Errorf(true, "block %s not found", hash) - } - block, err := context.Domain().Consensus().GetBlock(hash) + block, found, err := context.Domain().Consensus().GetBlock(hash) if err != nil { return errors.Wrapf(err, "unable to fetch requested block hash %s", hash) } + if !found { + return protocolerrors.Errorf(false, "Relay block %s not found", hash) + } + // TODO (Partial nodes): Convert block to partial block if needed err = outgoingRoute.Enqueue(appmessage.DomainBlockToMsgBlock(block)) diff --git a/app/protocol/flows/v5/blockrelay/handle_relay_invs.go b/app/protocol/flows/v5/blockrelay/handle_relay_invs.go index 72736689f..5a0377207 100644 --- a/app/protocol/flows/v5/blockrelay/handle_relay_invs.go +++ b/app/protocol/flows/v5/blockrelay/handle_relay_invs.go @@ -211,10 +211,14 @@ func (flow *handleRelayInvsFlow) start() error { continue } virtualHasNewParents = true - block, err := flow.Domain().Consensus().GetBlock(parent) + block, found, err := flow.Domain().Consensus().GetBlock(parent) if err != nil { return err } + + if !found { + return protocolerrors.Errorf(false, "Virtual parent %s not found", parent) + } blockHash := consensushashing.BlockHash(block) log.Debugf("Relaying block %s", blockHash) err = flow.relayBlock(block) diff --git a/cmd/kaspawallet/daemon/server/split_transaction_test.go b/cmd/kaspawallet/daemon/server/split_transaction_test.go index 0f521bb62..6d87470d3 100644 --- a/cmd/kaspawallet/daemon/server/split_transaction_test.go +++ b/cmd/kaspawallet/daemon/server/split_transaction_test.go @@ -121,7 +121,7 @@ func testEstimateMassIncreaseForSignaturesSetUp(t *testing.T, consensusConfig *c t.Fatalf("AddBlock: %+v", err) } - block1, err := tc.GetBlock(block1Hash) + block1, _, err := tc.GetBlock(block1Hash) if err != nil { t.Fatalf("GetBlock: %+v", err) } diff --git a/cmd/kaspawallet/libkaspawallet/transaction_test.go b/cmd/kaspawallet/libkaspawallet/transaction_test.go index 1d183080e..39a469994 100644 --- a/cmd/kaspawallet/libkaspawallet/transaction_test.go +++ b/cmd/kaspawallet/libkaspawallet/transaction_test.go @@ -84,7 +84,7 @@ func TestMultisig(t *testing.T) { t.Fatalf("AddBlock: %+v", err) } - block1, err := tc.GetBlock(block1Hash) + block1, _, err := tc.GetBlock(block1Hash) if err != nil { t.Fatalf("GetBlock: %+v", err) } @@ -245,7 +245,7 @@ func TestP2PK(t *testing.T) { t.Fatalf("AddBlock: %+v", err) } - block1, err := tc.GetBlock(block1Hash) + block1, _, err := tc.GetBlock(block1Hash) if err != nil { t.Fatalf("GetBlock: %+v", err) } @@ -377,17 +377,17 @@ func TestMaxSompi(t *testing.T) { t.Fatalf("AddBlock: %+v", err) } - fundingBlock2, err := tc.GetBlock(fundingBlock2Hash) + fundingBlock2, _, err := tc.GetBlock(fundingBlock2Hash) if err != nil { t.Fatalf("GetBlock: %+v", err) } - fundingBlock3, err := tc.GetBlock(fundingBlock3Hash) + fundingBlock3, _, err := tc.GetBlock(fundingBlock3Hash) if err != nil { t.Fatalf("GetBlock: %+v", err) } - fundingBlock4, err := tc.GetBlock(fundingBlock4Hash) + fundingBlock4, _, err := tc.GetBlock(fundingBlock4Hash) if err != nil { t.Fatalf("GetBlock: %+v", err) } @@ -397,7 +397,7 @@ func TestMaxSompi(t *testing.T) { t.Fatalf("AddBlock: %+v", err) } - block1, err := tc.GetBlock(block1Hash) + block1, _, err := tc.GetBlock(block1Hash) if err != nil { t.Fatalf("GetBlock: %+v", err) } diff --git a/domain/consensus/consensus.go b/domain/consensus/consensus.go index 518d7d608..f21cfaaad 100644 --- a/domain/consensus/consensus.go +++ b/domain/consensus/consensus.go @@ -357,7 +357,7 @@ func (s *consensus) ValidateTransactionAndPopulateWithConsensusData(transaction stagingArea, transaction, model.VirtualBlockHash) } -func (s *consensus) GetBlock(blockHash *externalapi.DomainHash) (*externalapi.DomainBlock, error) { +func (s *consensus) GetBlock(blockHash *externalapi.DomainHash) (*externalapi.DomainBlock, bool, error) { s.lock.Lock() defer s.lock.Unlock() @@ -366,11 +366,11 @@ func (s *consensus) GetBlock(blockHash *externalapi.DomainHash) (*externalapi.Do block, err := s.blockStore.Block(s.databaseContext, stagingArea, blockHash) if err != nil { if errors.Is(err, database.ErrNotFound) { - return nil, errors.Wrapf(err, "block %s does not exist", blockHash) + return nil, false, nil } - return nil, err + return nil, false, err } - return block, nil + return block, true, nil } func (s *consensus) GetBlockEvenIfHeaderOnly(blockHash *externalapi.DomainHash) (*externalapi.DomainBlock, error) { diff --git a/domain/consensus/finality_test.go b/domain/consensus/finality_test.go index cf7644288..6ac93f8f0 100644 --- a/domain/consensus/finality_test.go +++ b/domain/consensus/finality_test.go @@ -263,7 +263,7 @@ func TestBoundedMergeDepth(t *testing.T) { continue } - block, err := tcSyncer.GetBlock(blocksHash) + block, _, err := tcSyncer.GetBlock(blocksHash) if err != nil { t.Fatalf("GetBlockHeader: %+v", err) } diff --git a/domain/consensus/model/externalapi/consensus.go b/domain/consensus/model/externalapi/consensus.go index d7aadc203..da065adb2 100644 --- a/domain/consensus/model/externalapi/consensus.go +++ b/domain/consensus/model/externalapi/consensus.go @@ -13,7 +13,7 @@ type Consensus interface { ValidatePruningPointProof(pruningPointProof *PruningPointProof) error ApplyPruningPointProof(pruningPointProof *PruningPointProof) error - GetBlock(blockHash *DomainHash) (*DomainBlock, error) + GetBlock(blockHash *DomainHash) (*DomainBlock, bool, error) GetBlockEvenIfHeaderOnly(blockHash *DomainHash) (*DomainBlock, error) GetBlockHeader(blockHash *DomainHash) (BlockHeader, error) GetBlockInfo(blockHash *DomainHash) (*BlockInfo, error) diff --git a/domain/consensus/processes/blockprocessor/validate_and_insert_imported_pruning_point_test.go b/domain/consensus/processes/blockprocessor/validate_and_insert_imported_pruning_point_test.go index f86112baf..0ecd36b1e 100644 --- a/domain/consensus/processes/blockprocessor/validate_and_insert_imported_pruning_point_test.go +++ b/domain/consensus/processes/blockprocessor/validate_and_insert_imported_pruning_point_test.go @@ -93,7 +93,7 @@ func TestValidateAndInsertImportedPruningPoint(t *testing.T) { } for _, blockHash := range pruningPointAndItsAnticone { - block, err := tcSyncer.GetBlock(blockHash) + block, _, err := tcSyncer.GetBlock(blockHash) if err != nil { t.Fatalf("GetBlock: %+v", err) } @@ -268,7 +268,7 @@ func TestValidateAndInsertImportedPruningPoint(t *testing.T) { } for _, blocksHash := range missingBlockHashes { - block, err := tcSyncer.GetBlock(blocksHash) + block, _, err := tcSyncer.GetBlock(blocksHash) if err != nil { t.Fatalf("GetBlock: %+v", err) } @@ -294,7 +294,7 @@ func TestValidateAndInsertImportedPruningPoint(t *testing.T) { } tipHash := addBlock(tcSyncer, syncerTips, t) - tip, err := tcSyncer.GetBlock(tipHash) + tip, _, err := tcSyncer.GetBlock(tipHash) if err != nil { t.Fatalf("GetBlock: %+v", err) } @@ -341,7 +341,7 @@ func TestValidateAndInsertImportedPruningPoint(t *testing.T) { tipHash := consensusConfig.GenesisHash for i := 0; i < numSharedBlocks; i++ { tipHash = addBlock(tcSyncer, []*externalapi.DomainHash{tipHash}, t) - block, err := tcSyncer.GetBlock(tipHash) + block, _, err := tcSyncer.GetBlock(tipHash) if err != nil { t.Fatalf("GetBlock: %+v", err) } diff --git a/domain/consensus/processes/blockvalidator/block_body_in_context_test.go b/domain/consensus/processes/blockvalidator/block_body_in_context_test.go index ff8c71bb0..ac93c895b 100644 --- a/domain/consensus/processes/blockvalidator/block_body_in_context_test.go +++ b/domain/consensus/processes/blockvalidator/block_body_in_context_test.go @@ -41,7 +41,7 @@ func TestCheckBlockIsNotPruned(t *testing.T) { t.Fatalf("AddBlock: %+v", err) } - beforePruningBlock, err := tc.GetBlock(tipHash) + beforePruningBlock, _, err := tc.GetBlock(tipHash) if err != nil { t.Fatalf("beforePruningBlock: %+v", err) } @@ -199,7 +199,7 @@ func TestIsFinalizedTransaction(t *testing.T) { t.Fatalf("Error getting block DAA score : %+v", err) } blockParents := block.Header.DirectParents() - parentToSpend, err := tc.GetBlock(blockParents[0]) + parentToSpend, _, err := tc.GetBlock(blockParents[0]) if err != nil { t.Fatalf("Error getting block1: %+v", err) } diff --git a/domain/consensus/processes/blockvalidator/block_body_in_isolation_test.go b/domain/consensus/processes/blockvalidator/block_body_in_isolation_test.go index 15d60206d..0d3062f58 100644 --- a/domain/consensus/processes/blockvalidator/block_body_in_isolation_test.go +++ b/domain/consensus/processes/blockvalidator/block_body_in_isolation_test.go @@ -70,7 +70,7 @@ func TestChainedTransactions(t *testing.T) { t.Fatalf("AddBlock: %+v", err) } - block1, err := tc.GetBlock(block1Hash) + block1, _, err := tc.GetBlock(block1Hash) if err != nil { t.Fatalf("Error getting block1: %+v", err) } @@ -97,7 +97,7 @@ func TestChainedTransactions(t *testing.T) { t.Fatalf("unexpected error %+v", err) } - block2, err := tc.GetBlock(block2Hash) + block2, _, err := tc.GetBlock(block2Hash) if err != nil { t.Fatalf("Error getting block2: %+v", err) } diff --git a/domain/consensus/processes/consensusstatemanager/calculate_past_utxo_test.go b/domain/consensus/processes/consensusstatemanager/calculate_past_utxo_test.go index d86907673..a734fc28b 100644 --- a/domain/consensus/processes/consensusstatemanager/calculate_past_utxo_test.go +++ b/domain/consensus/processes/consensusstatemanager/calculate_past_utxo_test.go @@ -40,7 +40,7 @@ func TestUTXOCommitment(t *testing.T) { if err != nil { t.Fatalf("Error creating block B: %+v", err) } - blockB, err := consensus.GetBlock(blockBHash) + blockB, _, err := consensus.GetBlock(blockBHash) if err != nil { t.Fatalf("Error getting block B: %+v", err) } @@ -73,7 +73,7 @@ func TestUTXOCommitment(t *testing.T) { } func checkBlockUTXOCommitment(t *testing.T, consensus testapi.TestConsensus, blockHash *externalapi.DomainHash, blockName string) { - block, err := consensus.GetBlock(blockHash) + block, _, err := consensus.GetBlock(blockHash) if err != nil { t.Fatalf("Error getting block %s: %+v", blockName, err) } diff --git a/domain/consensus/processes/consensusstatemanager/resolve_block_status_test.go b/domain/consensus/processes/consensusstatemanager/resolve_block_status_test.go index 1614ff49a..cacfa195e 100644 --- a/domain/consensus/processes/consensusstatemanager/resolve_block_status_test.go +++ b/domain/consensus/processes/consensusstatemanager/resolve_block_status_test.go @@ -40,7 +40,7 @@ func TestDoubleSpends(t *testing.T) { if err != nil { t.Fatalf("Error creating fundingBlock: %+v", err) } - fundingBlock, err := consensus.GetBlock(fundingBlockHash) + fundingBlock, _, err := consensus.GetBlock(fundingBlockHash) if err != nil { t.Fatalf("Error getting fundingBlock: %+v", err) } @@ -195,7 +195,7 @@ func TestTransactionAcceptance(t *testing.T) { } } lastBlockInChain := chainTipHash - blockC, err := testConsensus.GetBlock(blockHashC) + blockC, _, err := testConsensus.GetBlock(blockHashC) if err != nil { t.Fatalf("Error getting blockC: %+v", err) } @@ -269,22 +269,27 @@ func TestTransactionAcceptance(t *testing.T) { if err != nil { t.Fatalf("Error getting acceptance data: %+v", err) } - blueChildOfRedBlock, err := testConsensus.GetBlock(hashBlueChildOfRedBlock) + blueChildOfRedBlock, _, err := testConsensus.GetBlock(hashBlueChildOfRedBlock) if err != nil { t.Fatalf("Error getting blueChildOfRedBlock: %+v", err) } - blockE, err := testConsensus.GetBlock(blockHashF) + blockE, _, err := testConsensus.GetBlock(blockHashF) if err != nil { t.Fatalf("Error getting blockE: %+v", err) } - redBlock, err := testConsensus.GetBlock(redHash) + redBlock, _, err := testConsensus.GetBlock(redHash) if err != nil { t.Fatalf("Error getting redBlock: %+v", err) } - _, err = testConsensus.GetBlock(blockHashG) + _, found, err := testConsensus.GetBlock(blockHashG) if err != nil { - t.Fatalf("Error getting blockF: %+v", err) + t.Fatalf("Error getting blockG: %+v", err) } + + if !found { + t.Fatalf("block G is missing") + } + updatedDAAScoreVirtualBlock := consensusConfig.GenesisBlock.Header.DAAScore() + 26 //We expect the second transaction in the "blue block" (blueChildOfRedBlock) to be accepted because the merge set is ordered topologically //and the red block is ordered topologically before the "blue block" so the input is known in the UTXOSet. diff --git a/domain/consensus/processes/transactionvalidator/transactionvalidator_test.go b/domain/consensus/processes/transactionvalidator/transactionvalidator_test.go index f9cdbdbcc..447b1934b 100644 --- a/domain/consensus/processes/transactionvalidator/transactionvalidator_test.go +++ b/domain/consensus/processes/transactionvalidator/transactionvalidator_test.go @@ -318,12 +318,12 @@ func TestSigningTwoInputs(t *testing.T) { t.Fatalf("AddBlock: %+v", err) } - block2, err := tc.GetBlock(block2Hash) + block2, _, err := tc.GetBlock(block2Hash) if err != nil { t.Fatalf("Error getting block2: %+v", err) } - block3, err := tc.GetBlock(block3Hash) + block3, _, err := tc.GetBlock(block3Hash) if err != nil { t.Fatalf("Error getting block3: %+v", err) } @@ -444,12 +444,12 @@ func TestSigningTwoInputsECDSA(t *testing.T) { t.Fatalf("AddBlock: %+v", err) } - block2, err := tc.GetBlock(block2Hash) + block2, _, err := tc.GetBlock(block2Hash) if err != nil { t.Fatalf("Error getting block2: %+v", err) } - block3, err := tc.GetBlock(block3Hash) + block3, _, err := tc.GetBlock(block3Hash) if err != nil { t.Fatalf("Error getting block3: %+v", err) } diff --git a/domain/consensus/timelock_CLTV_test.go b/domain/consensus/timelock_CLTV_test.go index 215442390..ce7a5122d 100644 --- a/domain/consensus/timelock_CLTV_test.go +++ b/domain/consensus/timelock_CLTV_test.go @@ -43,7 +43,7 @@ func TestCheckLockTimeVerifyConditionedByDAAScore(t *testing.T) { if err != nil { t.Fatalf("Error creating blockD: %v", err) } - blockD, err := testConsensus.GetBlock(blockDHash) + blockD, _, err := testConsensus.GetBlock(blockDHash) if err != nil { t.Fatalf("Failed getting blockD: %v", err) } @@ -150,7 +150,7 @@ func TestCheckLockTimeVerifyConditionedByDAAScoreWithWrongLockTime(t *testing.T) if err != nil { t.Fatalf("Error creating blockD: %v", err) } - blockD, err := testConsensus.GetBlock(blockDHash) + blockD, _, err := testConsensus.GetBlock(blockDHash) if err != nil { t.Fatalf("Failed getting blockD: %v", err) } @@ -252,7 +252,7 @@ func TestCheckLockTimeVerifyConditionedByAbsoluteTime(t *testing.T) { if err != nil { t.Fatalf("Error creating blockD: %v", err) } - blockD, err := testConsensus.GetBlock(blockDHash) + blockD, _, err := testConsensus.GetBlock(blockDHash) if err != nil { t.Fatalf("Failed getting blockD: %v", err) } @@ -283,7 +283,7 @@ func TestCheckLockTimeVerifyConditionedByAbsoluteTime(t *testing.T) { if err != nil { t.Fatalf("Error creating blockE: %v", err) } - blockE, err := testConsensus.GetBlock(blockEHash) + blockE, _, err := testConsensus.GetBlock(blockEHash) if err != nil { t.Fatalf("Failed getting blockE: %v", err) } @@ -380,7 +380,7 @@ func TestCheckLockTimeVerifyConditionedByAbsoluteTimeWithWrongLockTime(t *testin if err != nil { t.Fatalf("Error creating blockD: %v", err) } - blockD, err := testConsensus.GetBlock(blockDHash) + blockD, _, err := testConsensus.GetBlock(blockDHash) if err != nil { t.Fatalf("Failed getting blockD: %v", err) } @@ -411,7 +411,7 @@ func TestCheckLockTimeVerifyConditionedByAbsoluteTimeWithWrongLockTime(t *testin if err != nil { t.Fatalf("Error creating blockE: %v", err) } - blockE, err := testConsensus.GetBlock(blockEHash) + blockE, _, err := testConsensus.GetBlock(blockEHash) if err != nil { t.Fatalf("Failed getting blockE: %v", err) } diff --git a/domain/migrate.go b/domain/migrate.go index ef75a0458..ffb43acb4 100644 --- a/domain/migrate.go +++ b/domain/migrate.go @@ -2,6 +2,7 @@ package domain import ( "github.com/kaspanet/kaspad/domain/consensus/model/externalapi" + "github.com/pkg/errors" "math" ) @@ -66,11 +67,15 @@ func syncConsensuses(syncer, syncee externalapi.Consensus) error { } for _, blockHash := range pruningPointAndItsAnticone { - block, err := syncer.GetBlock(blockHash) + block, found, err := syncer.GetBlock(blockHash) if err != nil { return err } + if !found { + return errors.Errorf("block %s is missing", blockHash) + } + blockDAAWindowHashes, err := syncer.BlockDAAWindowHashes(blockHash) if err != nil { return err @@ -156,11 +161,14 @@ func syncConsensuses(syncer, syncee externalapi.Consensus) error { continue } - block, err := syncer.GetBlock(blocksHash) + block, found, err := syncer.GetBlock(blocksHash) if err != nil { return err } + if !found { + return errors.Errorf("block %s is missing", blocksHash) + } err = syncee.ValidateAndInsertBlock(block, false) if err != nil { return err diff --git a/domain/miningmanager/miningmanager_test.go b/domain/miningmanager/miningmanager_test.go index d98950b11..d1b1b8e2e 100644 --- a/domain/miningmanager/miningmanager_test.go +++ b/domain/miningmanager/miningmanager_test.go @@ -339,7 +339,7 @@ func TestOrphanTransactions(t *testing.T) { t.Fatalf("AddBlock: %v", err) } - blockParentsTransactions, err := tc.GetBlock(blockParentsTransactionsHash) + blockParentsTransactions, _, err := tc.GetBlock(blockParentsTransactionsHash) if err != nil { t.Fatalf("GetBlock: %v", err) } @@ -648,7 +648,7 @@ func TestModifyBlockTemplate(t *testing.T) { t.Fatalf("AddBlock: %v", err) } - blockParentsTransactions, err := tc.GetBlock(blockParentsTransactionsHash) + blockParentsTransactions, _, err := tc.GetBlock(blockParentsTransactionsHash) if err != nil { t.Fatalf("GetBlock: %v", err) } @@ -924,7 +924,7 @@ func createParentAndChildrenTransactions(tc testapi.TestConsensus) (txParent *ex if err != nil { return nil, nil, errors.Wrap(err, "AddBlock: ") } - fundingBlockForParent, err := tc.GetBlock(fundingBlockHashForParent) + fundingBlockForParent, _, err := tc.GetBlock(fundingBlockHashForParent) if err != nil { return nil, nil, errors.Wrap(err, "GetBlock: ") } @@ -949,7 +949,7 @@ func createChildAndParentTxsAndAddParentToConsensus(tc testapi.TestConsensus) (* if err != nil { return nil, errors.Wrap(err, "AddBlock: ") } - ParentBlock, err := tc.GetBlock(ParentBlockHash) + ParentBlock, _, err := tc.GetBlock(ParentBlockHash) if err != nil { return nil, errors.Wrap(err, "GetBlock: ") } diff --git a/stability-tests/common/mine/mine.go b/stability-tests/common/mine/mine.go index bcc65b20d..782009804 100644 --- a/stability-tests/common/mine/mine.go +++ b/stability-tests/common/mine/mine.go @@ -105,7 +105,16 @@ func mineBlocks(consensusConfig *consensus.Config, rpcClient *rpc.Client, blockC func mineOrFetchBlock(blockData JSONBlock, mdb *miningDB, testConsensus testapi.TestConsensus) (*externalapi.DomainBlock, error) { hash := mdb.hashByID(blockData.ID) if mdb.hashByID(blockData.ID) != nil { - return testConsensus.GetBlock(hash) + block, found, err := testConsensus.GetBlock(hash) + if err != nil { + return nil, err + } + + if !found { + return nil, errors.Errorf("block %s is missing", hash) + } + + return block, nil } parentHashes := make([]*externalapi.DomainHash, len(blockData.Parents)) diff --git a/stability-tests/netsync/fast-pruning-ibd-test/generate_test.go b/stability-tests/netsync/fast-pruning-ibd-test/generate_test.go index 58e6a2e77..2c631f5bc 100644 --- a/stability-tests/netsync/fast-pruning-ibd-test/generate_test.go +++ b/stability-tests/netsync/fast-pruning-ibd-test/generate_test.go @@ -44,7 +44,7 @@ func TestGenerateFastPruningIBDTest(t *testing.T) { } } - tip, err := tc.GetBlock(tipHash) + tip, _, err := tc.GetBlock(tipHash) if err != nil { t.Fatal(err) }