integritee-network / worker

Integritee off-chain worker and sidechain validateer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

secondary validateer should fetch light client state from peer if that one is significantly more up to date

brenzi opened this issue · comments

currently, SCV2 discovers its own light client state and won't obtain it from the better synced peer:

reproduce:
start SCV1 and SCV2 at same time. SCV+ synced faster, so we restarted SCV2

another problem seems to be that the shard creation block is not discarded although the SCV2 realizes that he's not the primary
on SCV1, shard creation is: Header { parent_hash: 0xc6977ad78912a524204b8e09a02bc302ef90885e12710ae2fafcc026eaffd485, number: 3671347, state_root: 0xf4df6a17d4dbaf9406a8c3ab5c0880e75a6dcaa9a30c0fe55748d4a0ec11ccce, extrinsics_root: 0xe42e7c472a5e01e8bdbc486b6c97e7d1ebede0c4bc47e145f8a031d4c1ef48cb, ...

│ We are NOT primary worker. The primary worker is 5FjfMNKrqA8Mmw8PjVZFz5ssG7DL78S9VqY7nQom6xLGMDvv.                                                                                                                                                                 │
│ [2023-12-13T15:44:30Z TRACE enclave_runtime] fetched shard creation header from state: (Integritee, <wasm:stripped>)                                                                                                                                               │
│ [2023-12-13T15:44:30Z TRACE enclave_runtime] fetched shard creation header from state: (Integritee, <wasm:stripped>)                                                                                                                                               │
│ [2023-12-13T15:44:30Z DEBUG integritee_service::main_impl] getting shard creation: Ok((Integritee, Header { parent_hash: 0xd93ebc82e2adc605a3acc239b0b2f19589d45335d45cb1d7ba8b3e7049af46b2, number: 3671617, state_root: 0xf3c55b927fc9f07b00688e6af7a13510775eba │
│ [2023-12-13T15:44:30Z INFO  enclave_runtime] Initializing light client!                                                                                                                                                                                            │
│ [2023-12-13T15:44:30Z INFO  itc_parentchain_light_client::io] Found already initialized light client with Genesis Hash: 0xafd7dcd3f6713a1b4bdf9b71edcf37d3ad019ec71743d89012ce227d00e59a08                                                                         │
│ [2023-12-13T15:44:30Z INFO  itc_parentchain_light_client::io] light client state: LightValidation { parentchain_id: Integritee, relay_state: RelayInfo { last_finalized_block_header_number: 917000, current_validator_set: [], current_validator_set_id: 0, numbe │
│ [2023-12-13T15:44:30Z INFO  itp_enclave_api::enclave_base::impl_ffi] Latest Header Header { parent_hash: 0x293958a842590e9fa952db3e95b58b8492b80b7bd34d3a3b482b4c3695fcd5ba, number: 917000, state_root: 0x9324732d1e9fd14d08f66decf68b4660fb12b7c1036a9520127167d │
│ [Integritee] last synced parentchain block: 917000                                                                                                                                                                                                                 │
│ [2023-12-13T15:44:30Z INFO  integritee_service::main_impl] [Integritee] Enclave nonce = 729                                                                                                                                                                        │
│ [2023-12-13T15:44:30Z INFO  enclave_runtime] Setting the nonce of the enclave to: 729 for parentchain: Integritee                                                                                                                                                  │
│ [2023-12-13T15:44:30Z INFO  enclave_runtime] Setting node meta data for parentchain: Integritee                                                                                                                                                                    │
│ [2023-12-13T15:44:30Z INFO  enclave_runtime] Successfully set the node meta data                                                                                                                                                                                   │
│ *** [+] Finished initializing light client, syncing parentchain...                                                                                                                                                                                                 │
│ [+] Spawning thread for sidechain block production                                                                                                                                                                                                                 │
│ [2023-12-13T15:44:30Z WARN  enclave_runtime::shard_vault] Failed to fetch shard vault account: Other("failed to fetch shard vault account. has it been initialized?")                                                                                              │
│ thread 'main' panicked at '[Integritee] no vault account has been initialized and we are not the primary worker', service/src/main_impl.rs:683:9                                                                                                                   │
│ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 

this issue looks a bit confusing in the log of the second SCV:

[2023-12-17T11:46:44Z INFO  integritee_service::parentchain_handler] [Integritee] Found 1000 block(s) to sync in this chunk. immediate import=false 
[2023-12-17T11:46:44Z TRACE integritee_service::parentchain_handler] skipping invocations for fast-sync for blocks older than shard creation: 3000 < 3696295
[2023-12-17T11:46:44Z TRACE enclave_runtime] [Integritee] Dispatching Import of 1000 blocks and 0 events
[2023-12-17T11:46:44Z INFO  integritee_service::parentchain_handler] [Integritee] Synced 3000 out of 3696429 finalized parentchain blocks
[2023-12-17T11:46:45Z WARN  its_consensus_common::block_import] Could not peek parentchain block, returning latest parentchain block (Other("Failed to find parentchain header in import queue (hash: 0xdde3…4b60) that is associated with the current sidechain block that is to be imported (number: 897, hash: 0xac58…aae3)"))
[2023-12-17T11:46:45Z DEBUG integritee_service::ocall_bridge::bridge_api] Requesting WorkerOnChain OCall API instance
[2023-12-17T11:46:45Z DEBUG integritee_service::ocall_bridge::worker_on_chain_ocall]     Entering ocall_worker_request
[2023-12-17T11:46:45Z ERROR enclave_runtime::error] Returning error Consensus(CouldNotGetAuthorities("Could not get validateer count from chain")) as sgx unexpected.
[2023-12-17T11:46:45Z ERROR integritee_service::sidechain_setup] Sgx(SGX_ERROR_UNEXPECTED)

these errors can be ignored as long as the light client is syncing