Skip to content

Shutdown on upgrade#2648

Open
StefanIliev545 wants to merge 10 commits intomainfrom
siliev/shutdown-on-upgrade-l2
Open

Shutdown on upgrade#2648
StefanIliev545 wants to merge 10 commits intomainfrom
siliev/shutdown-on-upgrade-l2

Conversation

@StefanIliev545
Copy link
Copy Markdown
Contributor

Why this change is needed

We need the ability to schedule upgrades, which if old versions do not support would make them shutdown.
Still needs testing.

What changes were made as part of this PR

Please provide a high level list of the changes made

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

Copy link
Copy Markdown
Collaborator

@tudor-malene tudor-malene left a comment

Choose a reason for hiding this comment

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

Looks good in principle, but this is only indicative.

The branch needs to be rebased.

return msg, nil
}

func FromBlockSubmissionErrorMsg(msg *generated.BlockSubmissionErrorMsg) *errutil.BlockRejectError {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

wasn't this already merged as a separate pr?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah i split it out of this


for _, upgrade := range upgrades {
um.logger.Info("Upgrade detected", "featureName", upgrade.FeatureName, "featureData", upgrade.FeatureData)
blockHeight := blockHeader.Number.Uint64() + 64
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why not use NetworkUpgradeConfirmationDepth

}

// GetNetworkUpgradesByFeature retrieves network upgrades for a specific feature
func GetNetworkUpgradesByFeature(ctx context.Context, db *sqlx.DB, featureName string) ([]*NetworkUpgrade, error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

there are a bunch of unused functions here. What's up with them? Please leave a comment if they will be needed in the future, and for what

@@ -0,0 +1,17 @@
-- Create table for storing network upgrades
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

give this file a better name, like 003_netw_upgrades.sql

block_height_final bigint,
block_height_active bigint,
created_at timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

use this syntax:

INDEX (feature_name),
INDEX (block_height_final, block_height_active),
INDEX USING HASH (block_hash)

instead of the "create index" stuff below.
It's easier to read

ctx := context.Background()

// Ensure the current block is canonical before proceeding
isCanonical, err := um.storage.IsBlockCanonical(ctx, blockHeader.Hash())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

since this is called from OnL1Block, it means only canonical l1 blocks are sent in. I dont think this check is necessary, maybe just leave a comment


// Load activated upgrades up to current block height
currentHeight := blockHeader.Number.Uint64()
stored, err := um.storage.GetActivatedNetworkUpgrades(ctx, currentHeight)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

don't you have to adjust with the 64 constant?

}

// filterSupportedUpgrades filters upgrades to only include supported ones
func (um *upgradeManager) filterSupportedUpgrades(ctx context.Context, allUpgrades []NetworkConfig.NetworkConfigUpgraded) []NetworkConfig.NetworkConfigUpgraded {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this method feels too hypothetical.
I have a feeling it will not look like this in practice.
Please leave a comment that this is an indicative implementation

g.submitDataLock.Unlock() // lock is only guarding the enclave call, so we can release it now
if err != nil {
if strings.Contains(err.Error(), errutil.ErrBlockAlreadyProcessed.Error()) {
if resp.RejectError != nil {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wasn't this stuff already included in a pr?

})

wg.Go(func() error {
ti.issueUpgradeTransaction()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this needs to be removed

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.

2 participants