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

[Cadence 1.0] Make staged contract code update migration aware of updated system contracts #5461

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions cmd/util/ledger/migrations/cadence.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,35 @@ func NewCadence1ContractsMigrations(
stagedContracts []StagedContract,
) []ledger.Migration {

systemContractsMigration := NewChangeContractCodeMigration(chainID)
stagedContractsMigration := NewStagedContractsMigration(chainID).
WithContractUpdateValidation()

systemContractChanges := SystemContractChanges(
chainID,
SystemContractChangesOptions{
EVM: evmContractChange,
},
)

for _, change := range systemContractChanges {
systemContractsMigration.RegisterContractChange(change)

// Make sure the staged contracts migration is aware of the new system contract code
stagedContractsMigration.RegisterContract(
change.Address,
change.Contract,
)
}

stagedContractsMigration.RegisterContractUpdates(stagedContracts)

return []ledger.Migration{
NewAccountBasedMigration(
log,
nWorker,
[]AccountBasedMigration{
NewSystemContactsMigration(
chainID,
SystemContractChangesOptions{
EVM: evmContractChange,
},
),
systemContractsMigration,
},
),
NewBurnerDeploymentMigration(chainID, log),
Expand Down
11 changes: 0 additions & 11 deletions cmd/util/ledger/migrations/change_contract_code_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,3 @@ func mustHexAddress(hexAddress string) common.Address {
}
return address
}

func NewSystemContactsMigration(
chainID flow.ChainID,
options SystemContractChangesOptions,
) *ChangeContractCodeMigration {
migration := NewChangeContractCodeMigration(chainID)
for _, change := range SystemContractChanges(chainID, options) {
migration.RegisterContractChange(change)
}
return migration
}
8 changes: 6 additions & 2 deletions cmd/util/ledger/migrations/staged_contracts_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ func (m *StagedContractsMigration) RegisterContractChange(change StagedContract)

m.stagedContracts[address][registerID] = change.Contract

m.RegisterContract(address, change.Contract)
}

func (m *StagedContractsMigration) RegisterContract(address common.Address, contract Contract) {
location := common.AddressLocation{
Name: name,
Name: contract.Name,
Address: address,
}
m.contractsByLocation[location] = change.Code
m.contractsByLocation[location] = contract.Code
}

func (m *StagedContractsMigration) contractUpdatesForAccount(
Expand Down
Loading