You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we add a new chain to Demeris backend by adding an entry to the CNS, we need to make sure that it has a connection/port/channel with all the chains we currently support.
In other words, we need a process that does the following:
// Process that needs to be followed when trying to enable a new chain NewChain with id newchain-id
// get list of clientIDs on NewChain
clientIDSNewChain := db.getClientIDs(newchain-id)
for each chain-id in CNS {
// matchingClientIDs contains a list of matching client IDs between NewChain and chain
matchingClientIDs := []string
// this loop attemps to find out the list of matching clients between chain and NewChain
for each clientID in clientIDSNewChain
clientState := db.getClientState(newchain-id, clientID)
if clientState.chainID == chain-id
// there is a client on newchain that matches the chain-id of a chain in the CNS
// we now need to verify that there is a matching client on the other side
counterpartyClientID = clientState.counterparty.ClientID
(found, counterPartyClientState) := db.getClientState(chain-id, counterpartyClientID) // find clientState where ChaindID == chain-id AND ClientID = counterpartyClientID
if (found) && (counterPartyClientState.chainID == newchain-id) && (counterPartyClientState.counterparty.clientID == clientID)
matchingClientIDs.add(clientID)
if matchingClientIDs.isEmpty
// no matching client IDs, we need to create client, connection and channel
(success, channelToChain, channelToNewChain) = hermes.createChannel(chain-id, newchain-id)
if success
cns.PrimaryChannel(chain-id, newchain-id) = channelToNewChain
cns.PrimaryChannel(newchain-id, chain-id) = channelToChain
return
else
// there is at least one matching client
// matchingConnectionIDs contains a list of matching connection IDs between NewChain and chain
matchingConnectionIDs := []string
for each clientID in matchingClientIDs
// get list of connectionIDs on NewChain associated with clientID
connectionIDSNewChain := db.getConnectionIDsFromClientID(newchain-id, clientID)
// this loop attemps to find out the list of matching connections between chain and NewChain
for each connectionID in connectionIDsNewChain
counterPartyConnectionID = db.getCounterpartyConnectionID(newchain-id, connectionID)
if db.getCounterpartyConnectionID(chain-id, counterPartyConnectionID) == connectionID
// there is a matching connection on both sides
macthingConnectionIDs.add(connectionID)
if matchingConnectionIDs.isEmpty
// there is at least a matching client on each side but no connection
// we open a new client, connection and channel to be safe
(success, channelToChain, channelToNewChain) = hermes.createChannel(chain-id, newchain-id)
if success
cns.PrimaryChannel(chain-id, newchain-id) = channelToNewChain
cns.PrimaryChannel(newchain-id, chain-id) = channelToChain
return
else
// at least one of the matching clients has a matching connection
// matchingChannelIDs contains a list of matching channelIDs (of unordered channels) between NewChain and chain
matchingChannelIDs := []{string, string}
for each connectionID in matchingConnectionIDs
// get list of channelIDs on NewChain associated with connectionID
channelIDSNewChain := db.getChannelIDsFromConnexionID(newchain-id, connectionID)
// this loop attemps to find out the list of matching channels between chain and NewChain
for each channelID in channelIDSNewChain
if channelID.isUNORDERED
counterPartyChannelID = db.getCounterpartyChannelID(newchain-id, channelID)
if db.getCounterpartyChannelID(chain-id, counterPartyChannelID) == channelID
// there is a matching unordered channel on both sides
macthingChannelIDs.add(channelID, counterPartyChannelID)
if matchingChannelIDs.isEmpty
// there is at least a matching connection on each side but no matching unordered channel
// we open a new client, connection and channel to be safe
(success, channelToChain, channelToNewChain) = hermes.createChannel(chain-id, newchain-id)
if success
cns.PrimaryChannel(chain-id, newchain-id) = channelToNewChain
cns.PrimaryChannel(newchain-id, chain-id) = channelToChain
return
else
// at least one of the matching connections has a matching unordered channel
// pick the first matching unordered channel as the primary channel
cns.PrimaryChannel(newchain-id, chain-id) = matchingChannelIDs[0]{0}
cns.PrimaryChannel(chain-id, newchain-id) = matchingChannelIDs[0]{1}
return
}
The text was updated successfully, but these errors were encountered:
When we add a new chain to Demeris backend by adding an entry to the CNS, we need to make sure that it has a connection/port/channel with all the chains we currently support.
In other words, we need a process that does the following:
The text was updated successfully, but these errors were encountered: