分享好文,中學生要學電腦嗎?
作者:創新工場CTO、人工智慧工程院執行院長 王詠剛
文章来自半轻人微信公众号(ban-qing-ren)
………………………………
朋友的孩子高中剛畢業,已拿到美國頂尖大學(非電腦專業)的錄取通知。疫情影響,不知何時才能去學校報到。孩子想抓緊學習一下程式設計,為大學打好基礎。這孩子找我聊了一個多小時,從如何學程式設計,聊到非電腦專業和電腦專業的路徑差異,又聊到如何從不同角度認識電腦與程式設計。聊得比較寬泛,不知是否對這孩子有用。
回想我自己的高中時代:那時雖迷戀程式設計,卻完全沒有懂行的人指導。在我們那個四線城市的廠礦中學裡,開設電腦興趣課的老師知道的資訊還沒我多。我高一時跑到北京中關村逛街,卻完全沒意識到中國第一代頂尖程式師當時就在我身邊的低矮辦公樓裡寫代碼(這話說得並不準確,比如求伯君那年就主要是在珠海做開發),鼎鼎大名的UCDOS、WPS、CCED就出自他們之手……我在當時街邊的一家書店(位置似乎就在今天的鼎好大廈對面)買到了許多種印刷品質極低劣的電腦圖書。用今天的標準看,那就是一批盜版影印或未授權翻譯的國外圖書。可那批書竟成了我高中時代最寶貴的程式設計知識來源。
顯然,我在高中時根本就是野路子學電腦。現在後悔也沒用,當時我的眼界或能觸及的資源就那麼多。如果能穿越回30年前,我該對喜歡程式設計的自己說些什麼呢?這些年,我與世界上最好的一批程式師合作過,也參與過世界上最有價值的軟體系統研發——我所積累的一些粗淺經驗裡,有哪些可以分享給一個愛程式設計的中學生?
【問題1】中學生要不要學電腦?
當然要!
每個中學生都要學。只不過——建議大部分中學生使用“休閒模式”,小部分(不超過10%)中學生使用“探險模式”。
啊?兩個模式?那我該進入哪個模式?⟹請跳轉至【問題2】
【問題2】選哪個模式?
你癡迷電腦嗎?比如,你玩遊戲時會特別想知道這遊戲背後的代碼是如何編寫的嗎?再比如,就算老師家長不同意你學電腦,甚至當著你的面把電腦砸了,你也要堅持學電腦嗎?如果是,恭喜你進入“探險模式”⟹請跳轉至【問題200】
你對數學有興趣嗎?比如,你看到街邊建築的曲線,就會在腦子裡琢磨曲線對應的函數或方程嗎?每當手裡攥著幾粒骰子,你就會不由自主地計算概率嗎?如果是,歡迎進入“探險模式”⟹請跳轉至【問題200】;當然,如果有些猶豫,也可以先進入“休閒模式”⟹請跳轉至【問題100】
即便你對電腦和數學興趣不大,家長、老師還是強烈建議你學電腦嗎?就算你一百個沒時間一千個不願意,家長、老師還是會逼著你學電腦嗎?如果是,建議你主動進入“休閒模式”並向家長、老師彙報說“我已經按照前谷歌資深軟體工程師的專業建議在認真學程式設計了”⟹請跳轉至【問題100】
其他情況,一律進入“休閒模式”。⟹請跳轉至【問題100】
【問題100】休閒模式 | 主要學什麼?
“休閒模式”將電腦視為我們生活、工作中的必備工具,主要學習如何聰明、高效、優雅地使用計算設備。這裡說的計算設備,包括所有形式的電腦、手機、遊戲機、智慧家電以及未來一定會進入生活的自動駕駛汽車。
什麼什麼?你已經會用電腦、會玩手機、會打遊戲了?別著急,慢慢往下看。
【問題101】休閒模式 | 我會用搜尋引擎嗎?
我知道你會用百度搜習題答案。但,習題答案不是知識。你會用搜尋引擎來搜索和梳理知識嗎?請試著用電腦和你喜歡的搜尋引擎來解決如下兩個問題:
(1)圓周率𝜋的計算方法有多少種?每種不同的計算方法分別是由什麼人在什麼時代提出的?借助電腦,今天人們可以將圓周率𝜋計算到小數點後多少位?將圓周率𝜋計算到小數點這麼多位元,一次大概需要花掉多少度電?
(2)全球大約有多少個廁所?在發展程度不同的國家,分別有多少比例的人可以享用安裝了抽水馬桶的衛生廁所?為什麼比爾·蓋茨曾大力推動一個設計新型馬桶的研發專案?比爾·蓋茨的公益組織在這個專案上大約花費了多少資金,最終收到了多大的效果?
如果你沒法快速得到上述問題的全部答案,那就給自己設一個小目標:一個月內,學會用搜尋引擎系統地獲取、梳理一組知識點的全部技巧。
【問題102】休閒模式 | 接下來學什麼?
建議學好典型的工具軟體。比如,我知道你會用Office了,但用Office和用Office是很不一樣的。對生活、學習、工作來說,學好、學透一個工具軟體比鑽研程式設計技巧更實用。
你會用Excel來管理班級公益基金的預算和實際收支情況嗎?
你會用Excel做出過去20年裡全球大學排名的演變趨勢圖嗎?
你會用Word排版一篇中學生論文嗎?論文中的圖表和最後的參考文獻部分該如何排版?
你會用Word編排一份班級刊物,包含封面、扉頁、目錄、插圖頁、附錄、封底等部分,可以在列印後直接裝訂成冊嗎?
PowerPoint呢?你有沒有研究過蘋果公司發佈會上那些幻燈片的設計?當約伯斯(多年以前)或蒂姆·庫克站在幻燈片前的時候,他們的演講思路是如何與幻燈片完美結合的?
還有哦,別忘了學學如何為數碼照片做後期,如何用電腦或手機剪視頻,如何為剪輯好的視頻配字幕,如何將照片、音樂、視頻等素材結合起來,做出一段吸引人的快手/抖音短視頻。
最後,抽空玩玩那些設計精妙的遊戲吧,比如《紀念碑穀》、《塞爾達傳說:曠野之息》之類;同時,遠離那些滿屏廣告,或者一心騙你在遊戲裡充值花錢的垃圾。
【問題103】休閒模式 | 不學學知識嗎?
當然要學知識。下面每種實用的電腦知識都夠大家學一陣子了。
(1)色彩知識:你知道同一張數碼照片在不同品牌的手機螢幕上、不同的電腦螢幕上、不同的智慧電視上顯示時,為什麼經常有較大色差嗎?你知道有一些色彩只適合螢幕顯示,不適合列印輸出嗎?你知道軟體工具裡常用的RGB、HSL之類的色彩空間都是什麼意思嗎?如何在設計PowerPoint幻燈片時選擇一組和諧美觀的色彩?
(2)字體知識:你知道什麼是襯線字體,什麼是無襯線字體嗎?你知道網頁中常用的英文字體都有哪些嗎?你知道商務演講時最適用于幻燈片的英文字體有哪些嗎?你知道電腦和手機常用的黑體、宋體、仿宋體、楷體等中文字體分別適合哪些實際應用場合嗎?你會將不同字體混排成一個美觀的頁面嗎?
(3)網路知識:你知道5G是什麼嗎?你知道5G和4G在通信頻寬、通信距離上的具體區別嗎?你知道什麼是路由器,什麼是防火牆嗎?你知道如何配置路由器,如何配置防火牆嗎?微信或QQ聊天時,對方發的文字、語音或視頻是如何傳送到你的手機上的?
(4)應用知識:淘寶中搜索得到的商品資訊是從哪裡來的?商品是按什麼方式排序的?為什麼購物APP經常會推薦給你一些曾經買過、看過的商品?你知道如何為自己建立個人網站嗎?你知道如何管理微信公眾號嗎?
(5)安全知識:你知道網路上的釣魚攻擊是怎麼回事兒嗎?你知道什麼是電腦漏洞嗎?你知道駭客為什麼想把一大批受攻擊的電腦變成可以遠端操控的傀儡機嗎?你知道為什麼現在很多手機APP都要通過短信發送驗證碼嗎?如果驗證碼被壞人截獲,你會面臨哪些風險?
這裡只是舉例。實用的電腦知識還有很多。大家可以自己發掘。
【問題104】休閒模式 | 我需要學程式設計嗎?
可以學,但不是必須。即便學,也只需要根據自己的需要,學那些最能幫你解決現實問題的部分。
【問題105】休閒模式 | 我該學什麼程式設計語言?
在“休閒模式”裡,電腦就是工具,程式設計也是工具,夠用就好。學什麼程式設計語言,完全看你想要電腦幫你做什麼。
• 如果你想對資料處理有更多自主權,那不妨學學Python;
• 如果你想做簡單的交互演示程式,那就先把JavaScript學起來;
• 如果你想更好、更快地寫論文,那不妨學學LaTeX(什麼什麼,LaTeX不是程式設計語言?你太小看LaTeX了);
• 如果你想學做簡單的手機APP,那麼,Android手機就學Java,蘋果手機就學Swift好了;
• 如果你只想知道程式設計是怎麼回事,那……從Python或JavaScript開始就行。其實,跟五六歲的小朋友一起學學Scratch圖形程式設計也不錯。
【問題106】休閒模式 | 我需要學人工智慧嗎?
在“休閒模式”裡,最需要學的不是“人工智慧的實現原理”,而是“什麼是人工智慧”,以及“人工智慧能做什麼,不能做什麼”。
• 在手機上試一試,人工智慧做語音辨識時能做到什麼水準?哪些話容易識別,哪些話不容易識別?
• 打開機器翻譯軟體,試一試哪些資訊翻譯得好,哪些資訊翻譯得不好?
• 手機上的拍照軟體一般都有人臉識別功能。試一試人臉識別在什麼場景下做得好,什麼場景下做得不好?
• 找一部講人工智慧的科幻電影,用自己的判斷解讀一下,電影裡哪些技術有可能成為現實,哪些技術存在邏輯矛盾。
【問題107】休閒模式 | 推薦什麼參考書、參考文獻?
書不重要,豆瓣評分7分以上的電腦應用、程式設計甚至科普類圖書都可以拿來翻翻。
直接在知乎裡搜索你想瞭解或學習的知識點可能更有效率。
如果你意猶未盡,覺得自己剛活動開筋骨,還想挑戰更高層次,歡迎進入“探險模式”。⟹請跳轉至【問題200】
否則,“休閒模式”到此結束。⟹請離開此問答
【問題200】探險模式 | 主要學什麼?
“探險模式”需要有挑戰精神。電腦科學的世界技術演進快,脈絡複雜,要想在探索時不迷路,你得通過有順序、有系統地學習電腦知識,慢慢構建出一張可以在未來幫你走得更遠的思維地圖來。
在“探險模式”裡,電腦就不止是一件能快速計算的工具了。電腦更像是我們大腦的一種延伸。這既包括認知能力的延伸,也包括認知邏輯的延伸。隨著學習深入,大家會逐漸體會到電腦所具有的多維度能力:
電腦是一種可以表示不同類型資訊(數、符號、文字、語音、圖像、視頻、虛擬空間、抽象邏輯)的“資訊管理機”;
同時,電腦也是一種可以連續執行指令以完成特定的資訊處理任務的“指令處理機”;
同時,電腦還是一種可以在知識與邏輯層面完成特定推理任務的“知識推理機”;
同時,電腦也是一種可以從人類給定的資料或自我生成的資料中總結規律,建立模型,自主完成某些決策的“智慧學習機”。
“探險模式”的目標就是盡可能準確地認識電腦,掌握有關電腦運行的最基本規律。有了這些基礎。未來在大學期間或工作中,你就能更容易地設計電腦軟硬體系統,或是設計出碳基大腦(人類)與矽基大腦(機器智慧)之間的最佳協作方案。
【問題201】探險模式 | 我的英語水準足夠嗎?
蘋果每年秋季的新品發佈會,不加字幕的話,你能聽懂多少?
能聽懂大部分:建議在學習電腦的過程中,盡可能使用英文教材、英文文檔。
能聽懂小部分:建議將原來準備學電腦的時間,分出一部分來學英語。
只能聽懂“你好”“再見”之類:⟹請離開此問答。然後,把原來準備學電腦的時間用於學英語,六個月後再回來。
【問題202】探險模式 | 我的數學水準足夠嗎?
如果你是數學和數學應用小能手——較複雜的數學問題總能快速找到核心思路,或快速簡化為簡單問題;很容易就能將抽象概念映射到具體的數學圖形,或將數學問題與相應的現實問題關聯在一起:請繼續探險之旅。
如果你應付正常數學課程感到吃力:建議將原來準備學電腦的時間,分出一部分來學數學。
如果你還搞不清楚什麼是方程、函數、集合、概率……:⟹請離開此問答。然後,把原來準備學電腦的時間用於學數學,六個月後再回來。
【問題203】探險模式 | 為什麼強調英語和數學?
(1)統計上說,最好的電腦參考資料大都是英文寫的,最好的電腦課程大都是用英文講的,最新的電腦論文大都是用英文發表的。
(2)函數、方程、坐標系、標量、向量、排列組合、概率這些中學數學裡會初步學習到的數學知識,是電腦科學的基礎。
【問題204】探險模式 | 電腦知識那麼多,正確的學習順序是什麼?
最重要的順序有兩個。建議先從順序一開始,學有餘力時兼顧兩個順序。
順序一:自底向上,即,自底層原理向上層應用拓展的順序。
電腦原理的基礎知識:
為什麼每台電腦(包括手機)都有CPU、記憶體和外部設備?
(馮·諾依曼體系結構的)記憶體中為什麼既可以存儲資料,也可以存儲指令?
CPU是如何完成一次加法運算的?
程式設計語言的基礎知識:
資料類型,值,變數,作用域……
語句,流程控制語句……
過程、方法或函數,類,模組,程式,服務……
編譯系統的基本概念:
電腦程式是如何被解釋或編譯成目標代碼的?
演算法和資料結構的基礎知識:
陣列,向量,鏈表,堆,棧,二叉樹,樹和圖……
遞迴演算法,排序演算法,二叉樹搜索演算法,圖搜索演算法……
應用層的基礎知識:
為什麼電腦需要作業系統?設備驅動程式是做什麼的?
網路通信的基本原理是什麼?流覽器是怎麼找到並顯示一個網頁的?
資料庫是做什麼用的?
虛擬機器是怎麼回事?
人工智慧系統的基礎知識:
先熟悉些線性代數、概率和數學優化的基礎知識。
什麼是機器學習?從簡單的線性回歸中體會機器學習的基本概念、基本思路。
什麼是神經網路?什麼是深度神經網路?為什麼神經網路可以完成機器學習任務?
如何使用PyTorch或TensorFlow實現簡單的深度學習功能?
順序二:自頂向下,即,自頂層抽象邏輯向下層具體邏輯拓展的順序。
• 電腦的本質是什麼?
• 什麼是圖靈機?什麼是通用圖靈機?
• 什麼是讀取﹣求值﹣輸出迴圈(Read–eval–print Loop,REPL)?
如何用自頂向下的方式理解(解析、解釋、編譯)一段程式碼?
• 靜態語言和動態語言的區別?
如何理解變數與資料類型之間的綁定關係?
• 什麼是函數式程式設計?
程式設計語言中,函數的本質是什麼?
函數為什麼可以像一個值一樣被表示、存儲、傳遞和處理?
• 什麼是物件導向?
類的本質是什麼?
如何用物件導向的方式定義個功能介面?
如何依據介面實現具體功能?
• 什麼是事件驅動?
什麼是事件?事件如何分發到接收者?
如何在事件驅動的環境中理解代碼的狀態和執行順序?
【問題205】探險模式 | 如何提高程式設計水準?
在掌握基本知識體系的基礎上,學好程式設計只有一條路:多程式設計,多參加程式設計比賽,多做程式設計題,多做實驗項目,多找實習機會——其中,能參與真實專案是最有價值的。
【問題206】探險模式 | 該從哪一門程式設計語言學起?
我個人推薦的程式設計入門語言(可根據情況任選):
Python
Java
Swift
C#
JavaScript / TypeScript
Ruby
……
可能不適合入門,但適合後續深入學習的語言:
C
C++
Go
Objective-C
組合語言
機器語言(CPU指令集)
Shell Script
Lua
Haskell
OCaml
R
Julia
Erlang
MATLAB
……
【問題207】探險模式 | 如何選參考書和參考資料?
(1)強烈推薦的參考書和參考資料:
• MIT、Stanford、CMU、UC Berkeley這四所大學中任何一個電腦專業方向使用的教學參考書或參考資料。網上可以查到這些學校電腦專業方向的課程體系,有的學校甚至公開了課程視頻。其中往往會列舉參考書和參考資料連結。
• 維琪百科(英文)上的數學、電腦科學相關條目。
• Github上star數在1000以上的開原始程式碼和開來源文件。
(2)強烈推薦但須小心辨別的參考資料:
知乎上的數學、電腦科學相關條目。使用時需要格外注意三件事:
儘量只看高贊答案或高贊文章;
辨別並避開廣告軟文;
辨別並避開純抖機靈的故事或段子。
Stack Overflow上的程式設計問題解答:
自己動手實驗,辨別解答是否有效。
CSDN上的程式設計問題解答:
自己動手實驗,辨別解答是否有效。
(3)其他推薦的參考書和參考資料:
國內專業作者寫作的專業技術書籍(豆瓣評分7分以上的)。
大廠(Google、Facebook、Microsoft、Amazon、阿裡、騰訊、百度、頭條等)資深工程師的技術公號、專欄、博客等。
著名圖書系列:如O’Reilly的動物封面的系列圖書(請注意最新版本和時效性)。
國內翻譯的著名技術圖書(譯本在豆瓣評分7分以上的)。
(4)儘量避免的參考書和參考資料:
• 已經過時的圖書或參考資料。
• 作者或譯者人數比章節數還多的專業圖書。
• 百度百科上的數學或電腦科學相關資料。
什麼什麼?你這篇問答居然沒有推薦一本具體的圖書?是,沒錯。如果你覺得即便有了上面的線索,自己還是找不到好書好資料,那也許你還是適合“休閒模式”⟹請跳轉至【問題100】
同時也有9部Youtube影片,追蹤數超過40萬的網紅糖餃子Sweet Dumpling,也在其Youtube影片中提到,Hi, everyone :) Today we'll going to show you how to make Classic French Orange-Scented Madeleines (Madeleines à l'orange) ! The madeleine is a tradit...
「c shell教學」的推薦目錄:
- 關於c shell教學 在 李開復 Kai-Fu Lee Facebook 的最佳貼文
- 關於c shell教學 在 Taipei Ethereum Meetup Facebook 的最佳貼文
- 關於c shell教學 在 糖餃子Sweet Dumpling Youtube 的最佳貼文
- 關於c shell教學 在 與芬尼學英語 Finnie's Language Arts Youtube 的精選貼文
- 關於c shell教學 在 TiA的D.I.Y教室 Youtube 的最佳解答
- 關於c shell教學 在 [問題] C shell scripting - 看板Linux - 批踢踢實業坊 的評價
- 關於c shell教學 在 Shell Script 新手入門教學 的評價
c shell教學 在 Taipei Ethereum Meetup Facebook 的最佳貼文
📜 [專欄新文章] Reason Why You Should Use EIP1167 Proxy Contract. (With Tutorial)
✍️ Ping Chen
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
EIP1167 minimal proxy contract is a standardized, gas-efficient way to deploy a bunch of contract clones from a factory.
1. Who may consider using EIP1167
For some DApp that are creating clones of a contract for its users, a “factory pattern” is usually introduced. Users simply interact with the factory to get a copy. For example, Gnosis Multisig Wallet has a factory. So, instead of copy-and-paste the source code to Remix, compile, key in some parameters, and deploy it by yourself, you can just ask the factory to create a wallet for you since the contract code has already been on-chain.
The problem is: we need standalone contract instances for each user, but then we’ll have many copies of the same bytecode on the blockchain, which seems redundant. Take multisig wallet as an example, different multisig wallet instances have separate addresses to receive assets and store the wallet’s owners’ addresses, but they can share the same program logic by referring to the same library. We call them ‘proxy contracts’.
One of the most famous proxy contract users is Uniswap. It also has a factory pattern to create exchanges for each ERC20 tokens. Different from Gnosis Multisig, Uniswap only has one exchange instance that contains full bytecode as the program logic, and the remainders are all proxies. So, when you go to Etherscan to check out the code, you’ll see a short bytecode, which is unlikely an implementation of an exchange.
0x3660006000376110006000366000732157a7894439191e520825fe9399ab8655e0f7085af41558576110006000f3
What it does is blindly relay every incoming transaction to the reference contract 0x2157a7894439191e520825fe9399ab8655e0f708by delegatecall.
Every proxy is a 100% replica of that contract but serving for different tokens.
The length of the creation code of Uniswap exchange implementation is 12468 bytes. A proxy contract, however, has only 46 bytes, which is much more gas efficient. So, if your DApp is in a scenario of creating copies of a contract, no matter for each user, each token, or what else, you may consider using proxy contracts to save gas.
2. Why use EIP1167
According to the proposal, EIP is a “minimal proxy contract”. It is currently the known shortest(in bytecode) and lowest gas consumption overhead implementation of proxy contract. Though most ERCs are protocols or interfaces, EIP1167 is the “best practice” of a proxy contract. It uses some EVM black magic to optimize performance.
EIP1167 not only minimizes length, but it is also literally a “minimal” proxy that does nothing but proxying. It minimizes trust. Unlike other upgradable proxy contracts that rely on the honesty of their administrator (who can change the implementation), address in EIP1167 is hardcoded in bytecode and remain unchangeable.
That brings convenience to the community.
Etherscan automatically displays code for EIP1167 proxies.
When you see an EIP1167 proxy, you can definitely regard it as the contract that it points to. For instance, if Etherscan finds a contract meets the format of EIP1167, and the reference implementation’s code has been published, it will automatically use that code for the proxy contract. Unfortunately, non-standard EIP1167 proxies like Uniswap will not benefit from this kind of network effect.
3. How to upgrade a contract to EIP1167 compatible
*Please read all the steps before use, otherwise there might have problems.
A. Build a clone factory
For Vyper, there’s a function create_with_code_of(address)that creates a proxy and returns its address. For Solidity, you may find a reference implementation here.
function createClone(address target) internal returns (address result){ bytes20 targetBytes = bytes20(target); assembly { let clone := mload(0x40) mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(clone, 0x14), targetBytes) mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) result := create(0, clone, 0x37) }}
You can either deploy the implementation contract first or deploy it with the factory’s constructor. I’ll suggest the former, so you can optimize it with higher runs.
contract WalletFactory is CloneFactory { address Template = "0xc0ffee"; function createWallet() external returns (address newWallet) { newWallet = createClone(Template); }}
B. Replace constructor with initializer
When it comes to a contract, there are two kinds of code: creation code and runtime code. Runtime code is the actual business logic stored in the contract’s code slot. Creation code, on the other hand, is runtime code plus an initialization process. When you compile a solidity source code, the output bytecode you get is creation code. And the permanent bytecode you can find on the blockchain is runtime code.
For EIP1167 proxies, we say it ‘clones’ a contract. It actually clones a contract’s runtime code. But if the contract that it is cloning has a constructor, the clone is not 100% precise. So, we need to slightly modify our implementation contract. Replace the constructor with an ‘initializer’, which is part of the permanent code but can only be called once.
// constructorconstructor(address _owner) external { owner = _owner;}// initializerfunction set(address _owner) external { require(owner == address(0)); owner = _owner;}
Mind that initializer is not a constructor, so theoretically it can be called multiple times. You need to maintain the edge case by yourself. Take the code above as an example, when the contract is initialized, the owner must never be set to 0, or anyone can modify it.
C. Don’t assign value outside a function
As mentioned, a creation code contains runtime code and initialization process. A so-called “initialization process” is not only a constructor but also all the variable assignments outside a function. If an EIP1167 proxy points to a contract that assigns value outside a function, it will again have different behavior. We need to remove them.
There are two approaches to solve this problem. The first one is to turn all the variables that need to be assigned to constant. By doing so, they are no longer a variable written in the contract’s storage, but a constant value that hardcoded everywhere it is used.
bytes32 public constant symbol = "4441490000000000000000000000000000000000000000000000000000000000";uint256 public constant decimals = 18;
Second, if you really want to assign a non-constant variable while initializing, then just add it to the initializer.
mapping(address => bool) public isOwner;uint public dailyWithdrawLimit;uint public signaturesRequired;
function set(address[] _owner, uint limit, uint required) external { require(dailyWithdrawLimit == 0 && signaturesRequired == 0); dailyWithdrawLimit = limit; signaturesRequired = required; //DO SOMETHING ELSE}
Our ultimate goal is to eliminate the difference between runtime code and creation code, so EIP1167 proxy can 100% imitate its implementation.
D. Put them all together
A proxy contract pattern splits the deployment process into two. But the factory can combine two steps into one, so users won’t feel different.
contract multisigWallet { //wallet interfaces function set(address[] owners, uint required, uint limit) external;}contract walletFactory is cloneFactory { address constant template = "0xdeadbeef"; function create(address[] owners, uint required, uint limit) external returns (address) { address wallet = createClone(template); multisigWallet(wallet).set(owners, required, limit); return wallet; }}
Since both the factory and the clone/proxy has exactly the same interface, no modification is required for all the existing DApp, webpage, and tools, just enjoy the benefit of proxy contracts!
4. Drawbacks
Though proxy contract can lower the storage fee of deploying multiple clones, it will slightly increase the gas cost of each operation in the future due to the usage of delegatecall. So, if the contract is not so long(in bytes), and you expect it’ll be called millions of times, it’ll eventually be more efficient to not use EIP1167 proxies.
In addition, proxy pattern also introduces a different attack vector to the system. For EIP1167 proxies, trust is minimized since the address they point to is hardcoded in bytecode. But, if the reference contract is not permanent, some problems may happen.
You might ever hear of parity multisig wallet hack. There are multiple proxies(not EIP1167) that refer to the same implementation. However, the wallet has a self-destruct function, which empties both the storage and the code of a contract. Unfortunately, there was a bug in Parity wallet’s access control and someone accidentally gained the ownership of the original implementation. That did not directly steal assets from other parity wallets, but then the hacker deleted the original implementation, making all the remaining wallets a shell without functionality, and lock assets in it forever.
https://cointelegraph.com/news/parity-multisig-wallet-hacked-or-how-come
Conclusion
In brief, the proxy factory pattern helps you to deploy a bunch of contract clones with a considerably lower gas cost. EIP1167 defines a bytecode format standard for minimal proxy and it is supported by Etherscan.
To upgrade a contract to EIP1167 compatible, you have to remove both constructor and variable assignment outside a function. So that runtime code will contain all business logic that proxies may need.
Here’s a use case of EIP1167 proxy contract: create adapters for ERC1155 tokens to support ERC20 interface.
pelith/erc-1155-adapter
References
https://eips.ethereum.org/EIPS/eip-1167
https://blog.openzeppelin.com/on-the-parity-wallet-multisig-hack-405a8c12e8f7/
Donation:
pingchen.eth
0xc1F9BB72216E5ecDc97e248F65E14df1fE46600a
Reason Why You Should Use EIP1167 Proxy Contract. (With Tutorial) was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
c shell教學 在 糖餃子Sweet Dumpling Youtube 的最佳貼文
Hi, everyone :) Today we'll going to show you how to make Classic French Orange-Scented Madeleines (Madeleines à l'orange) !
The madeleine is a traditional french cake(or cookies?) from Lorraine region of the northeastern France. They taste dense and moist inside, and crispy on the outside. It’s a perfect accompaniment to your afternoon cup of tea. To make madeleines, you require a madeleine pan to get that famous shell shape. But trust me, it’s very easy to make. Hope you enjoy this video.
This is an #ASMR version, you can check out the other version that with BGM and Voices in Chinese if you like:
https://youtu.be/6jMVL4-JJWM
-----------------------------------------------------------------------
Madeleines à l'orange recipes / Classic Orange-Scented Madeleines
❋ MAKES 6-7 madeleines
Ingredients
* unsalted butter 55g
* sugar 45g
* cake flour 60g
* egg at room temp, 1 (about 50g)
* aluminum free baking powder 2.5g
* orange 1
☞ For the Syrup
* water 40g
* sugar 30g
* orange juice 10g
-----------------------------------------------------------------------
Instructions
1. Butter pan lightly and dusk flour to coat. Place the pans in the freezer.
2. In a medium bowl, put the sugar and then grate the zest of orange . Stir together with your fingers until it’s well mixed. Set aside.
3. In a medium bowl, whisk the egg with the orange sugar until well-combined, the egg mixture will be thick and pale in color.
4. Sift the flour and baking powder, and gently fold into egg mixture.
5. Place the batter in the freezer for 1 hour.
6. In a small saucepan, melt the butter and then keep it warm(about 60°c).
7. Pour warm butter to the cold batter. Gently fold into batter until fully incorporate.
8. Remove the madeleine pans from the freezer. Fill 70~80% full with the batter. Repeat the process and fill in the same way.
9. Preheat the oven to 230°C and bake for 6 min, then reduce to 150°C and bake for 10-12 min
10. Meanwhile, heat water and sugar in a pot over medium heat. Simmer until thickened. Remove from heat and add 10g orange juice and stir well. Allow to cool.
11. Gently unmold madeleines onto a wire rack to cool. Shell-side down.
12. Gradually brush the syrup over the cake. Allow to cool completely. And Enjoy :-)
#madeleines
#OrangeCake
#easydessert
c shell教學 在 與芬尼學英語 Finnie's Language Arts Youtube 的精選貼文
各位,後製在之前影片 3:25 打錯了effect,含蓄不是subtlely 而是subtlety;是名詞 (n.) 不是副詞 (adv.)。這個錯誤也頗為嚴重,所以我們把舊的那個video unlist了,換上這個更正版本。謝謝各位體諒。
舊影片:https://youtu.be/0KNoEazckq0
例句一:
Oyster was conceived because of the metaphorical implications of security and value in the hard bivalve shell and the concealed pearl.
詞彙:
metaphorical (adj.) 比喻意義上的
implication (n.) 含意
bivalve (n.) 雙殼貝類
pearl (n.) 珍珠
例句二:
Its associations with London through Thames estuary oyster beds and the major relevance of the popular idiom "the world is your oyster" were also significant factors in its selection".
詞彙:
association (n.) 聯繫
estuary (n.) 河口
relevance (n.) 相關性
idiom (n.) 習語
significant (adj.) 重要的
▍成人英語再起步
● 課程資料 & 報名表格 ► http://bit.ly/成人英語再起步
● 成人英語再起步、One-day course、說話/寫作實戰班
時間表 ► http://bit.ly/fla-adult-infosheet
▍中、小學常規班
課程資料、時間表 ► http://bit.ly/fla-courses
訂閱與芬尼學英語 ► http://bit.ly/flayt-sub
喜歡我們的短片嗎?到 Patreon 支持我們! ► http://bit.ly/fla-patreon
▍播放清單:
今天只學一個字 ► http://bit.ly/2DRQPgE
Word Pairs 怎樣分 ► http://bit.ly/2hS1MCF
時事英語 ► http://bit.ly/2RqrMok
名人英語 ► http://bit.ly/2EUc8QO
品牌名學英語 ► http://bit.ly/2qd3mUq
朗誦節特訓 ► http://bit.ly/2PBqZno
▍更多學習資源:
● 加入 Finnie's Facebook 群組:bit.ly/flafbgp
● 訂閱電子報:http://bit.ly/fla-nl
● 下載免費學習資源:http://bit.ly/36VhrYS
▍Follow 芬尼:
● 博客: http://bit.ly/fla-blog
● Facebook: http://bit.ly/fla-facebook
● Instagram: http://bit.ly/fla-instagram
● Pinterest: http://bit.ly/fla-pinterest
Free stuff!!! :)
● Use my iHerb Discount Code: ASC7218
● Sign up at AirBnb and get HKD$290 in travel credit: https://www.airbnb.com/c/tiffanys213
● Get a FREE first Uber ride (up to HK$50): https://www.uber.com/invite/tiffanys2213ue
● Get TWO months of free SkillShare premium with this link:
https://skl.sh/2IIHhr8
c shell教學 在 TiA的D.I.Y教室 Youtube 的最佳解答
緹最近要去澎湖~
悠揚的大海~
蔚藍的天空~
在沙灘上踩著沙灘
這樣最需要強眼的耳環~
瘋玩也不擔心耳環落~
這次的耳勾很特別喔~
大家一起來做吧~~
▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽
◆使用材料細項◇
貝殼石片0.5mm圓 - 白
扣合式耳勾 - 金
5mm鐵環 - 金
4mm鐵環 - 金
鐵環3.5cm -金
10mm油珠 - 白
花托 - 金
尖嘴鉗
圓嘴鉗
▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽
TiA頻道訂閱::https://www.youtube.com/user/ancelita216
TiA粉絲專業::https://www.facebook.com/tialovediy
TiA合作邀約::ancelita216@yahoo.com.tw
▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽
◆長期招募字幕小幫手◇
本頻道字幕
http://www.youtube.com/timedtext_cs_panel?tab=2&c=UCLOxUJXk1Rxf63xT4N-o_UQ
本影片字幕
http://www.youtube.com/timedtext_video?v=yqeW9pTcLz0&ref=share
▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽
◆使用音樂◇
youtube音樂庫 無版權配樂
歌名: About That Oldie 作者: Vibe Tracks
▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽
c shell教學 在 Shell Script 新手入門教學 的推薦與評價
基礎四則運算,變數相加、相減、相乘、相除if 條件判斷for 迴圈while 迴圈function 函式檔案處理讀檔,讀取txt 文字檔其他sleep 延遲執行Shell Script ... ... <看更多>
c shell教學 在 [問題] C shell scripting - 看板Linux - 批踢踢實業坊 的推薦與評價
好不容易經歷了一年多 Linux的洗禮
慢慢熟悉 Bash csh
這一年內 也靠 鳥哥 的網頁 還有 網路農夫 跟其他網頁的教學
自己片斷摸索了 一些比較短的 bash csh scripts
終於要修改比較大的 csh scripts
鳥哥的網頁 還是偏重於 bash
我想找一個比較有系統的書籍 來閱讀
當然說寫這些東西都看天份,但我想有沒有可以加速我學習的方法
因為研究的關係需要使用的數值分析模式都是架構在大量 csh scripts 上
我自己以前是慣用fortran,這些東西感覺上差不多
但是有時候為了幾行東西 花了好幾天
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 107.15.112.169
※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1430510831.A.FD9.html
... <看更多>