-
Notifications
You must be signed in to change notification settings - Fork 2
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
KB Article: Contract migration to 2.0 #27
Conversation
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.
Link to original codes because they might be (or are already) subject to change.
runtime::get_call_stack
behaves differently from 1.x versions.
You are using cep-18 as an example but in said code the source of most changes is how we handle the new data structuring of runtime::get_call_stack
ContractPackageHash was half removed in favour of the new PackageHash type which on .into()
function call turns into Key::Package
variant as opposed to the old ContractPackageHash
which shared Key::Hash
variant with ContractHash
.
get_caller
on the otherhand currently still returns account_hash
which might cause confusion with the developers as it turns into Key::Account
while there is a new Key::AddressableEntity(Account)
variant to side with the new Key::AddressableEntity(SmartContract)
variant.
- **Native Events and Message Topics:** | ||
- Casper 2.0 prioritizes native event emission through message topics, offering flexibility and better integration. | ||
- Utilize `runtime::emit_message` to send events on specific topics. | ||
- **CES (Casper Event Standard):** |
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.
In case this is a doc for overall condor migration, CES should not be here. That is an implementation detail per contract and is not relevant for general condor readiness.
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 kept it here as a major change for smart contract developers with a note While not mandatory, switching to native events is recommended due to their cost-efficiency
. I removed the info about events from the Upgrade steps
section
3. **Event Handling:** | ||
- **Native Events and Message Topics:** | ||
- Casper 2.0 prioritizes native event emission through message topics, offering flexibility and better integration. | ||
- Utilize `runtime::emit_message` to send events on specific topics. |
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.
Messages are not held in global state, so they are not subject to the gas cost counted per stored byte, making them them cost 1/10 as much as storing the same data a dictionary.
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.
Added info about it
|
||
## Essential Upgrade Steps | ||
|
||
1. **Key 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.
This needs to be done for existing contracts in case the contract developer/maintainer changes the way they handle keys. It is possible to write your codes in a manner that you don't need to do these migration steps.
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.
Added this info
|
||
```rust | ||
#[no_mangle] | ||
pub fn migrate_user_balance_keys() { |
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.
Without further context/comments/documentation, this code might not mean much to most people. Link to original.
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.
Added comments to the code example explaining what is happening in more details
Applied all the suggestions. There is a note at the beginning saying that it is a WIP and may be subject to change as well as adding important information about |
No description provided.