near / nearcore

Reference client for NEAR Protocol

Home Page:https://near.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Revisit including contract code in state witness for deploy-contract actions

tayfunelmas opened this issue · comments

See related thread here.

Not for stateless protocol MVP but can be revisited later.

Summary: For deploy-contract actions we need to have the size of the old contract to calculate the new storage for the account (eg. diff between old and new contract code sizes will contribute to the storage).

Current approach: The reliable way to get the old code size is to actually send the code the state witness. Thus, we will put the old code for the account to the state witness for action_deploy_contract. It is an expensive action and there shouldn't be much txs doing that.

Future approach: Adding contract code for action_deploy_contract can be avoided by adding the code-length the Account similar to code-hash. Note that Account will be sent along with the code length in the state witness. But this requires a protocol change and a database migration (to populate the code-length for the existing accounts.