📜 [專欄新文章] 區塊鏈管線化的效能增進與瓶頸
✍️ Ping Chen
📥 歡迎投稿: https://medium.com/taipei-ethereum-meetup #徵技術分享文 #使用心得 #教學文 #medium
使用管線化(Pipeline)技術可以提升區塊鏈的處理效能,但也可能會產生相應的代價。
Photo by tian kuan on Unsplash
區塊鏈的擴容方案
說到區塊鏈的效能問題,目前討論度最高的應該是分片(sharding)技術,藉由將驗證者分成多組的方式,可以同時分別處理鏈上的交易需求,即使單分片效能不變,總交易量可以隨著分片/驗證者集的數量線性增加。
除了分片,另一個常用來提升程式效能的方案是將計算步驟拆解,以流水線的方式將複雜的運算攤平,降低系統的閒置時間,並大幅提升工作效率。為了達到管線化預期的目的,會需要先知道系統的瓶頸在哪。
區塊鏈的效能瓶頸
熟悉工作量證明設計哲學的人應該會知道,區塊鏈之所以需要挖礦,並不是為了驗證交易的正確性,而是要決定交易的先後順序,從而避免雙花和帳本分裂的發生。可以說,區塊鏈使用低效率的單線程設計,並付給礦工高額的成本,都只為了一件事,就是對交易的全局排序產生共識。
在這樣的基礎之上,區塊鏈在一段時間內可以處理的交易數量是有限的,這之中包含許多方面的限制,包括 CPU 效能、硬碟空間、網路速度等。其中,關於 TPS(每秒交易數) 提升和對硬體的要求大致上是線性增加的,但在設計共識演算法時,通訊複雜度常是平方甚至三次方的關係。
以現在的目標 TPS 來說,處理交易和生成一個合法的區塊並不困難,只是因為區塊鏈的特性,新區塊需要透過洪水法的方式擴散到全網路,每個節點在收到更新請求的時候都要先執行/驗證過區塊內的交易,等於整個廣播的延時會是「驗證區塊時間×經過的 hop 數量」這麼多。似乎網路越分散、節點越多,我們反而會需要降低計算量,以免讓共識不穩定。
管線化的共識機制
使用權益證明取代工作量證明算是行業發展的趨勢,除了環保或安全這些比較顯然的好處之外,權益證明對產生共識的穩定性也很有幫助。首先,權益證明在同一時間參與共識的節點數是已知的,比較容易控制數量級的邊界;其次,權益證明的出塊時間相較工作量證明固定很多,可以降低計算資源不足或閒置的機率。
相較於工作量證明是單一節點出塊,其餘節點驗證,權益證明的出塊本身就需要很多節點共同參與,瓶頸很像是從驗證轉移到通訊上。
以 PBFT 為例,每次產新區塊都需要經過 pre-prepare, prepare, commit 三個階段,你要對同意驗證的區塊簽名,還要對「你有收到某人的簽名」這件事簽名,再對「你有收到 A 說他有收到 B 的簽名」這件事簽名,過程中會有很多簽名飛來飛去,最後才能把一個區塊敲定。
為了降低每兩個區塊間都需要三輪簽名造成的延遲,後來的共識演算法包括 HotStuff 和 Casper FFG 採用了管線化的區塊驗證過程。也就是對區塊 T 的 pre-prepare 同時是對 T-1 的 prepare 和對 T-2 的 commit。再加上簽名聚合技術,出塊的開銷在複雜度等級和係數等級都降低許多。
然而,要保持管線化的區塊生產順利,需要驗證者集合固定不變,且網路通訊狀況良好。如果會經常更動驗證者集合或變換出塊的領導者,前後區塊間的相依性會是個大問題,也就是 T 的驗證者集合取決於 T-1 裡有沒有會導致刪除或新增驗證者的交易,T-1 的合法性又相依於 T-2,以此類推。
當激烈的分叉出現的時候,出塊跟共識的流水線式耦合就從優雅變成災難了。為了避免這種災難,更新的共識演算法會限制驗證者變更的時機,有些叫 epoch 有些叫 checkpoint,每隔一段時間會把前面的區塊徹底敲定,才統一讓驗證者加入或退出。到這些檢查點的時候,出塊的作業流程就會退化成原本的三階段驗證,但在大部分時候還是有加速的效果。
管線化的狀態更新
另一個可以用管線化加速的是區塊鏈的狀態更新。如前所述,現在公鏈的瓶頸在於提高 TPS 會讓區塊廣播變慢,進而導致共識不穩定,這點在區塊時間短的以太坊上尤其明顯。可是如果單看執行一個區塊內的交易所花的時間的話,實際上是遠遠低於區塊間隔的。
只有在收到新區塊的時候,節點才會執行狀態轉移函數,並根據執行結果是否合法來決定要不要把區塊資訊再廣播出去。不過其實只要給定了交易集合,新的狀態 s’ = STF(s, tx) 應該是確定性的。
於是我們有了一個大膽的想法:何不乾脆將交易執行結果移出共識外呢?反正只要大家有對這個區塊要打包哪些交易有共識,計算的結果完全可以當作業留給大家自己算吧。如果真的不放心,我們也可以晚點再一起對個答案,也就是把這個區塊執行後的新狀態根包在下個區塊頭裡面。
這就是對狀態更新的管線化,在區塊 T 中敲定交易順序但暫不執行,區塊 T+1 的時候才更新狀態(以及下一批交易)。這麼做的好處十分顯而易見,就是將原本最緊繃的狀態計算時間攤平了,從原本毫秒必爭的廣播期移出來,變成只要在下個塊出來之前算完就好,有好幾秒的時間可以慢慢來。新區塊在廣播的每個 hop 之間只要驗證交易格式合法(簽名正確,有足夠的錢付手續費)就可以放行了,甚至有些更激進的方案連驗簽名都省略了,如果真的有不合法交易混進去就在下個區塊處罰礦工/提案者便是。
把負擔最重的交易執行移出共識,光用想的就覺得效能要飛天,那代價呢?代價是區塊的使用程度會變得不穩定。因為我們省略了執行,所以對於一筆交易實際用掉多少 gas 是未知的。本來礦工會完整的執行所有交易,並盡可能的塞滿區塊空間,然而在沒有執行的情況下,只能以使用者設定的 gas limit 當作它的用量,能打包的交易會比實際的上限少。
緊接著,下一個問題是退費困難。如果我們仍然將沒用完的手續費退還給使用者,惡意的攻擊者可以透過發送 gas limit 超大,實際用量很小的交易,以接近零的成本「霸佔」區塊空間。所以像已故區塊鏈 DEXON 就直接取消 gas refund,杜絕濫用的可能。但顯然這在使用者體驗和區塊空間效率上都是次優的。
而最近推出的 smartBCH 嘗試擬了一套複雜的退款規則:交易執行後剩餘的 gas 如果小於 gas limit 的一半(代表不是故意的)就退款;如果剩餘量介於 50%-75% 可以退一半;超過 75% 推斷為惡意,不退款。乍看是個合理的方案,仔細一想會發現製造的問題似乎比解決的還多。無論如何,沒用掉的空間終究是浪費了,而根據殘氣比例決定是否退款也不會是個好政策,對於有條件判斷的程式,可能要實際執行才知道走哪條路,gas limit 一定是以高的情況去設定,萬一進到 gas 用量少的分支,反而會噴更多錢,怎麼想都不太合理。
安全考量,退費大概是沒希望了。不過呢,最近以太坊剛上線的 EIP1559 似乎給了一點方向,如果區塊的使用程度能以某種回授控制的方式調節,即使偶爾挖出比較空的區塊似乎也無傷大雅,也許能研究看怎麼把兩者融合吧。
管線化方案的發展性
考慮到以太坊已經堅定地選擇了分片的路線,比較激進的單鏈高 TPS 管線化改造方案應該不太有機會出線,不過管線化畢竟是種歷史悠久的軟體最佳化技巧,還是很有機會被使用在其他地方的,也許是 VDF 之於信標鏈,也許是 rollup 的狀態轉換證明,可以坐等開發者們表演。
倒是那些比較中心化的 EVM fork/sidechain,尤其是專門只 for DeFi 的鏈,管線化加速可以在不破壞交易原子性的前提下擴容,確實是有一些比分片優秀的地方可以說嘴,值得研究研究,但這就要看那些機房鏈們有沒有上進心,願不願意在分叉之餘也投資發展自己的新技術了。
給我錢
ping.eth
區塊鏈管線化的效能增進與瓶頸 was originally published in Taipei Ethereum Meetup on Medium, where people are continuing the conversation by highlighting and responding to this story.
👏 歡迎轉載分享鼓掌
同時也有3部Youtube影片,追蹤數超過361萬的網紅Dan Lok,也在其Youtube影片中提到,Knowing The 5 Easy To Fix Videography Mistakes Is Just One Way To Take Your YouTube Channel To The Next Level. If You Want To Know Dan’s Best-Kept You...
「pre commit」的推薦目錄:
- 關於pre commit 在 Taipei Ethereum Meetup Facebook 的最佳貼文
- 關於pre commit 在 Facebook 的最佳解答
- 關於pre commit 在 矽谷牛的耕田筆記 Facebook 的最讚貼文
- 關於pre commit 在 Dan Lok Youtube 的最佳貼文
- 關於pre commit 在 Fanny Trần Youtube 的精選貼文
- 關於pre commit 在 Ray Mak Youtube 的精選貼文
- 關於pre commit 在 pre-commit - GitHub 的評價
- 關於pre commit 在 pre-commit not able to discover any golang files in nested go ... 的評價
- 關於pre commit 在 Run detekt using a Git pre-commit hook 的評價
pre commit 在 Facebook 的最佳解答
#throwback to pre-pregnancy, pre-Layla, pre-covid, when life was completely different, commitment and mindset was completely different, this body and body shape of mine feels completely different.
This picture was taken in Sept 2019. It's not even been 2 years, but it really feels like a lifetime ago.
I've been hearing comments about how my IG account is no longer like before. It's true. It's no longer filled with branded goods, OOTDs, perfectly made up and dressed up Sheila. But i am no longer the same person i was before. My priority has changed. My life has changed. And most of all, i like that i am presenting myself in the most authentic and vulnerable way. I dare say, even the products i feature are products that i really use and endorse. I make it a point to understand the brand and i make sure i use the products for at least 2 weeks before i commit to a post. So i know that they really work before i sell it to my audience.
Anyway, talking about how my body feels completely different... I NEED TO GET BACK INTO MY FITNESS ROUTINE. I wanna put an end to my sags (that's happening everywhere). I need my muscles and pre-birth posture back! This breasfeeding posture is making me look like The Hunchback of Notre Dame!
Mommies, no more excuses! Do something today. Even if it's a 15mins walk or a simple stretch. Set a goal, and let's work towards it!
#sheilaloveherlife #dwtakesthebestphotosofme #sheilaonvacay (damn i miss this hashtag) #taiwan #ootd #streetphotography
#streetwear
pre commit 在 矽谷牛的耕田筆記 Facebook 的最讚貼文
今天這篇文章探討的是 Git 的 pre-commit hook 系統,透過這種 pre-commit 的系統,能夠幫助開發者與本地開發時,先行進行一些處理,避免什麼問題都要丟到遠方的 CI/CD pipeline 去檢查。畢竟程式碼更新,觸發 CI/CD 流程,等待結果告知,這部分有時候都要花上數分鐘,往往就是檢查到一個格式錯誤,譬如拼字錯誤,多一個空白,格式錯誤等。
如果今天可以將一些常用的檢查給複製一份到本地端去執行,這樣開發者可以更快地找出錯誤,同時也可以節省很多等待的時間,因此本篇文章就要針對 git pre-commit hook 來介紹。
本篇文章要介紹的並不是直接使用 git 的 pre-commit hook,而是要使用 python 的套件 git pre-commit hook,其龐大的生態系可以幫助使用者輕鬆的使用常見的 yaml 格式來管理 git 本身的 pre-commit hook。舉例來說,可以於專案底下放置一個有下列內容的檔案
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
透過 python 的 pre-commit hook 系統,會將其中描述的四個功能 (trailing-whitespace....check-added-large-files)實際的程式碼給轉換並且安裝到 .git/hooks/pre-commit 底下。
同時透過這種框架,開發者也可以自行開發屬於自己的 pre-commit hook並整合到該 yaml 檔案之中。整個使用的方式非常簡單
1. 透過 python 的方式安裝 git pre-commit
2. 準備一個名為 .pre-commit-config.yaml 的檔案,並且描述你希望使用的 hook
3. 透過 pre-commit install 的方式將該 yaml 的內容轉換為真正 git 所使用的內容
4. 可以開始透過 git commit 來幫助你進行本地檢查囉
如果對於提升本地開發效率有興趣的人,不要錯過研究看看 git pre-commit 這種機制,不論是直接撰寫 git 或是透過這種 python 的 git pre-commit 框架,只要能夠幫忙解決相關問題,提升效率就會是一個值得研究的方法。
更多的 hook 參考以及該框架介紹,請點選下列全文來觀賞囉
https://towardsdatascience.com/pre-commit-hooks-you-must-know-ff247f5feb7e
pre commit 在 Dan Lok Youtube 的最佳貼文
Knowing The 5 Easy To Fix Videography Mistakes Is Just One Way To Take Your YouTube Channel To The Next Level. If You Want To Know Dan’s Best-Kept YouTube Secrets And How To Monetize Your Efforts Easily, Click Here: http://fixvideomistakes.danlok.link
Are you a photographer or videographer working for yourself or someone else, and you want to take professional shots? In this video, Dan Lok’s director of video, Lindsay Hitchcock, will give you the 5 videography mistakes that you can instantly fix to upgrade your videography skill set and take better shots or make better videos.
? SUBSCRIBE TO DAN'S YOUTUBE CHANNEL NOW ?
https://www.youtube.com/danlok?sub_confirmation=1
Check out these Top Trending Playlists -
1.) Boss In The Bentley - https://www.youtube.com/playlist?list=PLEmTTOfet46OWsrbWGPnPW8mvDtjge_6-
2.) Sales Tips That Get People To Buy - https://www.youtube.com/watch?v=E6Csz_hvXzw&list=PLEmTTOfet46PvAsPpWByNgUWZ5dLJd_I4
3.) Dan Lok’s Best Secrets - https://www.youtube.com/watch?v=FZNmFJUuTRs&list=PLEmTTOfet46N3NIYsBQ9wku8UBNhtT9QQ
Dan Lok is a Chinese-Canadian business magnate and global educator known for being the founder and chairman of Closers.com - the world’s #1 virtual-closers network, Copywriters.com, and SalesCalls.com. Beyond his businesses, Mr. Lok has led several global movements to redefine modern education where he has taught individuals from 150+ countries to develop high income skills and financial confidence.
Beyond his success in business, he was also a two time TEDx opening speaker. An international best-selling author of 12+ books. A member of Young Presidents Organization (YPO) - a private group of global chief executives whose companies employ 22 million people and generate 9-trillion USD in annual revenues. He also hosts The Dan Lok Show - a series on elite business tycoons and world-leading entrepreneurs.
Today, Mr. Lok continues to be featured in thousands of media channels and publications every year and is widely seen as one of the top business leaders by millions around the world.
If you want the no b.s. way to master your financial destiny, then learn from Dan. Subscribe to his channel now.
★☆★ CONNECT WITH DAN ON SOCIAL MEDIA ★☆★
YouTube: http://youtube.danlok.link
Dan Lok Blog: http://blog.danlok.link
Facebook: http://facebook.danlok.link
Instagram: http://instagram.danlok.link
Linkedin: http://mylinkedin.danlok.link
Podcast: http://thedanlokshow.danlok.link
#DanLok #Videography #Video
Please understand that by watching Dan’s videos or enrolling in his programs does not mean you’ll get results close to what he’s been able to do (or do anything for that matter).
He’s been in business for over 20 years and his results are not typical.
Most people who watch his videos or enroll in his programs get the “how to” but never take action with the information. Dan is only sharing what has worked for him and his students.
Your results are dependent on many factors… including but not limited to your ability to work hard, commit yourself, and do whatever it takes.
Entering any business is going to involve a level of risk as well as massive commitment and action. If you're not willing to accept that, please DO NOT WATCH DAN’S VIDEOS OR SIGN UP FOR ONE OF HIS PROGRAMS.
This video is about 5 Easy To Fix Videography Mistakes
https://youtu.be/L_6D6l3CeJU
https://youtu.be/L_6D6l3CeJU

pre commit 在 Fanny Trần Youtube 的精選貼文
KILL THIS LOVE - BLACKPINK (Vietnamese cover) | FANNY K-POP COVER
♥ CÁM ƠN BẠN ĐÃ XEM HẾT VIDEO
ĐĂNG KÝ KÊNH ĐỂ ỦNG HỘ MÌNH LÀM CLIP HAY HƠN NHA♥
LYRICS:
KILL THIS LOVE
Verse 1:
Trong không gian mê say
Qua đêm nay đôi ta không còn
Buông nhau ra đôi ta chia xa
Em mong anh sẽ không quay về
Cho con tim em thôi không nhớ
Bao yêu thương bên nhau say đắm
Thôi hôm nay em quên đi hết
Tình yêu kia như cơn ác mộng
Rap:
Here i come kick in the door
Đâu cần ai biết có lý do
Mặc kệ mặc kệ đó là yêu
Nhạc lên thì em vẫn cứ phiêu
Dù cho là đúng hay là sai lỗi tại ai
Thì em vẫn cứ xin được nói lời bye bye
Tình yêu em dành cho anh đã kết thúc rồi vì từ nay em sẽ thành người cô đơn you might not get in it
Pre- chours:
Look at me , look at you
Xem hai ta bao lâu qua là gì
Tại sao như thế
Anh bên ai
Em bên ai
Đang nơi đâu
Em trong anh là gì
Tại sao không nói
Một lần nữa thôi, cho con tim em thôi không còn yếu mềm mỗi khi trông anh bên cạnh ai
Dù 1 lần đau nhưng em phải quên đi anh thôi
[Chorus:
Let's kill this love!
Yeah yeah, yeah yeah, yeah
Rum, pum, pum, pum, pum, pum, pum
Let's kill this love!
Rum, pum, pum, pum, pum, pum, pum
Verse2 :
Feelin' like a sinner
It's so fire with him I go boo, hoo
He said "you look crazy"
Thank you, baby
I owe it all to you
Got me all messed up
His love is my favorite
But you plus me
Sadly can be dangerous
Pre- chorus:
Lucky me , lucky you
Xem hai ta bao lâu qua là gì
So what so what
Anh bên ai
Em bên ai
Đang nơi đâu
Em trong anh là gì
Im not sorry
Một lần nữa thôi, cho con tim em thôi không còn yếu mềm mỗi khi trông anh bên cạnh ai
Dù 1 lần đau nhưng em phải quên đi anh thôi
[Chorus:
Let's kill this love!
Yeah yeah, yeah yeah, yeah
Rum, pum, pum, pum, pum, pum, pum
Let's kill this love!
Rum, pum, pum, pum, pum, pum, pum
Bridge:
We all commit to love
That makes you cry, oh oh
We're all making love
That kills you inside, yeah
[Outro: All]
We must kill this love (Yeah! Yeah!)
Yeah, it's sad but true
Gotta kill this love (Yeah! Yeah!)
Before it kills you too
Kill this love (Yeah! Yeah!)
Yeah, it's sad but true
Gotta kill this love (Yeah! Yeah!)
Gotta kill, let's kill this love!
---------
#KillThisLove #BlackPink #Fanny
NHỚ CLICK ĐĂNG KÍ ĐỂ XEM VIDEO MỚI NHẤT NHA
http://bit.ly/fannytran
---------
More information about Fanny
♫ Youtube: http://bit.ly/fannytran
♫ Fanpage: https://www.facebook.com/McFannyTran/
♫ Facebook: https://www.facebook.com/tran.yphung.18
↘ Creatory: http://creatory.vn
↘ Creatory page: http://facebook.com/CreatoryVN
↘ Hợp tác kinh doanh hoặc quảng cáo: partners@creatory.vn
---------
CREATORY PRODUCTION
Cameraman: Huy
Editor: Nguyễn Nghị
Colorist: Hải Lê
Mix & Master: Fanny Team
---------
© Bản quyền thuộc về Fanny Trần
© Copyright by Fanny Trần
☞ Please do not Reup
Kênh YouTube chính thức của Fanny

pre commit 在 Ray Mak Youtube 的精選貼文
?SHEET MUSIC & Mp3 ▸ http://www.makhonkit.com
?LEARN MY SONGS ▸ https://tinyurl.com/RayMak-flowkey
?Listen on Spotify ▸ https://sptfy.com/raymak
?Listen on Apple Music ▸ https://music.apple.com/sg/artist/ray-mak/1498802526
?Full Song List ▸ http://www.redefiningpiano.com
Talk to me :
? Instagram ▸ http://instagram.com/makhonkit
? Facebook ▸ http://facebook.com/raymakpiano
? Twitter ▸ http://twitter.com/makhonkit
Requested by Marcus Chow Piano :
https://www.youtube.com/channel/UCFCJAlpJVPqEujzgSND1j5g
Hope you guys like it as much as I did. If you Love it, please Subscribe otherwise you'll Kill This Love.
BLACKPINK - KILL THIS LOVE Piano by Ray Mak
[Intro: Jennie, Lisa]
Yeah, yeah, yeah
BLACKPINK IN YOUR AREA!
Yeah, yeah, yeah
[Verse 1: Jennie]
천사 같은 "hi" 끝엔 악마 같은 "bye"
매번 미칠듯한 high 뒤엔 뱉어야 하는 price
이건 답이 없는 test
매번 속더라도 yes
딱한 감정의 노예
얼어 죽을 사랑해
[Verse 2: Lisa]
Here I come kickin' the door, uh
가장 독한 걸로 줘, uh
뻔하디 뻔한 그 love
더 내놔봐 give me some more
알아서 매달려 벼랑 끝에
한마디면 또 like 헤벌레 해
그 따뜻한 떨림이 새빨간 설렘이
마치 heaven 같겠지만
You might not get in it
[Pre-Chorus: Jisoo & Rosé]
Look at me, look at you
누가 더 아플까
You smart 누가 you are
두 눈에 피눈물 흐르게 된다면
So sorry 누가 you are
나 어떡해 나약한 날 견딜 수 없어
애써 두 눈을 가린 채
사랑의 숨통을 끊어야겠어
[Chorus: All, Lisa, Jennie]
Let's kill this love!
Yeah, yeah yeah, yeah yeah yeah
Rum, pum, pum, pum, pum, pum, pum
Let's kill this love!
Rum, pum, pum, pum, pum, pum, pum
[Verse 3: Jennie, Lisa]
Feelin' like a sinner
It's so fire with him I go boo, hoo
He said "you look crazy"
Thank you, baby
I owe it all to you
Got me all messed up
His love is my favorite
But you plus me
Sadly can be dangerous
[Pre-Chorus: Rosé & Jisoo]
Lucky me, lucky you
결국엔 거짓말 we lie
So what? So what?
만약에 내가 널 지우게
된다면 so sorry
I'm not sorry
나 어떡해 나약한 날 견딜 수 없어
애써 눈물을 감춘 채, eh
사랑의 숨통을 끊어야겠어
[Chorus: All, Lisa, Jennie]
Let's kill this love!
Yeah, yeah yeah, yeah yeah yeah
Rum, pum, pum, pum, pum, pum, pum
Let's kill this love!
Rum, pum, pum, pum, pum, pum, pum
[Bridge: Rosé]
We all commit to love
That makes you cry, oh oh
We're all making love
That kills you inside, yeah
[Outro: All]
We must kill this love (Yeah! Yeah!)
Yeah, it's sad but true
Gotta kill this love (Yeah! Yeah!)
Before it kills you too
Kill this love (Yeah! Yeah!)
Yeah, it's sad but true
Gotta kill this love (Yeah! Yeah!)
Gotta kill, let's kill this love!
Featuring The Legendary CFX Grand Piano from Yamaha Music Malaysia
#blackpink #killthislove #yamahamusicmalaysia

pre commit 在 pre-commit not able to discover any golang files in nested go ... 的推薦與評價
... <看更多>
相關內容
pre commit 在 Run detekt using a Git pre-commit hook 的推薦與評價
The mentioned pre-commit hook can be setup locally on your dev-machine. The following client-side detekt hook is triggered by a commit operation. #!/usr/bin/env ... ... <看更多>
pre commit 在 pre-commit - GitHub 的推薦與評價
A framework for managing and maintaining multi-language pre-commit hooks. - GitHub - pre-commit/pre-commit: A framework for managing and maintaining ... ... <看更多>