Skip to content

Multi-chain cleanup#695

Open
nnikolash wants to merge 30 commits intodevelopfrom
chore/multi-chain-cleanup
Open

Multi-chain cleanup#695
nnikolash wants to merge 30 commits intodevelopfrom
chore/multi-chain-cleanup

Conversation

@nnikolash
Copy link
Collaborator

@nnikolash nnikolash commented Aug 12, 2025

Changes worth to note:

  • config.json: snapshotsToLoad array became single string snapshotToLoad which is just block hash (without chain ID). Now only one snapshot can be loaded
  • config.json: chains key became chain
  • Chain registry interface modified to not require chain ID
  • Added check into chain registry to forbid setting chain record with different chain ID
  • Chain ID was removed from consesus messages
  • Chain ID removed from PublishTX and WaitUntilAllRequestsProcessed
  • Chain ID removed from events

Delay uint32 `default:"20" usage:"how many states should pass before snapshot is produced"`
LocalPath string `default:"waspdb/snap" usage:"the path to the snapshots folder in this node's disk"`
NetworkPaths []string `default:"" usage:"the list of paths to the remote (http(s)) snapshot locations; each of listed locations must contain 'INDEX' file with list of snapshot files"`
SnapshotToLoad string `default:"" usage:"block hash of a snapshot to load"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice config.json structure has changed in this place. We would need to update all configs upon deployment.

Comment on lines +77 to +80
if storedChainRec.ChainID() != chainRecord.ChainID() {
return fmt.Errorf("cannot update chain record with different chain ID: %v != %v",
storedChainRec.ChainID().String(), chainRecord.ChainID().String())
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this check to ensure chain ID cannot change. This is simillar to what we had - Delete registry method is not exposed and Set had chain ID as it's argument. Now we still do not expose Delete, but we not dont have chain ID argument, so need to ensure nothing gets overwritten.

var params = &app.ComponentParams{
Params: map[string]any{
"chains": ParamsChains,
"chain": ParamsChainRunner,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice this key also changed in config.json.

}()
defer e.Shutdown(context.Background())

time.Sleep(5 * time.Second)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should fix sporadic issues in this test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the system back online this part, but should be good to add it but smaller number too

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just moved this line, but sure it makes sense to also decrease the time. Will do


// Protocol implementation.
type cmtLogImpl struct {
chainID isc.ChainID // Chain, for which this log is maintained by this committee.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice chain ID was removed from this and many other messages in chain/chains folder. @kape1395 could you please review this part?
And in general, could removing chain ID from consensus code cause issues? E.g. make chain vulnerable to some attacks like replay attack

Comment on lines +190 to +195
func (c *ChainRunner) initSnapshotToLoad(config string) {
c.snapshotToLoad = nil
blockHash, err := state.BlockHashFromString(config)
if err != nil {
c.log.LogErrorf("Parsing snapshots to load: %s is not a block hash: %v", config, err)
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now there is only one line, with syntax as it was for default snapshot

}

type ChainRecordRegistryImpl struct {
chainID isc.ChainID // We only have one chain. Multi-chain code left for backwards compatibility.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now registry supports only one chain record. But to avoid need to update all the files we keep implementation mostly as is, with exception that interface of the registry was updated to not require chain ID for some methods. And to implement it, we store chain ID of that one chain (inside map onChange callback).

Comment on lines +272 to +273
hasAccess bool
isServer bool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these good names?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and other files in this folder were not created but moved. But IDK for some reason this is not diplayed even though I used git mv

@chriscandless chriscandless marked this pull request as ready for review August 22, 2025 16:26
Comment on lines 62 to +63
func getConfig(chainID int) *params.ChainConfig {
if c, ok := configCache.Get(chainID); ok {
if c := configCache.Load(); c != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's necessary to check the value of chainID here. Because some solo tests may still be multi-chain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants