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

R4R: system contract upgrade framework and upgrade tokenhub #16

Merged
merged 14 commits into from
Aug 11, 2020

Conversation

HaoyangLiu
Copy link
Contributor

No description provided.

@HaoyangLiu HaoyangLiu force-pushed the system-contract-upgrade branch 12 times, most recently from 8bffb98 to c8a05e1 Compare July 3, 2020 06:55
/* testnet upgrade config */

// setup testnet upgrade config
devnetUpgrapdeConfig[20000] = Upgrade{
Copy link
Collaborator

@unclezoro unclezoro Aug 5, 2020

Choose a reason for hiding this comment

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

can not just simple define devnetUpgrapdeConfig[20000] here. Because 20000 is treat as fork height here, we must define the fork height on chainConfig, like dao fork get DAOForkBlock in config. Otherwise will break the handshake protocol about forkId.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We need define a map like map[forkname] []*UpgradeConfig here. Then define different height for the fork for different network on Params file

@HaoyangLiu HaoyangLiu force-pushed the system-contract-upgrade branch from c8a05e1 to 9669e2a Compare August 6, 2020 08:44
@HaoyangLiu HaoyangLiu changed the base branch from develop to back_off August 6, 2020 09:12
@HaoyangLiu HaoyangLiu force-pushed the system-contract-upgrade branch 2 times, most recently from 911e1fe to 45a9e2c Compare August 6, 2020 09:15
@HaoyangLiu HaoyangLiu changed the title WIP: system contract upgrade framework and upgrade tokenhub R4R: system contract upgrade framework and upgrade tokenhub Aug 6, 2020
@HaoyangLiu HaoyangLiu force-pushed the system-contract-upgrade branch from f10d500 to 70a26aa Compare August 6, 2020 11:07

var (
// genesis contracts
validatorContract = common.HexToAddress("0x0000000000000000000000000000000000001000")
Copy link
Collaborator

@unclezoro unclezoro Aug 6, 2020

Choose a reason for hiding this comment

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

we have redefined the system contract address here, since parlia have done it too. But I don't know where to put it better either. Just a bit uncomfortable for this.

Copy link
Contributor Author

@HaoyangLiu HaoyangLiu Aug 6, 2020

Choose a reason for hiding this comment

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

System addresses in parlia.go are not completed. Besides, I think it would be better to defind all addresses in here ranther than in consensus engine.

/* Add mainnet genesis hash */
case params.ChapelGenesisHash:
network = chapel
case params.RialtoGenesisHash:
Copy link
Collaborator

Choose a reason for hiding this comment

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

if no match with any network, just return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the further development, we might need to start a local network. This local network might also need system upgrade, so I added a default network type.


logger.Info(fmt.Sprintf("Apply upgrade %s at height %d", upgrade.UpgradeName, blockNumber.Int64()))
for _, cfg := range upgrade.Configs {
logger.Info(fmt.Sprintf("Upgrade contract %s to commit %s", cfg.ContractAddr.String(), cfg.CommitUrl))
Copy link
Collaborator

@unclezoro unclezoro Aug 6, 2020

Choose a reason for hiding this comment

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

==> logger.Info("Upgrade contract to commit ", "address", cfg.ContractAddr.String(),"commit url", cfg.CommitUrl)

Copy link
Contributor Author

@HaoyangLiu HaoyangLiu Aug 6, 2020

Choose a reason for hiding this comment

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

commit url contains space. Besides, I think no need to follow this style. In many case, logger.Info is used together with fmt.Sprintf.

return
}

logger.Info(fmt.Sprintf("Apply upgrade %s at height %d", upgrade.UpgradeName, blockNumber.Int64()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

The log style here violate how the log being used.

Configs []*UpgradeConfig
}

type beforeUpgrade func(blockNumber *big.Int, contractAddr common.Address, statedb *state.StateDB)
Copy link
Collaborator

Choose a reason for hiding this comment

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

there is no need to define type beforeUpgrade and afterUpgrade, upgradeHook is enough.

Copy link
Collaborator

Choose a reason for hiding this comment

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

please add return (error) to this hook.

Copy link
Contributor Author

@HaoyangLiu HaoyangLiu Aug 6, 2020

Choose a reason for hiding this comment

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

there is no need to define type beforeUpgrade and afterUpgrade, upgradeHook is enough.

I don't think upgradeHook is enough. Sometime we have to do cleanup work before update code, and sometime we have to do init work after update code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for misunderstand. We can just define one function typeupgradeHook but multiple instances

type UpgradeConfig struct {
	BeforeUpgrade ugradeHook
	AfterUpgrade  ugradeHook
        ...
}

@HaoyangLiu HaoyangLiu force-pushed the system-contract-upgrade branch from 549f073 to 32ec9be Compare August 7, 2020 03:16
core/genesis.go Outdated Show resolved Hide resolved
@unclezoro unclezoro changed the base branch from back_off to develop August 7, 2020 09:12
@HaoyangLiu HaoyangLiu force-pushed the system-contract-upgrade branch from 8712a64 to 11a85ae Compare August 7, 2020 09:15
@HaoyangLiu HaoyangLiu force-pushed the system-contract-upgrade branch from 11a85ae to 650d066 Compare August 7, 2020 09:16
@unclezoro unclezoro merged commit 8c8c2a7 into develop Aug 11, 2020
@unclezoro unclezoro deleted the system-contract-upgrade branch August 28, 2020 02:40
galaio pushed a commit to galaio/bsc that referenced this pull request Jul 31, 2024
galaio added a commit to galaio/bsc that referenced this pull request Aug 16, 2024
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