SegWit
KODEBOX
목차
1. 블록 사이즈 논쟁의 역사
2. SegWit
3. SegWit의 영향
블록 사이즈 논쟁의 역사
블록 사이즈 제한: 1MB
사토시가 아무말 없이 2010년 7월에 블록의 1MB제한을 추가
의도를 밝히진 않았지만 DOS 공격을 막기 위해서였던 것으로 추측
Satoshi once told me, "I think most P2P networks, and websites for that matter, are vulnerable to an endless number of DoS attacks. The best we can realistically do is limit the worst cases."
첫 번째 제안 (2010년 10월 3일)
Jeff Garzik�Contributor to Bitcoin Core
We should be able to at least match Paypal's average transaction rate...
diff --git a/main.h b/main.h
index c5a0127..c92592a 100644
--- a/main.h
+++ b/main.h
@@ -14,7 +14,10 @@ class CBlockIndex;
class CWalletTx;
class CKeyItem;
-static const unsigned int MAX_BLOCK_SIZE = 1000000;
+static const unsigned int TX_PER_MINUTE = 1400;
+static const unsigned int TX_AVG_SIZE_GUESS = 256;
+static const unsigned int MAX_BLOCK_SIZE =
+ TX_PER_MINUTE * TX_AVG_SIZE_GUESS * 10 * 2;
Satoshi says
+1 theymos. Don't use this patch, it'll make you incompatible with the network, to your own detriment.
We can phase in a change later if we get closer to needing it.
Bitcoin Scalability
Bitcoin Scalability
Bitcoin Scalability
1월 7일 기준 수수료
일반적인 트랜잭션 사이즈(median) : 226 byte
2,000원의 수수료를 내면 최대 21시간의 딜레이
20,000원의 수수료를 내면 최대 1시간의 딜레이
소액결제가 불가능한 시스템
BIP-101 & Bitcoin xt
Gavin Andresen
Bitcoin lead developer (2010~2014)
프로토콜에 제한을 두지 말자
“There are limits on routing table sizes, but they are not top-down-specified-in-a-standards-document protocol limits. They are organic limits that arise from whatever hardware is available and from the (sometimes very contentious!) interaction of the engineers keeping the Internet backbone up and running.”
“Trust that smart developers will fix scaling or denial-of-service issues as they arise”
BIP 101
This BIP proposes replacing the fixed one megabyte maximum block size with a maximum size that grows over time at a predictable rate.
블록 사이즈 리밋을 즉시 8메가로 수정
2년마다 2배로 늘리기
2016년 1월 11일에 75% 이상의 해시파워가 동의하면 진행
블록 사이즈 투표
비트코인 커미터들
2015년 당시 커미터 5 명 중 권한이 큰 2명이 하드포크를 통한 블록사이즈 늘리기에 반대
Wladimir van der Laan
(2014/8~) Bitcoin Lead maintainer
I mostly have a problem with proposals that bake in expected exponential bandwidth growth. I don’t think it’s realistic. If we’ve learned anything from the 2008 subprime bubble crisis it should be that nothing ever keeps growing exponentially, and assuming so can be hazardous. It reduces a complex geographical issue, the distribution of internet connectivity over the planet for a long time to come, to a simple function.
Wladimir van der Laan
(2014/8~) Bitcoin Lead maintainer
On the other hand a hardfork is extremely hard to coordinate. Even one that just involves changing one parameter. Everyone with a full node has to upgrade. This is not something that can be done regularly. Certainly not with such a near time horizon. Changing the rules in a decentralized consensus system is a very difficult problem and I don’t think we’ll resolve it any time soon.
China Great Firewall
Pan zhibiao(bitmain)
“I personally think that the blocksize topic has conflicts with the Firewall of China,I think the current BIP 100 proposal would be good, but we need a better solution for the Great Firewall of China.”
Chinese Mining Pools
중국에 대한 우려
Toomim (Bitcoin classic member)
“Most of the rest of the world can handle large blocks,China, though, cannot. We need to get Chinese pools to take their block transactions outside of China.”
having 65% of the total hashrate based in the region was a “problem”.
“The purpose [of The Great Firewall] is to censor and control information, and that has some problems for bitcoin. It makes me uncomfortable to have so much hashing power subject to that system,” he said.
중국 마이너들의 불만
“We’re getting close to something everyone can agree on, that doesn’t put us in a voting power position, and something that doesn’t scale too quickly,” Long(FinalHash) said.
“Before 2014, over half of the hashing power was in the US. But there was no worry about US committing a 51% attack,” F2Pool’s Wang said.
Zhibiao said. “The core developers shouldn’t have all the discussions and debate and then ask us to vote.”
Hongkong Agreement
2016년 2월 Hongkong Agreement
2017년 5월 New York Agreement
SegWit
Bitcoin Cash
SegWit2x의 문제
Replay protection 논란
Bitcoin Core 의 반대
SegWit
Review
복습
SegWit
왜?
주 목적
Soft-fork
Serialization Format
txid,wtxid
Script 변화
P2PKH
Pay To Public Key Hash
scriptPubKey: OP_DUP OP_HASH160 <PubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <sig> <pubkey>
복습
P2WPKH
P2SH
Pay To Script Hash
scriptPubKey: OP_HASH160 <Hash160(redeem script)> OP_EQUAL
scriptSig: [sig...] <redeemScript>
복습
P2WSH
Soft-fork
새로운 블록 사이즈 계산법
새로운 블록 사이즈 계산법
새로운 블록 사이즈 계산법
이렇게 한 이유
Transaction Serialization of P2SH
블록 헤더
복습
Commitment Structure
Transaction Malleability
SegWit의 영향
Micropayment Channel
Alice가 Bob에게 잦은 빈도로 적은 양의 돈을 지불하고 싶어 함. 그러나 매 지불마다 트랜잭션을 발생시키면 지불할 양보다 수수료가 더 커지는 문제가 있음
Solution
결제 채널을 열고 닫는 2개의 트랜잭션만 블록체인에 올리고 그 사이에 Off-chain 트랜잭션을 무수히 수행할 수 있음
1 satoshi * 100
복습
Micropayment Channel
Alice가 Bob에게 채널을 열려고 함, 트랜잭션 2개를 생성만 하고 네트워크에 전파하지 않음
Tx 1 (Alice가 계약금을 예치)
Tx 2 (계약금을 Alice에게 환불)
Alice 지갑
Multisig
Multisig
Alice 지갑
scriptPubKey
2 <key A> <key B> 2 CHECKMULTISIG
복습
Micropayment Channel
일정 시간이 지나면 예치금이 환불될 수 있도록 Bob의 서명을 받음
Tx 1 (Alice가 계약금을 예치)
Tx 2 (계약금을 Alice에게 환불)
Alice 지갑
Multisig
Multisig
nSequence +12 시간
Alice 지갑
scriptSig: <sig A> <sig B>
서명 제공
복습
Micropayment Channel
Tx1이 네트워크에 전파되고 Bob은 이를 확인할 수 있음
Tx 1 (Alice가 계약금을 예치)
Tx 2 (계약금을 Alice에게 전액 환불)
Alice 지갑
Multisig
Multisig
Alice 지갑
네트워크에 전파
복습
Micropayment Channel
Tx1이 네트워크에 전파되고 Bob은 이를 확인할 수 있음
Tx 1 (Alice가 계약금을 예치)
Tx 2 (계약금을 Alice에게 전액 환불)
Alice 지갑
Multisig
Multisig
Alice 지갑
네트워크에 전파
네트워크에 전파 중
txid를 변조 가능
최악의 경우 환불 불가능
SegWit을 통하여 해결
Script Version Up
Pruning