Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not collect data for unconnected schains #1406

Open
DmytroNazarenko opened this issue Jan 17, 2023 · 4 comments
Open

Not collect data for unconnected schains #1406

DmytroNazarenko opened this issue Jan 17, 2023 · 4 comments
Assignees
Labels
bug Something isn't working epic:ima-optimizations
Milestone

Comments

@DmytroNazarenko
Copy link
Contributor

For IMA S2S transfers we collect data(endpoints, ports, etc) for all schains on the network. This operation take some time and we have huge amount of calls to mainnet.
Suggestion: To avoid overload validator geth ima and agent, collect data only from connected schain.(isConnected: true)

Instead of collect all data for all schains. You can get all schainHashes for the network then convert each schainHash to name and check is this chain connected and then collect data for current chain.
Steps:

  1. SchainsInternal.getSchains() will return all schainHashes for all schains in the network
  2. schainName = SchainsInternal.getSchainName(schainHash) will convert schainHash to schainName
  3. MessageProxyForSchain.isConnectedChain(schainName) will check is schain connected to current schain

Pseudocode:

async function isSchainHashConnected(schainHash: bytes32) {
    const schainName = await SchainsInternal.getSchainName(schainHash);
    return await MessageProxyForSchain.isConnectedChain(schainName);
}

async function collectDataForSchain(schainHash: bytes32) {
    ....
}

async function collectDataForConnectedSchains() {
    let allCollectedData;
    const allSchainHashes = await SchainsInternal.getSchains();
    for schainHash in allSchainHashes {
        if (await isSchainHashConnected(schainHash)) {
            allCollectedData.add(await collectDataForSchain(schainHash));
        }
    }
    return allCollectedData;
}

Solidity Help:

With this code amount of calls would be 2 * N + 1, where N is number of schains in the network, to get all schainHashes which connected to current schain.
We can add a EnumerableSet of connected schainHashes to the MessageProxyForSchain and it would be necessary to call only one function, but it would require to finalize Upgrade procedure on Schains.
Or we can add events to connectSchain function and update collected data by checking events, but overall it requires upgrade procedure on Schains.

@DmytroNazarenko
Copy link
Contributor Author

Need to retest by @sergiy-skalelabs

@DmytroNazarenko
Copy link
Contributor Author

2.0.0-beta.0

@sergiy-skalelabs
Copy link
Collaborator

Accroding to design of SChains/SChainsInternal smart contracts of SKALE Manager we had to get all S-Chains first, and then call isConnectedChain for each of them to find out all S-Chains really connected to one particular S-Chain. I.e. we cannot escape enumerating all S-Chains of SKALE Network.

@DmytroNazarenko
Copy link
Contributor Author

DmytroNazarenko commented Jul 6, 2023

For now not so critical, because multicalls in IMA 2.0.0 will mostly resolve this issue. Moving back to backlog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working epic:ima-optimizations
Projects
Status: No status
Development

No branches or pull requests

2 participants