📜 [專欄新文章] Solidity Data Collision
✍️ Wias Liaw
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
這是一篇關於 Proxy Contract 和 delegatecall 的注意事項。
Delegatecall
當 A 合約對 B 合約執行 delegatecall 時,B 合約的函式會被執行,但是對 storage 的操作都會作用在 A 合約上。舉例如下:
但是假如多加了一個 other 欄位在 _value 之前,執行合約之後反而是 other 欄位被更改了。
Storage Layout
了解上面的合約之前要先了解 Solidity 怎麼儲存 State Variables。Solidity Storage 以 Slot 為單位,每個 Slot 可以儲存 32 bytes 的資訊,一個 Contract 擁有 2**256 個 Slot。上述可以寫成一個映射關係 mapping(uint256 => bytes32) slots。
Solidity 會從 Slot Index 為零開始分配給 State Variable。
除了 mapping 和 dynamically-sized array,其他的 State Variable 會從 index 為零的 slot 開始被分配。
沒有宣告確切大小的 Array 會以 Slot Index 計算出一個雜湊值並將其作為 Slot Index。透過計算 keccak256(slot) 可以得知 _arr[0] 被存在哪裡,如果要取得 _arr[1] 則將計算出來的雜湊加上 Array 的 index 即可。
Mapping 則是以 Slot Index 和 Key 計算出一個雜湊值並將其作為 Slot Index。透過計算 keccak256(key, slot) 可以得到 mapping(key => value) 被存在哪。
Storage Collision
回到 DelegateExample_v2 的合約,對 B 來說, add 最後儲存加法的 Slot Index 為零,所以使用 A 的 Storage 執行 B 的函式結果自然會儲存在 A 的 other 裡,其 Slot Index 為 0。
這個問題也發生在 Proxy Contract,Layout 如下,當有需要更改 _owner 的操作,就會順帶把 _implementation 也更改了。
|Proxy |Implementation ||--------------------------|-------------------------||address _implementation |address _owner | <= collision|... |mapping _balances || |uint256 _supply || |... |
OpenZeppelin 處理的手法也很簡單,就是將 _implementation 換地方擺。以特定字串的雜湊值作為 Slot Index,儲存 Implementation 的地址。
|Proxy |Implementation ||--------------------------|-------------------------||... |address _owner ||... |mapping _balances ||... |uint256 _supply ||... |... ||address _implementation | | <= specified|... | |
openzeppelin-contracts/ERC1967Upgrade.sol at 83644fdb6a9f75a652d2fe2d96cb26073a14f6f8 · OpenZeppelin/openzeppelin-contracts
hardhat-storage-layout
如何知道合約的 Storage Layout 呢?這邊推薦一個 Hardhat Plugin,按照文件就能得到合約的 Storage Layout。
Ethereum development environment for professionals by Nomic Labs
Reference
Understanding Ethereum Smart Contract Storage
Collisions of Solidity Storage Layouts
Proxy Upgrade Pattern - OpenZeppelin Docs
Solidity Data Collision was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
同時也有14部Youtube影片,追蹤數超過0的網紅CarDebuts,也在其Youtube影片中提到,? คลิปรถใหม่ 2019-2020 มาแล้วครับ คลิกที่นี่ https://www.youtube.com/channel/UCSebcviE-UeYMxVRNozwqtw/videos Body and Chassis Design The 2018 Accord...
「environment mapping」的推薦目錄:
- 關於environment mapping 在 Taipei Ethereum Meetup Facebook 的最佳解答
- 關於environment mapping 在 This is Mr. B Facebook 的最佳貼文
- 關於environment mapping 在 Alan Wong Photography Facebook 的最佳貼文
- 關於environment mapping 在 CarDebuts Youtube 的最讚貼文
- 關於environment mapping 在 赤髪のとものゲーム実況チャンネル!! Youtube 的最佳解答
- 關於environment mapping 在 赤髪のとものゲーム実況チャンネル!! Youtube 的精選貼文
environment mapping 在 This is Mr. B Facebook 的最佳貼文
Disney Enterprises 為新技術申請專利, 稱作"Multimedia System for Transforming Any Room into A Show Environment". 利用Projection mapping 同其他特效, 配合房內多個道具同控制系統, 將房間牆壁變成令人置身其中嘅互動演出.
https://bit.ly/3t2fupg
專利申請中特別提及到呢個技術可以用喺Waiting Areas 以至Hotel Rooms. 並同時花筆墨去解釋呢種技術能夠提升酒店房內嘅in-room entertainment.
Disney Resort Hotel 嘅新時代來臨? 唔通係會用喺Walt Disney World 興建緊嘅Star Wars 酒店?
environment mapping 在 Alan Wong Photography Facebook 的最佳貼文
Dance Animation-Mask On
Dancer @alanw417
Music @heartgreymusic
Dance Animation
When started?
I knew I wasn’t good at drawing since I was small and I tried to avoid it as much as possible for years. The first time I started to learn about animation was to create LED Mapping Dance and produce neon lights outlining dancers.
Taking up the role as a producer in recent years means it is essential for me to prepare storyboard to facilitate communication with team members. Therefore, I am trained to present the ideas in my mind with illustration.
CO = CODE = COVID = COLD
She is CO
Every dancer wants a perfect body. In animation, CO is not affected by gravity and is able to break the boundary. Not only you can control her limbs, but also be able to make her hair and clothes to be the focus while dancing.
Flow with consciousness
There is no limitation to create CO with animation.
CO learnt how to dance during COVID-19. She could pick up dancing easily. She could dance anywhere in the world, without limitation on number of people, location nor venue. She could dance with any concept.
I wish to bring CO to different venues, different environment and to participate in different film festivals. I wish CO could one day dance with real-life dancers on stage.
#danceeffect #danceanimation #dance #dancevideo #dancelife #jumpingframes #dancefilm #dancefestivals #dancevideoworldwide #danceculture #animationfestival
environment mapping 在 CarDebuts Youtube 的最讚貼文
? คลิปรถใหม่ 2019-2020 มาแล้วครับ คลิกที่นี่ https://www.youtube.com/channel/UCSebcviE-UeYMxVRNozwqtw/videos
Body and Chassis Design
The 2018 Accord's new body structure is lighter and more rigid, utilizing 29 percent ultra-high-strength steel, the most ever for a mass-produced Honda car. Overall, the new Accord employs 54.2 percent high strength steel (above 440 MPa).
Key body features include the latest generation of Honda's Advanced Compatibility Engineering™ (ACE™) body structure with crash stroke front frame, tailor-tempered rear frame members for improved crash-energy absorption, and the extensive use of structural adhesives for increased rigidity, cabin quietness and weight reduction. Total vehicle weight is down between approximately 110 to 176 pounds, depending on trim, while body torsional and bending rigidity are improved 32 and 24 percent, respectively, aiding ride quality, cabin quietness, and dynamic performance.
Mated to the new body is a more sophisticated new chassis design. The 2018 Accord's chassis is 6-percent lighter than before (not including wheels and tires) and features a new Macpherson strut front suspension with L-shaped aluminum lower arms mounted to an aluminum front subframe. The new setup better isolates and manages varying road inputs, improving handling precision, ride quality and cabin quietness along with outstanding high-speed stability and control. The new, more space-efficient rear suspension is a multi-link design mounted to a more rigid, floating rear subframe. Fluid-filled compliance bushings at all four corners further improve ride comfort and absorption of road irregularities.
Touring trims of Accord also feature, for the first time, an Adaptive Damper System with the ability to adjust shock absorber damping force every 1/500 of a second (0.002 second), using a proprietary Honda control algorithm, providing for a more compliant and controlled ride in all driving situations. The adaptive dampers are tied to a Two-Mode Driving System with Normal and Sport modes that allows the driver to dial-up/down the vehicle's sporty reflexes depending on the driving environment. The system engages with multiple chassis and drivetrain components, including the new dual-pinion variable-ratio electric power steering (EPS), automatic transmission, drive-by-wire throttle, adaptive dampers and Active Sound Control system, to provide the driver with an expanded range of driving characteristics. An ECON mode is also available that helps improve fuel efficiency by modifying throttle mapping and HVAC operation.
The new Accord has a 10-mm lower center of gravity. The adoption of lighter-weight turbocharged engines and other body design changes reduce the vehicle's moment of inertia, resulting in crisper turn-in and steering response. All models now have near optimal FWD weight distribution of approximately 60/40 percent front/rear. Accords with the new 2.0-liter VTEC turbo and 10AT check in at approximately 61/39 percent front/rear, a significant improvement versus the current V6 Accord with 6AT.
Along with the first application of structural adhesives to Accord, cabin quietness is further enhanced by a comprehensive sound-insulating package that includes full underbody covers (which also aid aerodynamics), front and rear fender and engine compartment insulators, alloy wheels with Honda-proprietary resonator technology, sound-absorbing carpet, acoustic laminated windshield glass – plus front door acoustic glass on EX and above – and a new, 3-microphone Active Noise Control system. The result is low noise levels with a well-balanced sound quality and a pleasingly sporty engine note.
Advanced Safety and Driver-Assistive Technology
For 2018, all Accords feature the full suite of Honda Sensing® safety and driver-assistive technologies as standard equipment. Honda Sensing includes Collision Mitigation Braking System™ (CMBS™), Lane Departure Warning, Road Departure Mitigation, Adaptive Cruise Control with Low-Speed Follow and, for the first time, Traffic Sign Recognition (see Safety section for more details). Additional available driver-assistive technologies include Blind Spot Information, front and rear parking sensors, Rear Cross Traffic Monitor and Driver Awareness Monitor; and all models feature a Multi-Angle Rearview Camera with dynamic guidelines.
Standard advanced active and passive safety systems include Vehicle Stability Assist with Traction Control, Anti-lock brakes with Electronic Brake Booster, Tire Pressure Monitoring System (TPMS), advanced front airbags, driver and front-passenger side airbags and new driver and front-passenger knee airbags. The Accord targets top U.S. government (NCAP) and IIHS collision safety ratings.

environment mapping 在 赤髪のとものゲーム実況チャンネル!! Youtube 的最佳解答
☆チャンネル登録お願いします!!☆
→ http://goo.gl/m3Omo8
☆実写動画のサブチャンネル登録はこちら☆
→ http://goo.gl/eZ9lPC
ぺいんとチャンネル
https://www.youtube.com/user/peinto1008
~↓赤髪のとものマイクラ実況まとめ↓~
◆【第1弾 採掘王シリーズ】
http://goo.gl/CiUuLE
◆【第2弾 あかがみんクラフト】
http://goo.gl/2YQJF5
◆【第3弾 MODで遊ぼう】
http://goo.gl/1md3fr
◆【第4弾 和を目指して】
http://goo.gl/21RZUC
◆【第5弾 あかがみんクラフト2】
http://goo.gl/pa6EXX
◆【第6弾しろくろクラフト】
http://goo.gl/CCjB9W
◆【第7弾 和を食して】
http://goo.gl/2DT5sz
◆【第8弾 超巨大日本地図を作る!!】
https://goo.gl/X8xJ0X
◆【第9弾アルカディア】
https://goo.gl/r77aml
◆【第10弾アスタルテ】
https://goo.gl/hQ75ts
◆【第11弾アスタルテ2】
https://goo.gl/UmqnnQ
◆【第12弾ミナトモクラフト】
https://goo.gl/VQzPLx
◆【第13弾動物MOD実況】
https://goo.gl/lZM59T
◆【第14弾リスナー街づくり】
https://goo.gl/UepbI0
◆【第15弾エーテル実況】
https://goo.gl/0BX45O
◆【第16弾スカイブロック】
https://goo.gl/yMFAWy
◆【第17弾トロピクラフト】
https://goo.gl/yqKdCB
◆【第18弾あかがみんクラフト3】
https://goo.gl/hiypYt ←コレ
◆【第19弾 豆腐Craft2】
https://goo.gl/S5dHp3
◆【第20弾 2人きりクラフト】
https://goo.gl/v5Ww9a
◆【第21弾 黄昏の森 再び!】
https://goo.gl/0Kv1j4
◆【第22弾 赤ぺんマイクラ】
◆【単発マイクラ実況】
http://goo.gl/oR04rl
【赤髪のともリンク】
★twitter→https://twitter.com/tomo0723sw
★ニコ生コミュニティ→http://goo.gl/xj5TlS
★公式サイト→http://akstudioxx.web.fc2.com/
Twin MusicomのCarefree Melodyは、http://www.twinmusicom.org/ライセンス(http://www.twinmusicom.org/)でライセンス付与されています。
ソース: http://www.twinmusicom.org/song/302/carefree-melody
アーティスト: http://www.twinmusicom.org
Kevin MacLeodのCarny's Danceは、https://creativecommons.org/licenses/by/4.0/ライセンス(https://creativecommons.org/licenses/by/4.0/)でライセンス付与されています。
ソース: https://soundcloud.com/kevin-9-1/carnys-dance
アーティスト: http://incompetech.com/
AudionautixのPop Tuneは、https://creativecommons.org/licenses/by/4.0/ライセンス(https://creativecommons.org/licenses/by/4.0/)でライセンス付与されています。
アーティスト: http://audionautix.com/
~使用させて頂いているMOD~
「The Betweenlands」
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1441135-the-betweenlands-a-dark-hostile-environment-v2-0-2
「Guide Book Mod」
http://mod-minecraft.net/guide-book-mod/

environment mapping 在 赤髪のとものゲーム実況チャンネル!! Youtube 的精選貼文
☆チャンネル登録お願いします!!☆
→ http://goo.gl/m3Omo8
☆実写動画のサブチャンネル登録はこちら☆
→ http://goo.gl/eZ9lPC
ぺいんとチャンネル
https://www.youtube.com/user/peinto1008
~↓赤髪のとものマイクラ実況まとめ↓~
◆【第1弾 採掘王シリーズ】
http://goo.gl/CiUuLE
◆【第2弾 あかがみんクラフト】
http://goo.gl/2YQJF5
◆【第3弾 MODで遊ぼう】
http://goo.gl/1md3fr
◆【第4弾 和を目指して】
http://goo.gl/21RZUC
◆【第5弾 あかがみんクラフト2】
http://goo.gl/pa6EXX
◆【第6弾しろくろクラフト】
http://goo.gl/CCjB9W
◆【第7弾 和を食して】
http://goo.gl/2DT5sz
◆【第8弾 超巨大日本地図を作る!!】
https://goo.gl/X8xJ0X
◆【第9弾アルカディア】
https://goo.gl/r77aml
◆【第10弾アスタルテ】
https://goo.gl/hQ75ts
◆【第11弾アスタルテ2】
https://goo.gl/UmqnnQ
◆【第12弾ミナトモクラフト】
https://goo.gl/VQzPLx
◆【第13弾動物MOD実況】
https://goo.gl/lZM59T
◆【第14弾リスナー街づくり】
https://goo.gl/UepbI0
◆【第15弾エーテル実況】
https://goo.gl/0BX45O
◆【第16弾スカイブロック】
https://goo.gl/yMFAWy
◆【第17弾トロピクラフト】
https://goo.gl/yqKdCB
◆【第18弾あかがみんクラフト3】
https://goo.gl/hiypYt ←コレ
◆【第19弾 豆腐Craft2】
https://goo.gl/S5dHp3
◆【第20弾 2人きりクラフト】
https://goo.gl/v5Ww9a
◆【第21弾 黄昏の森 再び!】
https://goo.gl/0Kv1j4
◆【第22弾 赤ぺんマイクラ】
◆【単発マイクラ実況】
http://goo.gl/oR04rl
【赤髪のともリンク】
★twitter→https://twitter.com/tomo0723sw
★ニコ生コミュニティ→http://goo.gl/xj5TlS
★公式サイト→http://akstudioxx.web.fc2.com/
Twin MusicomのCarefree Melodyは、http://www.twinmusicom.org/ライセンス(http://www.twinmusicom.org/)でライセンス付与されています。
ソース: http://www.twinmusicom.org/song/302/carefree-melody
アーティスト: http://www.twinmusicom.org
Kevin MacLeodのCarny's Danceは、https://creativecommons.org/licenses/by/4.0/ライセンス(https://creativecommons.org/licenses/by/4.0/)でライセンス付与されています。
ソース: https://soundcloud.com/kevin-9-1/carnys-dance
アーティスト: http://incompetech.com/
AudionautixのPop Tuneは、https://creativecommons.org/licenses/by/4.0/ライセンス(https://creativecommons.org/licenses/by/4.0/)でライセンス付与されています。
アーティスト: http://audionautix.com/
~使用させて頂いているMOD~
「The Betweenlands」
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1441135-the-betweenlands-a-dark-hostile-environment-v2-0-2
「Guide Book Mod」
http://mod-minecraft.net/guide-book-mod/
