zcash/lightwalletd

Darksidewalletd GetLatestBlock rpc method fails

pacu opened this issue · 3 comments

pacu commented

What is the bug?
Running the iOS darkside walletd sanity checks on lwd master I came across this error

{"app":"lightwalletd","level":"info","msg":"getblock 663150 failed, will retry: error requesting block: error parsing height as integer","time":"2022-08-28T16:12:01-03:00"}

** Reproduce error manually on terminal **

  1. reset the chain grpcurl -plaintext -d '{ "saplingActivation" : 663150, "branchID" : "2bb40e60", "chainName" : "main"}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/Reset

  2. Stage the blocks grpcurl -plaintext -d '{ "url" : "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/tx-height-reorg/before-reorg.txt" }' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/StageBlocks

  3. Apply them grpcurl -plaintext -d '{ "height" : 663200 }' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/ApplyStaged

result:

darksidewalletd should actually stay at this

{"app":"lightwalletd","level":"info","msg":"Waiting for block: 663201","time":"2022-08-28T16:26:50-03:00"}

But instead starts looping with this message

{"app":"lightwalletd","level":"info","msg":"getblock 663150 failed, will retry: error requesting block: error parsing height as integer","time":"2022-08-28T16:22:23-03:00"}

Darksidewalletd start
Additional context
source code of sanity tests

func testDarkside() throws {
        let expectedFirstBlock = (height: BlockHeight(663150), hash: "0000000002fd3be4c24c437bd22620901617125ec2a3a6c902ec9a6c06f734fc")
        let expectedLastBlock = (height: BlockHeight(663200), hash: "2fc7b4682f5ba6ba6f86e170b40f0aa9302e1d3becb2a6ee0db611ff87835e4a")
        
        try coordinator.applyStaged(blockheight: expectedLastBlock.height)
        
        let syncExpectation = XCTestExpectation(description: "sync to \(expectedLastBlock.height)")
        
        try coordinator.sync(
            completion: { _ in
                syncExpectation.fulfill()
            },
            error: { error in
                guard let e = error else {
                    XCTFail("failed with unknown error")
                    return
                }
                XCTFail("failed with error: \(e)")
                return
            }
        )
        
        wait(for: [syncExpectation], timeout: 5)
        
        let blocksDao = BlockSQLDAO(dbProvider: SimpleConnectionProvider(path: coordinator.databases.dataDB.absoluteString, readonly: true))
        
        let firstBlock = try blocksDao.block(at: expectedFirstBlock.height)
        let lastBlock = try blocksDao.block(at: expectedLastBlock.height)
        
        XCTAssertEqual(firstBlock?.hash.toHexStringTxId(), expectedFirstBlock.hash)
        XCTAssertEqual(lastBlock?.hash.toHexStringTxId(), expectedLastBlock.hash)
    }

Workaround
stick to v0.4.13

@pacu is this still not working? I just tried to reproduce it using the steps you specified in the description, on the latest master, and it didn't fail for me.

pacu commented

I'll test it!

pacu commented

image

Works!