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

feat: support switch backend binaries by height #713

Merged

Conversation

jjyr
Copy link
Collaborator

@jjyr jjyr commented May 31, 2022

This PR support upgrade backend binaries by height.

Now, instead of define backends in the config.toml we define backend_switch:

pub struct BackendSwitchConfig {
    pub switch_height: u64,
    pub backends: Vec<BackendConfig>,
}

switch_height means in which height we use the new version of backend. For example:

To upgrade godwoken config file, we should move all the backends fields into a backend switch clause such as: BackendSwitchConfig {switch_height: 0, backends}, when we need to upgrade a backend, we define a new backend switch item follows the original one such as: BackendSwitchConfig {switch_height: 1000, backends: <new SUDT backend>}. Then when the tip block arrives the 1000 height, the new SUDT backend will be loaded instead the old one, the other backends are not change.

This change affects the following API:

https://github.com/nervosnetwork/godwoken/blob/develop/docs/RPC.md#method-gw_get_node_info

Consider mostly use-case of this API is to use the validator_script_type_hash field of a backend, I think we can only returns backends at 0 height for now.

@jjyr jjyr requested review from Flouse, blckngm, zeroqn and keroro520 May 31, 2022 14:10
@gw-bot

This comment was marked as off-topic.

@gw-bot

This comment was marked as outdated.

@gw-bot

This comment was marked as outdated.

@jjyr jjyr force-pushed the support-switch-backend-binaries-by-tip-height branch from d2d3ec7 to f998684 Compare June 2, 2022 04:29
@gw-bot
Copy link

gw-bot bot commented Jun 2, 2022

Running integration test

Workflow Run Id: 2426636431

Components:

Manually running integration test

Post a comment contains

/itest
[prebuilds: tag]
[godwoken: branch/ref]
[scripts: branch/ref]
[polyjuice: branch/ref]
[web3: branch/ref]
[kicker: branch/ref]
[tests: branch/ref]

Note: [] means optional, for example

/itest
prebuilds: dev-202203280240
godwoken: develop
scripts: 81676d9d53ffdf5bbaa60483928d07da16eb4a88
polyjuice: e37553b9

Run Result

failure

Run Result

failure

self.backend_switches
.iter()
.rev()
.find(|(height, _)| block_number >= *height)
Copy link
Contributor

Choose a reason for hiding this comment

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

Binary search could be used to improve performance if the number of switches is high.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, but since the chain is keep growing, the later version of backend has more possibility to be selected.

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