From d69e9054e602f808c4504e2007c25f4bd9ec7f53 Mon Sep 17 00:00:00 2001 From: Austin Abell Date: Wed, 1 Sep 2021 17:28:39 -0400 Subject: [PATCH] fix: update atomic register to u64::MAX-2 to avoid collisions (#557) --- CHANGELOG.md | 2 ++ .../res/cross_contract_high_level.wasm | Bin 244783 -> 244783 bytes .../res/cross_contract_low_level.wasm | Bin 267530 -> 267530 bytes examples/fungible-token/res/defi.wasm | Bin 118868 -> 118868 bytes .../fungible-token/res/fungible_token.wasm | Bin 201136 -> 201136 bytes .../gas-fee-tester/res/gas_fee_tester.wasm | Bin 135819 -> 135819 bytes .../res/lockable_fungible_token.wasm | Bin 134801 -> 134801 bytes .../mission-control/res/mission_control.wasm | Bin 128548 -> 128548 bytes .../res/approval_receiver.wasm | Bin 116413 -> 116413 bytes .../res/non_fungible_token.wasm | Bin 287245 -> 287245 bytes .../res/token_receiver.wasm | Bin 115684 -> 115684 bytes .../res/status_message_collections.wasm | Bin 86767 -> 86767 bytes .../status-message/res/status_message.wasm | Bin 115268 -> 115268 bytes examples/test-contract/res/test_contract.wasm | Bin 28014 -> 28014 bytes near-sdk/src/environment/env.rs | 2 +- 15 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b3b53783..640e8284f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## [unreleased] - mock: Update `method_names` field of `AddKeyWithFunctionCall` to a `Vec` from `Vec>`. [PR 555](https://github.com/near/near-sdk-rs/pull/555) - Method names were changed to be strings in `4.0.0-pre.2` but this one was missed +- env: Update the register used for temporary `env` methods to `u64::MAX - 2` from `0`. [PR 557](https://github.com/near/near-sdk-rs/pull/489). + - When mixing using `sys` and `env`, reduces chance of collision for using `0` ## `4.0.0-pre.2` [08-19-2021] - Update `panic` and `panic_utf8` syscall signatures to indicate they do not return. [PR 489](https://github.com/near/near-sdk-rs/pull/489) diff --git a/examples/cross-contract-high-level/res/cross_contract_high_level.wasm b/examples/cross-contract-high-level/res/cross_contract_high_level.wasm index 8c788c890c661213595498af188e824a523b2d2d..911b05c20dd99a1ee08860799b1719c1a4dff989 100755 GIT binary patch delta 183 zcmZ4ggKzy0z6~;)_-X~38X6iH6c`-^vYcus$8B|(oVDpHP`DXgxOcNSP`Cvu%mGxr zdDG^3j6ktgRHa+EYX#cCLJUAPvfCE0FxF1qw@VR7KG<~uNN(J%##q~YWB2wOyBV`e s8EdyY8!{PiGS*Hnv0_pOa_3kv^=SfW?G&a+pm2L@F4OkbT;^4N00Tipm;e9( delta 183 zcmZ4ggKzy0z6~;)_!tD58X6iH6c`-^vYZ$u$8B|(oVDpHP`DXgxOcNSP`Cvu%mGxr zdDG^3j6ktgRHa+E83fwELJUAPvfCE0FfvTuw@VR7KG<~uNN(J%#>mioWB2wOyBV`e s85y=a8!{PiGBQjrv0_pOa_3kv^=SfW?G&a+pm2L@F4OkbT;^4N0P$cuQ2+n{ diff --git a/examples/cross-contract-low-level/res/cross_contract_low_level.wasm b/examples/cross-contract-low-level/res/cross_contract_low_level.wasm index 8b76a21c176e61dbf9bd58886a974cf69fedcc24..af3ec197f613284a6e60a7adcc9a1c97e29e45e9 100755 GIT binary patch delta 183 zcmeBLCD64>V1w6UzFL8%hK2?P1x81KET`JZJ&scmFDBO%LynBf_P`Cvu%mGxr z`N5KTj6ktgRHa+EYX#cCLJUAP-pd=A8EYq>U8M*l->V1w6UJ_doNhK2?P1x81KEGLG^J&scmFDBO%LynBf_P`Cvu%mGxr z`N5KTj6ktgRHa+E83fwELJUAP-pd=A85t&@U8M*l->_6^S(_-X~38X6iH6c`-^vYcusi#It;Hfg*H6mCWp-ojlg&;k}>aH`#W Zt*MNav39a=hZ_6^S(_!tD58X6iH6c`-^vYZ$ui#It;Hfg*H6mCWp-oniw&;k}>aAMee Zt*MNakzulLhZ-Y8b4kbck`BfP?f}Nx8{_~0 diff --git a/examples/fungible-token/res/fungible_token.wasm b/examples/fungible-token/res/fungible_token.wasm index 3e9948176308e0190f05821b6c2e2db7c578d58a..ebdb2b1b20f9462c792bfa17d144c76331dec5be 100755 GIT binary patch delta 135 zcmdn6m}kRco`x-qlbiTz1)3Tf8Wxuy?ln^2S delta 38 ucmeBP%F(@)W5bGhybJ=34Gj$pOb$#AP7IT`&QoV(Xudmd``vkr>xuyoHV&%* diff --git a/examples/lockable-fungible-token/res/lockable_fungible_token.wasm b/examples/lockable-fungible-token/res/lockable_fungible_token.wasm index c6f5a23627f181f51d2bbbc29fc798eb12e387d8..3ec1c3cf2ae35973f27b6dfce8c648fa50e34800 100755 GIT binary patch delta 63 zcmbO@mt*2wjty)38EYr6>sMo}-F&rQN{p{oprxUqfkA=Mkt55gcJtq*FZj4?1zN#k R3{JJpAGU1&u!V79Bmggq8VCRY delta 63 zcmbO@mt*2wjty)385t(8>sMoB*nG8LN{o*|prxUqfkA=Mkt55AVe{XmFZj3_1X{sj R3{DKqAGU1&u!V79BmmD#7a9Nn diff --git a/examples/mission-control/res/mission_control.wasm b/examples/mission-control/res/mission_control.wasm index 9ae98daabed050c6d5d7cb0d1efc970d53565fcb..2c170729d852a7bb6738a2048f0a67e7df74018b 100755 GIT binary patch delta 47 zcmZ4ThJDE!_6=)iGS+ThH?vNNv39cV8g(Eibd8q@kXrB{T7a>(`Ok;#e?Bm3umS)O C#1+T@ delta 47 zcmZ4ThJDE!_6=)iGBRvlH?vNNkzum#8g(Eibd8q@kXrB{T7Z$E`Ok;#e?Bm3umS+r C7ZX delta 85 zcmaFT&ie9+cpjflc=IuJ08724u-%Jvs delta 47 zcmX@o!hWQMeZ$K#MuyF=$_zLe8750Nr~^694SkwG>e9+cpjflc=IuJ08724urLGV$ diff --git a/examples/test-contract/res/test_contract.wasm b/examples/test-contract/res/test_contract.wasm index 3a10f4eea0907332f3eacfbafa7cc77542478887..ccb344ddd2d14a03f8611ac8e7081bededbbaf3c 100755 GIT binary patch delta 28 icmaENi}Bqp#trwG8EYp$U{(Q=tSqXGwVSnBoHGHpKnjQe delta 28 icmaENi}Bqp#trwG85t%&U{(Q=tSqXG44buCoHGHXtO*eS diff --git a/near-sdk/src/environment/env.rs b/near-sdk/src/environment/env.rs index 8a4a1a73f..ccdeea112 100644 --- a/near-sdk/src/environment/env.rs +++ b/near-sdk/src/environment/env.rs @@ -20,7 +20,7 @@ const REGISTER_EXPECTED_ERR: &str = /// Register used internally for atomic operations. This register is safe to use by the user, /// since it only needs to be untouched while methods of `Environment` execute, which is guaranteed /// guest code is not parallel. -const ATOMIC_OP_REGISTER: u64 = 0; +const ATOMIC_OP_REGISTER: u64 = std::u64::MAX - 2; /// Register used to record evicted values from the storage. const EVICTED_REGISTER: u64 = std::u64::MAX - 1;