-
Notifications
You must be signed in to change notification settings - Fork 181
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
Multiple contracts per address support - code migration #144
Multiple contracts per address support - code migration #144
Conversation
m.logger.Debug(). | ||
Str("address", address.Hex()). | ||
Msg("Single contract or interface at address moved to new key") | ||
p.Key = addNameToKey(p.Key, program.Declarations[0].DeclarationIdentifier().Identifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to change the migration to not impact the original payloads in the migration steps, right now we return the pointer to the original stored values.
newKey := key | ||
newKey.KeyParts = make([]ledger.KeyPart, 3) | ||
copy(newKey.KeyParts, key.KeyParts) | ||
newKeyString := fmt.Sprintf("code.%s", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the long term plan was "code" be a key part type and we only use the name, so the ledger can optimize the code storage but I'm fine with this migration for now.
…low/flow-go into janez/multiple-contract-support-code-migration
…/flow-go into janez/multiple-contract-support-code-migration
…low/flow-go into janez/multiple-contract-support-code-migration
…low/flow-go into janez/multiple-contract-support-code-migration
} | ||
declarations := program.Declarations | ||
|
||
// find import declarations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turbolent does the import part look good to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
return []ledger.Payload{p}, nil | ||
} | ||
|
||
// We have two declarations. Due to the current rules one of them is an interface and one is a contract. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently zero or one contract, and zero or more contract interfaces are allowed. Was the idea here that we only support the case where we have a contract and a contract interface, because that's the only case in the real world (on the current testnet and mainnet)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats correct. The migration only supports the cases where there is:
- no contracts/interfaces
- one contract/interface (it will never be one interface as that is currently not allowed)
- one contract and one interface
…low/flow-go into janez/multiple-contract-support-code-migration
…/flow-go into janez/multiple-contract-support-code-migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, great work and great tests!
ref: onflow/flow#82
Migration for code registers.
error will be thrown in the following cases:
I ran this on devnet16. There were no errors, which means all contracts are migratable.