zcash / lightwalletd

Lightwalletd is a backend service that provides a bandwidth-efficient interface to the Zcash blockchain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Darksidewalletd] Block not found

pacu opened this issue · comments

commented

What is the bug?
What happened, and why was it unexpected? If applicable, add screenshots to help explain your problem.
running this test

/// Steps:
    /// 1.  sync up to an incoming transaction (incomingTxHeight + 1)
    /// 1a. save balances
    /// 2. stage 4 blocks from incomingTxHeight - 1 with different nonce
    /// 3. stage otherTx at incomingTxHeight
    /// 4. stage incomingTx at incomingTxHeight
    /// 5. applyHeight(incomingHeight + 3)
    /// 6. sync to latest height
    /// 7. check that balances still match
    func testReOrgChangesInboundTxIndexInBlock() throws {
        try FakeChainBuilder.buildChain(darksideWallet: coordinator.service, branchID: branchID, chainName: chainName)
        
        let incomingTxHeight = BlockHeight(663188)
        
        try coordinator.applyStaged(blockheight: incomingTxHeight + 1)
        
        /*
        1.  sync up to an incoming transaction (incomingTxHeight + 1)
        */
        let firstSyncExpectation = XCTestExpectation(description: "first sync test expectation")
        
        var initialBalance = Zatoshi(-1)
        var initialVerifiedBalance = Zatoshi(-1)
        var incomingTx: ConfirmedTransactionEntity?
        try coordinator.sync(completion: { _ in
            firstSyncExpectation.fulfill()
        }, error: self.handleError)
        
        wait(for: [firstSyncExpectation], timeout: 5)
        
        /*
        1a. save balances
        */
        initialBalance = coordinator.synchronizer.initializer.getBalance()
        initialVerifiedBalance = coordinator.synchronizer.initializer.getVerifiedBalance()
        incomingTx = coordinator.synchronizer.receivedTransactions.first(where: { $0.minedHeight == incomingTxHeight })

        guard let transaction = incomingTx else {
            XCTFail("no tx found")
            return
        }
        
        guard let txRawData = transaction.raw else {
            XCTFail("transaction has no raw data")
            return
        }
        
        let rawTransaction = RawTransaction.with({ rawTx in
            rawTx.data = txRawData
        })
        
        /*
        2. stage 4 blocks from incomingTxHeight - 1 with different nonce
        */
        let blockCount = 4
        try coordinator.stageBlockCreate(height: incomingTxHeight - 1, count: blockCount, nonce: Int.random(in: 0 ... Int.max))
        
        /*
        3. stage otherTx at incomingTxHeight
        */
        try coordinator.stageTransaction(url: FakeChainBuilder.someOtherTxUrl, at: incomingTxHeight)
        
        /*
        4. stage incomingTx at incomingTxHeight
        5. applyHeight(incomingHeight + 3)
        6. sync to latest height
        7. check that balances still match
        */
        try coordinator.stageTransaction(rawTransaction, at: incomingTxHeight)
        
        /*
        5. applyHeight(incomingHeight + 2)
        */
        try coordinator.applyStaged(blockheight: incomingTxHeight + 2)
        
        let lastSyncExpectation = XCTestExpectation(description: "last sync expectation")

        /*
        6. sync to latest height
        */
        try coordinator.sync(completion: { _ in
            lastSyncExpectation.fulfill()
        }, error: self.handleError)
        
        /*
        7. check that balances still match
        */
        XCTAssertEqual(coordinator.synchronizer.initializer.getVerifiedBalance(), initialVerifiedBalance)
        XCTAssertEqual(coordinator.synchronizer.initializer.getBalance(), initialBalance)
        
        wait(for: [lastSyncExpectation], timeout: 5)
    }

I consistently get this error.
testReOrgChangesInboundTxIndexInBlock(): failed - Failed with error: generalError(message: "block not found in cache, should always be in cache in darkside mode")

Workaround Solution
use v0.4.13

Thanks for the report; I did change this area recently, I'll look into it this week. Is it holding you up?

commented

Thanks for the report; I did change this area recently, I'll look into it this week. Is it holding you up?

It is not! 0.4.13 works fine

Fixed by #419.

Closing, fixed.