Skip to content

Conversation

@Eslam-Nawara
Copy link
Contributor

Description

support modules updating substrate/relay connections if the url in zos-config was updated.

Changes

  • add update function in substrate-gateway to update substrate connection
  • add update function in events package to update substrate connection
  • update GetSubstrate in env pkg to update used substrate manager on changing sub url

Related Issues

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring

@Eslam-Nawara Eslam-Nawara force-pushed the update-modules-on-config-update branch from ebb3e29 to c1ed22b Compare July 7, 2025 10:09
@Eslam-Nawara Eslam-Nawara force-pushed the update-modules-on-config-update branch from c1ed22b to 7af2de7 Compare July 7, 2025 10:10
@Eslam-Nawara Eslam-Nawara force-pushed the load-config-urls-from-zos-config branch from 2683a49 to 67517d3 Compare July 7, 2025 10:12

FlistURL string `json:"flist_url"`
V4FlistURL string `json:"v4_flist_url"`
// FlistURL string `json:"flist_url"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

why did u remove flist url?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

flist urls same as storage urls should not be configurable as long as the node will break if they're changed in run time

if !slices.Equal(subURLs, env.SubstrateURL) {
log.Debug().Strs("substrate_urls", env.SubstrateURL).Msg("updating to sub manager with url")
subURLs = env.SubstrateURL
pool = substrate.NewManager(env.SubstrateURL...)
Copy link
Collaborator

Choose a reason for hiding this comment

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

here u are creating connection everytime getSubstrate is called which is against the original design this should be executed one time better to have another approach than this we should be using one connection all the time, so either we detect if connection is not working we restart the node services if we can reach substrate on another url from zos config something like monitoring

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, we're not creating a new connection every time it's called, we're creating a new connection every time it's called after the substrate URLs are changed, only then we create the connection

if flist := config.V4FlistURL; len(flist) > 0 {
env.FlistURL = flist
}
// if flist := config.V4FlistURL; len(flist) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should come from zos-config, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Eslam-Nawara Eslam-Nawara force-pushed the update-modules-on-config-update branch 3 times, most recently from 55db330 to fc867d1 Compare July 29, 2025 13:08
@Eslam-Nawara Eslam-Nawara force-pushed the update-modules-on-config-update branch from fc867d1 to a6949c3 Compare July 29, 2025 13:09

func (r *RedisStream) Start(ctx context.Context) {
ps := NewProcessor(r.sub, r.process, NewFileState(r.state))
r.processor = ps
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this deals with the already started stream? or we close the old one?


func (r *RedisStream) UpdateSubstrateManager(sub substrate.Manager) {
r.sub = sub
r.processor.sub = sub
Copy link
Collaborator

Choose a reason for hiding this comment

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

also here u r just changing sub and u didn't deal with the already started stream

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change will not have any effect on the running connection as long as it is open and healty, if the connection is closed unexpectedly, then new connection will be created with the new manager

Base automatically changed from load-config-urls-from-zos-config to main July 31, 2025 09:12
@Eslam-Nawara Eslam-Nawara force-pushed the update-modules-on-config-update branch from 7692ea4 to de1de8a Compare July 31, 2025 12:24
// if new update is received then the connection is broken as noded only issues new update only if
// the old manager is broken so we need to resubscribe with the new manager.
e.sub = newSub
log.Info().Msg("new substrate manager received, trying to resubscribe to the new manager")
Copy link
Collaborator

Choose a reason for hiding this comment

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

that is not correct u r printing log that there is a new substrate manager that u will try
then after that directly u print an error which will confuse the user for sure
the error should be printed first then the info for trying new connection should come after when u r actually trying

Copy link
Collaborator

Choose a reason for hiding this comment

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

also can u plz print which urls r failing and which urls u r trying?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will remove the log.Info message, will just log that the subscribtion failed and will try again, noded module will log that it was updated successfully once the update is done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also both noded and api-gateway modules logs the new urls that will be used, and the error messages of the modules trying to reach the chain shows the faulty urls

// if new update is received then the connection is broken as noded only issues new update only if
// the old manager is broken so we need to resubscribe with the new manager.
e.sub = newSub
log.Info().Msg("new substrate manager received, trying to resubscribe to the new manager")
Copy link
Collaborator

Choose a reason for hiding this comment

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

also can u plz print which urls r failing and which urls u r trying?

@Eslam-Nawara Eslam-Nawara force-pushed the update-modules-on-config-update branch from de1de8a to b41b6f5 Compare July 31, 2025 13:23
@Eslam-Nawara Eslam-Nawara merged commit 3e77601 into main Jul 31, 2025
1 check failed
@Eslam-Nawara Eslam-Nawara deleted the update-modules-on-config-update branch July 31, 2025 13:40
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.

3 participants