near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.3k stars 605 forks source link

Roll out Wasmer 2 #4910

Open MaksymZavershynskyi opened 2 years ago

MaksymZavershynskyi commented 2 years ago

We would like to roll out Wasmer 2 ASAP to improve our Wasm fees. AFAIU we need feature to be 6 weeks on Testnet before it it makes into Mainnet release, so we won't be able to have Wasmer 2 on Mainnet before Nearcon, but we should have it on Testnet. The following are the steps that we need to do before Nearcon:

Assigning to @olonho who is owning this feature and to @bowenwang1996 to supervise the Testnet release

bowenwang1996 commented 2 years ago

Synced with @matklad. @matklad will own the stabilization of this feature.

matklad commented 2 years ago

AFAIU it is a protocol change since Wasmer 0.17 is violating Wasm spec. So we need to document exactly how it violates it

Our current understanding is that the difference happens only in extreme edge cases, which were not actually observed historically. In this sense, this is not be a protocol change, and we are doing a protocol change conservatively, just to guard against us potentially missing a change in behavior. Still makes sense to document all this.

Properly gate the feature for Testnet release

Not entirely understand what this means. Assuming it's just "feature takes protocol version into account", than that's :white_check_mark:

Estimate new fee cost and update it

It would be less risky to roll out wasmer2 without cost upgrade, and do a cost upgrade later. That is, if we find out that w2 doesn't work despite all our testing efforts, if we don't do a cost upgrade, we can roll back to w1 just in case. Though, I don't think that cost decrease together with wasmer2 rollout is particularly risky.

MaksymZavershynskyi commented 2 years ago

It would be less risky to roll out wasmer2 without cost upgrade, and do a cost upgrade later. That is, if we find out that w2 doesn't work despite all our testing efforts, if we don't do a cost upgrade, we can roll back to w1 just in case. Though, I don't think that cost decrease together with wasmer2 rollout is particularly risky.

I think it is the same level of risk. We can roll back to w0 and old cost if we find out w2 does not work anyway, since we will likely find it out before Mainnet. However, if we separate w2 and fee rollout then we have less chance of making it work until Nearcon.

MaksymZavershynskyi commented 2 years ago

We would need to recompute the fee and merge it into master before end of next week, if we want it to make into Testnet release on Oct 18.

matklad commented 2 years ago

Wasmer2 stabilization PR: https://github.com/near/nearcore/pull/4934

I am sufficiently convinced that lowering wasm costs is fine, will prepare a PR for that as well. It still seems better to treat the two as two distinct protocol features, as that makes piece-wise stabilization easier. In particular, the infra for changing costs is new, and I don't want to keep stabilizing new regular op cost (and probably ecrecover cost) to be entangled with wasmer2 stabilization

matklad commented 2 years ago

Status update: the two required stabilizations (for wasmer 2, and for lowered costs) are in! Updating nomicon is on me.

matklad commented 2 years ago

Status: holding back updating the nomicon -- there's a high chance that this isn't in fact a protocol change: there are some contracts which behave differently under wasmer0 and wasmer2 (we have tests for that in the suite), but we have a reason to believe that we've never hit such cases in the history on the mainnet. To figure this out, we are doing a big history replay experiment, which takes more (CPU) time than originally expected.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity in the last 2 months. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.