0chain / zboxcli

A client CLI using GoSDK to interface the blockchain, storage platform, and blobbers (storage providers)
Other
28 stars 23 forks source link

Added filter status on ./zbox ls-blobber #32

Closed cnlangzi closed 3 years ago

cnlangzi commented 3 years ago

Please answer these questions before submitting your issue.


Question


Bug


Requirement or improvement

the blobber will be listed too even it is offline on ./zbox ls-blobber. Could we add a status filter for it?

cnlangzi commented 3 years ago

blobber should be reconnected after it is restarted.

2021-06-09T15:22:12.626Z ERROR chain/state.go:379 Error executing the SC {"txn": {"hash":"bd06ff7df481adc6ff8bf63112106192a63fe0b1e57ce80bfc2fc82ada3d2bdb","version":"1.0","client_id":"367f46c2a4e9d83f819ecdf9a9c9aa6fea33f6c99c358031d10525a15811a654","to_client_id":"6dba10422e368813802877a85039d3985d96760ed844092319743fb3a76712d7","chain_id":"0afc093ffb509f059c55478bc1a60351cef7b4e9c008a53a6cc8241ca8617dfe","transaction_data":"{\"name\":\"new_allocation_request\",\"input\":{\"data_shards\":1,\"expiration_date\":1625844107,\"max_challenge_completion_time\":3600000000000,\"owner_id\":\"367f46c2a4e9d83f819ecdf9a9c9aa6fea33f6c99c358031d10525a15811a654\",\"owner_public_key\":\"b4a00393320a04336ded7c871585350280c219a400def7640422f71374f0060391fdddc7b091972c400a3938890c23d172a0502a1ff91cc46c9917a50bcdbe1a\",\"parity_shards\":1,\"preferred_blobbers\":null,\"read_price_range\":{\"min\":0,\"max\":9223372036854775807},\"size\":2147483648,\"write_price_range\":{\"min\":0,\"max\":9223372036854775807}}}","transaction_value":5000000000,"signature":"ed0a43a6e915482012dea9fdc6f45a078dc51ea4e2de9adfc765c4a5043f0822","creation_date":1623252107,"transaction_fee":0,"transaction_type":1000,"txn_output_hash":"","transaction_status":0}, "error": "allocation_creation_failed: Not enough blobbers to honor the allocation"} 0chain.net/chaincore/chain.(Chain).updateState /0chain/go/0chain.net/chaincore/chain/state.go:379 0chain.net/chaincore/chain.(Chain).UpdateState /0chain/go/0chain.net/chaincore/chain/state.go:350 0chain.net/miner.(Chain).GenerateBlock.func1 /0chain/go/0chain.net/miner/protocol_block_main.go:91 0chain.net/miner.(Chain).GenerateBlock.func2 /0chain/go/0chain.net/miner/protocol_block_main.go:135 0chain.net/core/memorystore.(Store).iterateCollection /0chain/go/0chain.net/core/memorystore/collection.go:108 0chain.net/core/memorystore.(Store).IterateCollection /0chain/go/0chain.net/core/memorystore/collection.go:21 0chain.net/miner.(Chain).GenerateBlock /0chain/go/0chain.net/miner/protocol_block_main.go:151 0chain.net/miner.(Chain).GenerateRoundBlock /0chain/go/0chain.net/miner/protocol_round.go:496

guruhubb commented 3 years ago

@andrenerd is this fixed? I believe one of your PR address this issue. I just checked and its not working with one.devnet

andrenerd commented 3 years ago

@guruhubb I'm afraid, it doesn't. The original point is that sharder doesn't "deactivate" or "remove" blobbers when they go down for a while or completely. As a result they remain on the list (as "active/online").

What was fixed is how re-registration processed. That is when blobbers wake up and send registration request.

Let me check how it works and get back soon.

guruhubb commented 3 years ago

On Explorer, if you look at https://one.devnet-0chain.net/blobber, it filters out the blobbers based on health status. We can add this to our gosdk. I'll assign this to @chauchausoup since he is working on the Explorer. Perhaps have a flag --active to filter ls blobbers

chauchausoup commented 3 years ago

On js-sdk there is a filter that checks if the last health check timestamp value is more than an hour or not from the present time. If last healthcheck has exceeded an hour from present time then it is under inactive sets of Blobber and vice versa. Here is a js-sdk code that implements that filter.

    getAllBlobbers: function getAllBlobbers() {
        return utils.getConsensusedInformationFromSharders(sharders, Endpoints.SC_BLOBBER_STATS, {})
            .then((res) => {
                const response = res.Nodes.filter((value) =>
                    new Date().getTime() - new Date(value.last_health_check * 1000).getTime() < 3600000
                );
                return response;
            });
    },

On cli we can have --active flag that does similar operation.

Filter algorithm:

If( present time - blobber's last health check time ) < 1 hours 
 then the blobber passes from the filter
guruhubb commented 3 years ago

@chauchausoup pls go ahead with that change

chauchausoup commented 3 years ago

Sorry for the previous hesitation to implement the filter in ls-blobber as I have very less experience in golang. But with some help from Google and after testing in six,nine and one network and getting as expected result I here have made a https://github.com/0chain/zboxcli/pull/40 on the issue. I will close the issue for now as any syntax or error related to the code will be discussed in the https://github.com/0chain/zboxcli/pull/40 @andrenerd please check the code and suggest me for changes if required.