stellar / rs-soroban-env

Rust environment for Soroban contracts.
Apache License 2.0
61 stars 42 forks source link

Implement CAP-58 (constructor support) #1447

Closed dmkozh closed 1 month ago

dmkozh commented 1 month ago

What

The implementation itself is fairly simple (thanks to not needing to support v21 semantics) and follows the CAP-58. It only has a few caveats:

Bulk of this change is tests, and testing is really not trivial as we want to cover a set product of several different options:

To make things worse, a contract may only have a single constructor, so this needed a lot of new test Wasms.

Why

See CAP-58 motivation.

Known limitations

I'm sure I haven't covered every possible combination of parameters in tests, but at least tried to have some basic coverage for most of the cases and most obvious combinations.

anupsdf commented 1 month ago

If a pre-v22 contract gets its wasm updated in v22+ protocol with update_current_contract_wasm host fn call and the new wasm has a constructor, we will not be calling the constructor right?

anupsdf commented 1 month ago

If a pre-v22 contract gets its wasm updated in v22+ protocol with update_current_contract_wasm host fn call and the new wasm has a constructor, we will not be calling the constructor right?

Nevermind, I see this mentioned in the CAP, When the contract has its code updated it is not considered created and thus constructor won't be called.