Cross-Chain dApps for Developers
Cross-Chain dApps for Developers
ABSTRACT
arXiv:1908.09343v3 [cs.CR] 4 Sep 2019
blockchains. All entities are conceptually local to M, regardless 1 # Import the source code of contracts written in different languages.
of which blockchains they are obtained from. Entities come with 2 import (“broker.sol”, “option.vy”, “option.go”)
kinds, and each entity kind has different attributes. The current 3 # Entity definition.
version of USM defines two concrete kinds of entities, accounts 4 # Attributes of a contract entity are implicit from its source code.
and contracts, as tabulated in Table 1 (we discuss the extensions of 5 account a1 = ChainX ::Account(0x7019..., 100, xcoin)
USM in § 6.1). Specifically, an account entity is associated with a 6 account a2 = ChainY ::Account(0x47a1..., 0, ycoin)
uniquely identifiable address, as well as its balance in certain units. 7 account a3 = ChainZ ::Account(0x61a2..., 50, zcoin)
A contract entity, besides its address, is further associated with a 8 contract c1 = ChainX ::Broker(0xbba7...)
list of public attributes, such as state variables, callable interfaces, 9 contract c2 = ChainY ::Option(0x917f...)
and its source code deployed on blockchains. Entity attributes are 10 contract c3 = ChainZ ::Option(0xefed...)
crucial to enforce the security and correctness of dApps during 11 # Operation definition.
compilation, as discussed in § 2.3. 12 op op1 invocation c1.GetStrikePrice() using a1
An operation in USM defines a step of computation performed 13 op op2 payment 50 xcoin from a1 to a2 with 1 xcoin as 0.5 ycoin
over several entities. Table 1 lists two kinds of operations in USM: a 14 op op3 invocation c2.CashSettle(10, c1.StrikePrice) using a2
payment operation that describes the balance updates between two 15 op op4 invocation c3.CashSettle(5, c1.StrikePrice) using a3
account entities at a certain exchange rate; an invocation operation 16 # Dependency definition.
that describes the execution of a method specified by the interface 17 op1 before op2, op4; op3 after op2
of a contract entity using compatible parameters, whose values 18 op1 deadline 10 blocks; op2, op3 deadline default; op4 deadline 20 mins
may be obtained from other contract entities’ state variables.
Figure 2: A cross-chain Option dApp written in HSL.
Although operations are conceptually local, each operation is
eventually compiled into one or more transactions on different
blockchains, whose consensus processes are not synchronized. To turn, prevents dApps from spreading their business across multi-
honor the possible dependencies among events in distributed com- ple blockchains. For instance, a call-option contract deployed on
puting [47], USM, therefore, defines constraints to specify depen- Ethereum forces investors to exercise the option using Ether, but
dencies among operations. Currently, USM supports two kinds of not in other cryptocurrencies.
dependencies: preconditions and deadlines, where an operation can As an introductory example, we shall see how conceptually
proceed only if all its preconditioning operations are finished, and simple, yet elegant, it is, from developers’ perspective, to build a
an operation must be finished within a bounded time interval after universal call-option dApp that allows investors to natively exer-
its dependencies are satisfied. Preconditions and deadlines offer cise options with the cryptocurrencies they prefer. The code snip-
desirable programming abstraction for dApps: (i) preconditions en- pet shown in Figure 2 is the HSL implementation for the referred
able developers to organize their operations into a directed acyclic dApp. In this dApp, both Option contracts deployed on blockchains
graph, where the state of upstream nodes is persistent and can be ChainY and ChainZ rely on the same Broker contract on ChainX to
used by downstream nodes; (ii) deadlines are crucial to ensure the provide the genuine strike price (lines 14 and 15 in Figure 2). Detailed
forward progress of dApp executions. HSL grammar is given in Grammar 1.
cryptography protocol UIP, as detailed below. ActionRoot CommonRoots StatusRoot ActionRoot … StatusRoot
ProtNSB and ProtISC are the protocol realization of the NSB and Figure 5: The architecture of NSB blocks.
ISC, respectively. Lastly, ProtUIP includes ProtBC , the protocol real-
ization of a general-purposed blockchain. Overall, ProtUIP has two
phases: the execution phase where the transactions specified in the support the extra functionality of the NSB, an NSB block contains
HSL executables are posted on blockchains and the insurance claim two additional Merkle tree roots: StatusRoot and ActionRoot.
phase where the execution correctness or violation is arbitrated. StatusRoot is the root of a Merkle tree (referred as StatusMT)
that stores transaction status of underlying blockchains. The NSB
4.1 Protocol Preliminaries represents the transaction status of a blockchain based on the Tx-
4.1.1 Runtime Transaction State Roots and StateRoots retrieved from the blockchain’s public ledger.
Although the exact namings may vary on different blockchains,
During the execution phase, a transaction may be in any of the fol-
in general, the TxRoot and StateRoot in a blockchain block rep-
lowing state {unknown, init, inited, open, opened, closed}, where
resent the root of a Merkle tree storing transactions and storage
a latter state is considered more advanced than a former one. The
state (e.g., account balance, contract state), respectively. Note that
state of each transaction must be gradually promoted following the
the NSB only stores relevant blockchain state, where a blockchain
above sequence. For each state (except for the unknown), ProtUIP
block is considered to be relevant if the block packages at least one
produces a corresponding attestation to prove the state. When the
transaction that is part of any dApp executables.
execution phase terminates, the final execution status of the HSL
ActionRoot is the root of a Merkle tree (referred to as ActionMT)
program is collectively decided by the state of all transactions, based
whose leaf nodes store certificates computed by VESes and dApp
on which ProtISC arbitrates its correctness or violation.
clients. Each certificate represents a certain step taken by either
4.1.2 Off-Chain State Channels the VES or the dApp client during the execution phase. To prove
The protocol exchange between ProtVES and ProtCLI can be con- such an action, a party needs to construct a Merkle proof to demon-
ducted via off-chain state channels for low latency. One challenge, strate that the certificate mapped to the action can be linked to a
however, is that it is difficult to enforce accountability for non- committed block on the NSB. These PoAs are crucial for the ISC to
closed transactions without preserving the execution steps by both enforce accountability if the execution fails. Since the information
parties. To address this issue, ProtUIP proposes Proof of Actions of each ActionMT is static, we lexicographically sort the ActionMT
(PoAs), allowing ProtVES and ProtCLI to stake their execution steps to achieve fast search and convenient proof of non-membership.
on NSB. As a result, the NSB is treated as a publicly-observable Note that the construction of StatusMT ensures that each under-
fallback communication medium for the off-chain channel. The lying blockchain can have a dedicated subtree for storing its trans-
benefit of this dual-medium design is that the protocol exchange action status. This makes the NSB shardable on the granularity of
between ProtVES and ProtCLI can still proceed agilely via off-chain individual blockchains, ensuing that the NSB is horizontally scalable
channels in typical scenarios, whereas the full granularity of their as HyperService continuously incorporates additional blockchains.
protocol exchange is preserved on the NSB in case of exceptions, ProtNSB , discussed in § 4.5, is the protocol that specifies the detailed
eliminating the ambiguity for accountability enforcement. construction of both roots and guarantees their correctness.
As mentioned in § 4.1.1, ProtUIP produces security attestations
to prove the runtime state of transactions. As we shall see below, an 4.2 Execution Protocol by VESes
attestation may come in two forms: a certificate, denoted by Cert, The full protocol of ProtVES is detailed in Figure 6. Below we clarify
signed by ProtVES or/and ProtCLI during their off-chain exchange, some technical subtleties.
or an on-chain Merkle proof, denoted by Merk, constructed using 4.2.1 Post Compilation and Session Setup
the NSB and underlying blockchains. An Cert and its corresponding
Merk are treated equivalently by the ProtISC in code arbitration. After GT is generated, ProtVES initiates an execution session for
GT in the PostCompiliation daemon. The primary goal of the ini-
4.1.3 Architecture of the NSB tialization is to create and deploy an insurance contract to protect
The NSB is a blockchain designed to provide an objective view on the execution of GT . Towards this end, ProtVES interacts with the
the execution status of dApps. Figure 5 depicts the architecture protocol ProtISC to create the insurance contract for GT , and fur-
of NSB blocks. Similar to typical blockchain blocks, an NSB block ther deploys the contract on NSB after the dApp client D agrees
contains several common fields, such as the hash fields to link blocks on the contract. Throughout the paper, Cert([∗]; Sig) represents a
together and the Merkle trees to store transactions and state. To signed certificate proving that the signing party agrees on the value
1 Init: Data := ∅ 54 update S Cert .Add(Certid
T
) and T .state := inited
2 Daemon PostCompiliation(): 55 non-blocking wait until ProtNSB .MerkleProof(Certid ) returns Merkid
T T
3 generate the session ID sid ← {0, 1} λ 56 update S Merk .Add(Merkid )
T
4 call [cid, contract] := ProtISC .CreateContract(GT )
57 Upon Receive RInitedTrans(Certid T
) public: Southbound
5 send Cert([sid, GT , contract]; SigV ) to ProtCLI for approval
sid 58 assert Certid has the valid form of Cert([Te, inited, sid, T]; SigD )
6 halt until Cert([sid, GT , contract]; SigV , Sigsid
D ) is received T sid
sid 59 (_, _, S Cert, S Merk ) := Data[sid]; abort if not found
7 package contract as a valid transaction contract
60 i id
abort if the CertT corresponding to CertT is not in S Cert
8 call ProtNSB .Exec(contract)
to deploy the contract
61 assert Te is correctly associated with the wrapper T
9 halt until contract
is initialized on ProtNSB
62 get tsopen := ProtNSB .BlockHeight()
10 call ProtISC .StakeFund to stake the required funds in ProtISC
63 compute CertoT := Cert([Te, open, sid, T, tsopen ]; SigV
sid
)
11 halt until D has staked its required funds in ProtISC
64 call ProtCLI .OpenTrans(CertoT ) to request opening for T
12 initialize Data[sid] := { GT , cid, S Cert =∅, S Merk =∅ }
65 call ProtNSB .AddAction(CertoT ) to prove CertoT is sent
13 Daemon Watching(sid, {ProtBC , ...}) private:
66 update S Cert .Add(CertoT ) and T .state := open
14 (GT , _, S Cert, S Merk ) := Data[sid]; abort if not found
67 non-blocking wait until ProtNSB .MerkleProof(CertoT ) returns MerkoT
15 for each T ∈ GT :
68 update S Merk .Add(MerkoT )
16 continue if T .state is not opened
69 Upon Receive OpenTrans(CertTo ) public: Northbound
17 identify T’s on-chain counterpart Te
18 continue if ProtBC .Status(Te) is not committed 70 assert Certo has valid form of Cert([Te, open, sid, T, tsopen ]; SigD )
T sid
19 get tsclosed := ProtNSB .BlockHeight() 71 (_, _, S Cert, S Merk ) := Data[sid]; abort if not found
20 T
compute C closed := Cert([Te, closed, sid, T, tsclosed ], SigV ) 72 abort if the CertTid corresponding to CertTo is not in S Cert
sid
T 73 assert tsopen is within a bounded range with ProtNSB .BlockHeight()
21 call ProtCLI .CloseTrans(C closed )
to negotiate the closed attestation
74 compute CertTod := Cert([Te, open, sid, T, tsopen ]; Sigsid
D , SigV )
sid
22 call ProtBC .MerkleProof(Te) to obtain a finalization proof for Te
c 75 call ProtBC .Exec(Te) to trigger on-chain execution
23 denote the finalization proof as MerkT1 (Figure 7)
c 76 call ProtCLI .OpenedTrans(CertTod ) to acknowledge request
24 update S Cert .Add(C closed
T ) and S Merk .Add(MerkT1 )
77 call ProtNSB .AddAction(CertTod ) to prove CertTod is sent
25 Daemon Watching(sid, ProtNSB ) private:
26 (GT , _, S Cert, S Merk ) := Data[sid]; abort if not found 78 update S Cert .Add(CertTod ) and T .state := opened
27 watch four types of attestations {Certid, Certo , Certod, Certc } 79 non-blocking wait until ProtNSB .MerkleProof(CertTod ) returns MerkTod
28 process fresh attestations via corresponding handlers (see below) 80 update S Merk .Add(MerkTod )
29 # Retrieve alternative attestations if necessary. 81 Upon Receive OpenedTrans(CertTod ) public: Southbound
30 for each T ∈ GT : 82 ast. CertTod has valid form of Cert([Te, open, sid, T, tsopen ]; SigV
sid
, Sigsid
D)
c
31 if T .state = opened and MerkT1 ∈ S Merk : 83 (_, _, S Cert, _) := Data[sid]; abort if not found
c
32 retrieve the roots [R, ...] of the proof MerkT1 84 abort if the CertTo corresponding to CertTod is not in S Cert
c
33 call ProtNSB .MerkleProof([R, ...]) to obtain a status proof MerkT2 85 update S Cert .Add(CertTod ) and T .state := opened
c2
34 continue if MerkT is not available yet on ProtNSB 86 T
Upon Receive CloseTrans(C closed ) public: Bidirectional
c c
35 compute the complete proof MerkcT := [MerkT1 , MerkT2 ] 87 assert C closed has valid form of Cert([Te, closed, sid, T, tsclosed ], Sigsid
T D)
36 update T .state := closed and S Merk .Add(MerkT ) c
c1
88 assert T is finalized on its destination blockchain and obtain Merk
e
T
37 compute eligible transaction set S using the current state of GT
89 assert tsclosed is within a bounded margin with ProtNSB .BlockHeight()
38 for each T ∈ S:
90 (_, _, S Cert, S Merk ) := Data[sid]; abort if not found
39 continue if T .state is not unknown
91 compute CertcT := Cert([Te, closed, sid, T, tsclosed ], Sigsid
D , SigV )
40 if T .from = ProtCLI : sid
92 call ProtCLI .ClosedTrans(CertcT ) to acknowledged request
41 compute CertiT := Cert([T, init, sid]; SigV ) c
sid 93 update S Cert .Add(CertTc ), S Merk .Add(MerkT1 ) and T .state := closed
42 call ProtCLI .InitTrans(CertiT ) to request initialization c
94 Upon Receive ClosedTrans(CertT ) public: Bidirectional
43 call ProtNSB .AddAction(CertiT ) to prove CertiT is sent
95 ast. Certc has valid form of Cert([Te, closed, sid, T, tsclosed ], SigV , SigD )
T
44 update S Cert .Add(CertiT ) and T .state := init sid sid
96 (_, _, S Cert, _) := Data[sid]; abort if not found
45 non-blocking wait until ProtNSB .MerkleProof(CertiT ) rt. MerkiT 97 abort if Cert([Te, closed, sid, T, tsclosed ], SigV ) is not in S Cert
sid
46 update S Merk .Add(MerkiT ) 98 update S Cert .Add(CertTc ) and T .state := closed
47 else: call self.SInitedTrans(sid, T) 99 Daemon Redeem(sid) private:
48 Upon Receive SInitedTrans(sid, T) private: Northbound 100 # Invoke the insurance contract periodically
49 (GT , _, S Cert, S Merk ) := Data[sid]; abort if not found 101 (GT , cid, S Cert, S Merk ) := Data[sid]; abort if not found
50 compute and sign the on-chain counterpart Te for T 102 for each unclaimed T ∈ GT :
51 compute Certid T
:= Cert([Te, inited, sid, T]; SigVsid
) 103
Ð
get the CertT from S Cert S Merk with the most advanced state
52 call ProtCLI .InitedTrans(Certid
T
) to request opening of initialized T 104 call ProtISC .InsuranceClaim(cid, CertT ) to claim insurance
53 call ProtNSB .AddAction(Certid
T
) to prove Certid
T
is sent
Figure 6: Protocol description of of ProtVES . Gray background denotes non-blocking operations triggered by status updates
on ProtNSB . Handlers annotated with northbound and southbound process transactions originated from ProtVES and ProtCLI ,
respectively. Handlers annotated with bidirectional are shared by all transactions.
V and Sig D to represent the Blockchain X The NSB
enclosed in the certificate. We use Sigsid sid
signature by ProtVES and ProtCLI , respectively. … TxRoot: Rx StateRoot: Ry … … StatusRoot …
Additionally, both ProtVES and ProtCLI are required to deposit
sufficient funds to ProtISC to ensure that ProtISC holds sufficient
funds to financially revert all committed transactions regardless
Blockchain X
of the step at which the execution aborts prematurely. Intuitively,
each party would need to stake at least the total amount of in- Value A BlockID: 2019
TxHash: 0x3…
coming funds to the party without deducting the outgoing funds. StateRoot: Ry
This strawman design, however, require high stakes. More desir- Value B TxRoot: Rx
ably, considering the dependency requirements in GT , an party X Figure 7: The complete on-chain proof (denoted by MerkcT )
(ProtVES or ProtCLI ) only needs to stake to prove that the state of a transaction is eligible to be pro-
moted as closed. The left-side part is the finalization proof
Õ Õ
max T .meta.amt − T .meta.amt
s ∈ GS
T ∈s ∧ T .to=X T ∈s ∧ T .from=X (denoted by MerkcT1 ) for the transaction collected from its
where GS is the set of all committable subsets in GT , where a subset destination blockchain; the right-side part is the blockchain
s ⊆ GT is committable if, whenever T ∈ s, all preconditions of T status proof (denoted by MerkcT2 ) collected from the NSB.
are also in s. For clarity of notation, throughout the paper, when
saying T .from =ProtVES or T is originated from ProtVES , we mean both parties. Only the tsopen specified in Certod is used by ProtISC
T
that T is sent and signed by an account owned by ProtVES . Likewise, when evaluating the deadline constraint of T .
T .from =ProtCLI indicates that T is sent from an account entity Southbound transactions originating from ProtCLI are processed
defined in the HSL program. ProtISC refunds any remaining funds by ProtVES in a similar manner as the northbound transactions, via
after the contract is terminated. the RInitedTrans and OpenedTrans handlers. We clarify a subtlety
After the contract is instantiated and sufficiently staked, ProtVES in the RInitedTrans handler when verifying the association between
initializes its internal bookkeeping for the session. The two no- Te and T (line 61). If Te depends on the resulting state from its up-
tations S Cert and S Merk represent two sets that store the signed stream transactions (for instance, T4 depends on the resulting state
certificates received via off-chain channels and on-chain Merkle
of T1 in Figure 4), ProtVES needs to verify that the state used by Te
proofs constructed using ProtNSB and ProtBC .
is consistent with the state enclosed in the finalization proofs of
4.2.2 Protocol Exchange for Transaction Handling those upstream transactions.
In ProtVES , SInitedTrans and OpenTrans are two handlers process- 4.2.3 Proactive Watching Services
ing northbound transactions which originates from ProtVES . The
The cross-chain execution process proceeds when all session-relevant
SInitedTrans handling for T is invoked when all its preconditions
blockchains and the NSB make progress on transactions. As the dri-
are finalized, which is detected by the watching service of ProtVES
ver of execution, ProtVES internally creates two watching services
(c.f., § 4.2.3). The SInitedTrans computes Certid T
to prove T is in to proactively read the status of those blockchains.
the inited state , and then passes it to the corresponding handler of In the watching daemon to one blockchain, ProtVES mainly reads
ProtCLI for subsequent processing. Meanwhile, SInitedTrans stakes the public ledger of ProtBC to monitor the status of transactions
Certid T
on ProtNSB , and later it retrieves a Merkle proof MerkiT from that have been posted for on-chain execution. If ProtVES notices
the NSB to prove that Certid T
has been sent. MerkidT
essentially is a that an on-chain transaction Te is recently finalized, it requests the
id
hash chain linking Cert T back to an ActionRoot on a committed closing process for T by sending ProtCLI a timestamped certificate
block of the NSB. The proof retrieval is a non-blocking operation C closed . The pair of handlers, CloseTrans and ClosedTrans, are used
triggered by the consensus update on the NSB. by both ProtVES and ProtCLI in this exchange. Both handlers can
The OpenTrans handler pairs with SInitedTrans. It listens for a be used for handling northbound and southbound transactions,
timestamped CertoT , which is supposed to be generated by ProtCLI depending on which party sends the closing request. In general, a
after it processes CertidT
from ProtVES . OpenTrans performs special transaction’s originator has a stronger motivation to initiate the
correctness check on the tsopen enclosed in CertoT . In particular, closing process because the originator would be held accountable
ProtVES and ProtCLI use the block height of the NSB as a calibrated if the transaction were not timely closed by its deadline.
clock. By checking that tsopen is within a bounded range of the In addition, ProtVES needs to retrieve a Merkle Proof from ProtBC
NSB height, ProtVES ensures that the tsopen added by ProtCLI is to prove the finalization of Te. This proof, denoted by MerkcT1 , serves
fresh. After all correctness checks on Certid are passed, the state two purposes: (i) it is the first part of a complete on-chain proof
T to prove that the state Te can be promoted to closed, as shown in
of T is promoted from open to opened. OpenTrans then computes
certificate to prove the updated state and posts Te on its destination Figure 7; (ii) if the resulting state of Te is used by its downstream
blockchain for on-chain execution. Throughout the paper, Te denotes transactions, MerkcT1 is necessary to ensure that those downstream
the on-chain executable transaction computed and signed using transactions indeed use genuine state.
the information contained in T . Note that the difference between In the watching service to ProtNSB , ProtVES performs following
the CertoT received from ProtCLI and a post-open (i.e., opened) tasks. First, as described in § 4.1.2, NSB is treated as a fallback
communication medium for the off-chain channel. Thus, ProtVES
certificate CertodT
computed by ProtVES is that latter one is signed by
1 Init: Data := ∅ 28 assert the Te enclosed in Certid
T
or CertoT is genuine
2 Upon Receive CreateContract(GT ): 29 assert the tsopen enclosed in CertoT is genuine
3 generate the arbitration cod, denoted by contract, as follows 30 update T.state := Atte.state
4 initialize three maps Tstate , Arevs and Fstake 31 elif Atte is MerkodT
:
5 for each T ∈ GT : 32 retrieve the certificate Certod from Atte
T
6 compute an internal identifier for T as tid := H (T) 33 update T.state := opened and T.tsopen := Certod .tsopen
T
7 initialize Tstate [tid] := [unknown, T, tsopen =0, tsclosed =0, stproof ] 34 elif Atte is MerkcT :
8 retrieve tid’s fund-reversion account, denoted as dst c
35 update T.stproof based on MerkT1 if necessary
9 initialize Arevs [tid] := [amt=0, dst] c
→− 36 update T.tsclosed as the height of the block attaching MerkT2
10 compute an identifier for contract as cid := H ( 0 , contract) 37 update T.state := closed
11 initialize Data[cid] := [GT , Tstate, Arevs, Fstake ] 38 Upon Timeout SettleContract(cid): Internal Daemon
12 send [cid, contract] to the requester for acknowledgment 39 (GT , Tstate, Arevs, Fstake ) := Data[cid]; abort if not found
13 Upon Receive StakeFund(cid): 40 for (tid, T) ∈ Tstate :
14 (_, _, _, _, Fstake ) := Data[cid]; abort if not found 41 continue if T.state is not closed
15 update Fstake [msg.sender] := Fstake [msg.sender] + msg.value 42 update Arevs [tid].amt := T. T .meta.amt
16 Upon Receive InsuranceClaim(cid, Atte): 43 if DeadlineVerify(T) = true : update T.state := correct
17 (_, _, Tstate, _, _) := Data[cid]; abort if not found 44 compute S := DirtyTrans(GT , Tstate ) # non-empty if execution fails.
18 compute tid := H (Atte. T); T := Tstate [tid] abort if not found 45 execute fund reversion for non-zero entries in Arevs if S is not empty
19 abort if T.state is more advanced the state enclosed by Cert 46 initialize a map resp to record which party to blame
20 if Atte is a certificate signed by both parties : 47 for each (tid, T) ∈ S :
21 assert SigVerify(Atte) is true 48 if T.state = closed | open | opened : resp[tid] := T. T .from
22 if Atte is CertodT
: update T.state := opened; T.tsopen := Atte.tsopen 49 elif T.state = inited : resp[tid] := T. T .to
23 else : update T.state := closed; T.tsclosed := Atte.tsclosed 50 elif T.state = init : resp[tid] := D
24 else : # Atte is in form of a Merkle proof 51 else : resp[tid] := V
25 assert MerkleVerify(Atte) is true 52 return any remaining funds in Fstake to corresponding senders
26 if Atte is a MerkiT or Merkid T
or MerkoT : 53 call Data.erase[cid] to stay silent afterwards
27 retrieve the certificate CertiT or Certid
T
or CertoT from Atte
searches the sorted ActionMT to look for any session-relevant cer- and OpenTrans of ProtVES , respectively, to process Certid and
tificates that have not been received via the off-chain channel. Sec- Certod sent by ProtVES when handling transactions originated from
ond, for each opened T whose closed attestation is still missing ProtVES . The InitTrans and OpenTrans process Certi and Certo sent
after ProtVES has sent C closed (indicating slow or no reaction from by ProtVES when executing transactions originated from ProtCLI .
ProtCLI ), ProtVES tries to retrieve the second part of MerkcT from The CloseTrans and ClosedTrans of ProtCLI match their counter-
ProtNSB . The second proof, denoted as MerkcT2 , is to prove that the parts in ProtVES to negotiate closing attestations.
Merkle roots referred in MerkcT1 are correctly linked to a StatusRoot For usability, HyperService imposes smaller requirements on
on a finalized NSB block (see Figure 7). Once MerkcT is fully con- the watching daemons implemented by ProtCLI . Specially, ProtCLI
structed, the state of T is promoted as closed. Finally, ProtVES may still proactively watches ProtNSB to have a fallback communica-
find a new set of transactions that are eligible to be executed if their tion medium with ProtVES . However, ProtCLI is not required to
preconditions are finalized due to any recently-closed transactions. proactively watch the status of underlying blockchains or dynami-
If so, ProtVES processes them by either requesting initialization cally compute eligible transactions whenever the execution status
from ProtCLI or calling SInitedTrans internally, depending on the changes. We intentionally offload such complexity on ProtVES to
originators of those transactions. enable lightweight dApp clients. ProtCLI , though, should (and is
motivated to) check the status of self-originated transactions in
4.2.4 ProtISC Invocation order to request transaction closing.
ProtVES periodically invokes ProtISC to execute the contract. All
internally stored certificates and complete Merkle proofs are accept- 4.4 Protocol Realization of the ISC
able. However, for any T , ProtVES should invoke ProtISC only using Figure 8 specifies the protocol realization of the ISC. The Create-
the attestation with the most advanced state, since lower-ranked Contract handler is the entry point of requesting insurance contract
attestations for T are effectively ignored by ProtISC (c.f., § 4.4). creation using ProtISC . It generates the arbitration code, denoted
as contract, based on the given dApp executable GT . The contract
4.3 Execution Protocol by dApp Clients internally uses Tstate to track the state of each transaction in GT ,
ProtCLI specifies the protocol implemented by dApp clients. ProtCLI which is updated when processing security attestations in the In-
defines the following set of handlers to match ProtVES . In partic- suranceClaim handler. For clear presentation, Figure 8 extracts
ular, the InitedTrans and OpenedTrans match the SInitedTrans
Negative Branch Positive Branch
accountable for not proactively driving the initialization of T , no
Originator: Dest: Failed to VES: Failed to matter which party originates T .
Violated deadline request opening proactively drive
Throughput (KB/s)
to the multi-lang front end to support the programming language 1000
used by the blockchain (if this language has not been supported 800
by (IFUIP , S), and the real world, featured by (ProtUIP , A). Math- is that the simulator S observes the side effects of ProtUIP in the
→− real world, such as attestation publication on the NSB and contract
ematically, on any input, the probability that E outputs 1 after
interacting with (ProtUIP , A) in the real world differs by at most invocation of the ISC, and then accurately emulates these effects
→− in the ideal world, with the help from FUIP . As a result, E cannot
a negligible amount from the probability that E outputs 1 after
distinguish the ideal and real worlds.
interacting with (IFUIP , S) in the ideal world.
The ideal protocol IFUIP is a wrapper around FUIP by a set of
dummy parties that have the same interfaces as the parties of
8.4 Construction of the Ideal Simulator S
ProtUIP in the real world. As a result, E is able to interact with Next, we detail the construction of S by specifying what actions S
IFUIP in the ideal world the same way it interacts with ProtUIP in should take upon observing instructions from E. As a distinguisher,
the real world. These dummy parties simply pass received input E sends the same instructions to the ideal world dummy parities
from E to FUIP and relay output of FUIP to E, without implementing as those sent to the real world parties.
any additional logic. FUIP controls all keys of these dummy parties. • Upon E gives an instruction to start an inter-BN session between
I and P I , S emulates the G and contract setup (c.f., § 8.5)
PCLI
For the sake of clear presentation, we abstract the real-world par- VES T
ticipants of ProtUIP as five parties {PVES , PCLI , PISC , PNSB , PBC }. and constructs a SessionCreate call to FUIP with parameter (GT ,
The corresponding dummy party of PVES in the ideal world is I , P I ).
contract, PCLI VES
denoted as PVESI . This annotation applies for other parties. I to send an initialization request for a
• Upon E instructs PVES
Based on [28], to prove that ProtUIP UC-emulates IFUIP for any transaction intent T , S extracts T and sid from the instruction
adversaries, it is sufficient to construct a simulator S just for the of E, and constructs a ReqTransInit call to FUIP with parameter
dummy adversary A that simply relays messages between E and I ). Other instructions in the same category are han-
(T , sid, PVES
the parties running ProtUIP . The high-level process of the proof dled similarly by S. In particular, for instruction to SInitedTrans,
S calls ReqTransInited of FUIP ; for instructions to RInitedTrans, Upon observing an instruction from E (to either dummy party)
S calls ReqTransOpen of FUIP ; for instructions to OpenTrans, S to invoke the smart contract, S uses its saved certificates or Merkle
calls ReqTransOpened of FUIP ; for instructions to CloseTrans, S proofs to invoke PISC in the Hybrid A1 accordingly.
calls ReqTransClose of FUIP . S ignores instructions to Opened- Note that in the real world, the execution of GT is automatic in
Trans and ClosedTrans. S may also extract the Te from the in- the sense that GT can continuously proceed even without additional
struction, which is used by some interfaces of FUIP to ensure the instructions from E after successful session setup. In the Hybrid A1 ,
association between T and Te. although PVES and PCLI are replaced by dummy parties, S, with
• Due to the asymmetry of interfaces defined by PCLI I and P I , S fully knowledge of GT , is still able to drive the execution of GT so
VES
I .
acts slightly differently when observing instructions sent to PVES that from E’s perspective, GT is executed automatically. Further,
In particular, for instructions to InitTrans, S calls ReqTransInited since PISC still lives in the Hybrid A1 , S should not trigger the
of FUIP ; for instructions to InitedTrans, S calls ReqTransOpen TermExecution interface of FUIP to avoid double execution on the
of FUIP ; for instructions to OpenTrans, S calls ReqTransOpened same contract terms. S can still reclaim its funds staked in FUIP via
of FUIP . The rest handlings are the same as those of PVES I . “backdoor” channels since S and FUIP are allowed to communicate
I freely under the UC framework.
• Upon E instructs PVES to invoke the smart contract, S locally
executes the contract and the instructs FUIP to published the Fact 1. With the aforementioned construction of S and FUIP , it is
I . immediately clear that the outputs of both dummy parties in the
updated contract to PISC
Hybrid A1 are exactly the same as the outputs of the corresponding
8.5 Indistinguishability of Real and Ideal actual parties in the real world, and all side effects in the real world
are accurately emulated by S in the Hybrid A1 . Thus, E cannot
Worlds distinguish with the real world and the Hybrid A1 .
To prove indistinguishability of the real and ideal worlds from Hybrid A2 . Hybrid A2 is the same as the Hybrid A1 , expect that
the perspective of E, we will go through a sequence of hybrid PISC is further replaced by the dummy PISC I . As a result, S is
arguments, where each argument is a hybrid construction of FUIP , required to resume the responsibility of PISC in the Hybrid A2 .
a subset of dummy parties of IFUIP , and a subset of real-world In particular, when observing an instruction to execute a GT , S
parties of ProtUIP , except that the first argument that is ProtUIP computes the arbitration code contract, and then instructs FUIP to
without any ideal parties and the last argument is IFUIP without I , which is observable by E. For any
publish the contract on PISC
any real world parties. We prove that E cannot distinguish any
instruction to invoke contract, S locally executes contract with the
two consecutive hybrid arguments. Then based on the transitivity I via F
input and then publishes the updated contract to PISC UIP .
of protocol emulation [28], we prove that the first argument (i.e.,
Finally, upon the predefined contract timeout, S calls the TermExe-
ProtUIP ) UC-emulates the last argument (i.e., IFUIP ). I ) or (sid, P I )
cution interface of FUIP with parameter (sid, PVES CLI
Real World. We start with the real world ProtUIP with a dummy to execute the contract, which emulates the arbitration performed
adversary that simply passes messages to and from E. by PISC in the Hybrid A1 .
Hybrid A1 . Hybrid A1 is the same as the real world, except that the It is immediately clear that with the help of S and FUIP , the out-
I , P I ) pair. Upon
(PVES , PCLI ) pair is replaced by the dummy (PVES I and all effects in the Hybrid A are exactly
CLI put of the dummy PISC 2
observing an instruction from E to execute some dApp executables the same as those in the Hybrid A1 . Thus, E cannot distinguish
GT , S calls the CreateContract interface of PISC (living in the these two worlds.
Hybrid A1 ) to obtain the contract code contract. Upon contract is Hybrid A3 . Hybrid A3 is the same as the Hybrid A2 , expect that
received, S calls the SessionCreate interface of FUIP with parameter I . Since the structure of
I , P I ), which will output a certificate to both PNSB is further replaced by the dummy PNSB
(GT , contract, PVES CLI PNSB and messages sent to PNSB are public, simulating its function-
dummy parties to emulate the handshake result between PVES and ality by S is trivial. Therefore, Hybrid A3 is identically distributed
PCLI in the real world. S also deploys contract on PNSB or PBC in as Hybrid A2 from the view of E.
the Hybrid A1 . Finally, S stakes required funds into FUIP to unblock
Hybrid A4 , i.e., the ideal world. Hybrid A4 is the same as the
its execution.
Hybrid A3 , expect that PBC (the last real-world party) is further
Upon observing an instruction from E (sent to either dummy I . Thus, the Hybrid A is essentially
replaced by the dummy PBC 4
parties) to execute a transaction in GT , based on its construction
IFUIP . Since the functionality of PBC is a strict subset of that of
in § 8.4, S has enough information to construct a call to FUIP
PNSB , simulating PBC by S is straightforward. Therefore, IFUIP is
with a proper interface and parameters. If the call generates a
indistinguishable with the Hybrid A3 from E’s perspective.
certificate Cert, S retrieves Cert to emulate the PoAs staking in
Then given the transitivity of protocol emulation, we show that
the real world. In particular, if in the real world, PVES (and PCLI )
ProtUIP UC-emulates IFUIP , and therefore prove that ProtUIP UC-
publishes a certificate on PNSB after receiving the same instruction
realizes FUIP . Throughout the simulation, we maintain a key in-
from E, then S publishes the corresponding certificate on PNSB
variant: S and FUIP together can always accurately simulate the
in the Hybrid A1 as well. Otherwise, S skip the publishing. Later,
desired outputs and side effects on all (dummy and real) parties
S retrieves (and stores) the Merkle proof from PNSB , and then
in all Hybrid worlds. Thus, from E’s view, the indistinguishability
instructs FUIP to output the proof to the dummy party which, from
between the real and ideal worlds naturally follows.
the point view of E, should be the publisher of Cert.
8.6 Byzantine Corruption Model [9] J.P. Morgan: Blockchain and Distributed Ledger. https://www.jpmorgan.com/
global/blockchain, Accessed on 2019.
Theorem 8.1 considers the passive corruption model. In this section, [10] Nebulas. https://github.com/nebulasio, Accessed on 2019.
we discuss the more general Byzantine corruption model for PVES [11] Oraclize. http://www.oraclize.it, Accessed on 2019.
[12] Polkadot. https://polkadot.network, Accessed on 2019.
and PCLI (by assumption of this paper, blockchains and smart con- [13] rhombus. https://rhombus.network, Accessed on 2019.
tracts are trusted for correctness). Previously, we construct S and [14] Solidity. https://solidity.readthedocs.io/en/v0.5.6/, Accessed on 2019.
FUIP accurately to match the desired execution of ProtUIP . However, [15] Standards for the Cosmos network & Interchain Ecosystem. https://github.com/
cosmos/ics, Accessed on 2019.
if one party is Byzantinely corrupted, the party behaves arbitrarily. [16] Substrate. https://github.com/paritytech/substrate, Accessed on 2019.
As a result, a Byzantine-corrupted party may send conflicting mes- [17] Tendermint Core. https://tendermint.com, Accessed on 2019.
sages to off-chain channels and PNSB . Note that for any transaction [18] Tor Directory Authorities. https://metrics.torproject.org/rs.html#search/flag:
authority, Accessed on 2019.
state, ProtUIP always processes the first received attestation (either [19] Vyper. https://github.com/ethereum/vyper, Accessed on 2019.
a certificate from channels or Merkle proof from the PNSB ) and [20] Al-Bassam, M., Sonnino, A., Bano, S., Hrycyszyn, D., and Danezis, G.
Chainspace: A Sharded Smart Contracts Platform. NDSS (2017).
effectively ignores the other one. The adversary could then inject [21] Back, A., Corallo, M., Dashjr, L., Friedenbach, M., Maxwell, G., Miller, A.,
message inconsistency to make the protocol execution favors one Poelstra, A., Timón, J., and Wuille, P. Enabling Blockchain Innovations with
type of attestations over the other. This makes it impossible for S Pegged Sidechains. URL: tinyurl. com/mj656p7 (2014).
[22] Blackshear, S., Cheng, E., Dill, D. L., Gao, V., Maurer, B., Nowacki, T., Pott,
to always accurately emulate its behaviors, resulting in difference A., Qadeer, S., Rain, Russi, D., Sezer, S., Zakian, T., and Zhou, R. Move: A
between the ideal world and the real world from E’s view. language with programmable resources. Tech. rep., The Libra Association, 2019.
To incorporate the Byzantine corruption model into our security [23] Borders, K., Springer, J., and Burnside, M. Chimera: A Declarative Language
for Streaming Network Traffic Analysis. In USENIX Security Symposium (2012).
analysis, we consider a variant of ProtUIP , referred to as H-ProtUIP , [24] Breidenbach, L., Cornell Tech, I., Daian, P., Tramer, F., and Juels, A. Enter the
that requires PVES and PCLI to only use PNSB as the communication Hydra: Towards Principled Bug Bounties and Exploit-Resistant Smart Contracts.
In 27th USENIX Security Symposium (2018).
medium. Thus, the full granularity of protocol execution is guar- [25] Bünz, B., Bootle, J., Boneh, D., Poelstra, A., Wuille, P., and Maxwell, G.
anteed to be public and unique, allowing S to emulate whatever Bulletproofs: Short proofs for Confidential Transactions and More. In 2018 IEEE
actions a (corrupted) part may take in the real world. Therefore, it Symposium on Security and Privacy (SP) (2018), IEEE, pp. 315–334.
[26] Buterin, V. Chain Interoperability. R3 Reports (2016).
is not hard to conclude the Theorem 8.2. [27] Buterin, V., et al. A Next-Generation Smart Contract and Decentralized Appli-
cation Platform. white paper (2014).
9 CONCLUSION [28] Canetti, R. Universally Composable Security: A New Paradigm for Crypto-
graphic Protocols. In IEEE Symposium on Foundations of Computer Science (2001).
In this paper, we presented HyperService, the first platform that [29] Cheng, R., Zhang, F., Kos, J., He, W., Hynes, N., Johnson, N. M., Juels, A.,
offers interoperability and programmability across heterogeneous Miller, A., and Song, D. Ekiden: A Platform for Confidentiality-Preserving,
Trustworthy, and Performant Smart Contract Execution. In IEEE EuroS&P (2019).
blockchains. HyperService is powered by two innovative designs: [30] Costan, V., and Devadas, S. Intel SGX explained, Accessed on 2019. https:
HSL, a programming framework for writing cross-chain dApps by //eprint.iacr.org/2016/086.pdf.
[31] Dingledine, R., Mathewson, N., and Syverson, P. Tor: The Second-Generation
unifying smart contracts written in different languages, and UIP, Onion Router. In USENIX Security Symposium (2004).
the universal blockchain interoperability protocol designed to se- [32] Eyal, I., Gencer, A. E., Sirer, E. G., and Van Renesse, R. Bitcoin-NG: A Scalable
curely realize the complex operations defined in these dApps on Blockchain Protocol. In USENIX NSDI (2016).
[33] Gao, P., Xiao, X., Li, D., Li, Z., Jee, K., Wu, Z., Kim, C. H., Kulkarni, S. R., and
blockchains. We implemented a HyperService prototype in approx- Mittal, P. SAQL: A Stream-based Query System for Real-time Abnormal System
imately 35,000 lines of code to demonstrate its practicality, and ran Behavior Detection. In USENIX Security Symposium (2018).
experiments on the prototype to report the end-to-end execution [34] Gao, P., Xiao, X., Li, Z., Jee, K., Xu, F., Kulkarni, S. R., and Mittal, P. AIQL:
Enabling Efficient Attack Investigation from System Monitoring Data. In USENIX
latency for dApps, as well as the aggregated platform throughput. ATC (2018).
[35] Garay, J., Kiayias, A., and Leonardos, N. The Bitcoin Backbone Protocol with
10 ACKNOWLEDGMENTS Chains of Variable Difficulty. In Annual International Cryptology Conference
(2017).
We thank the anonymous reviewers for their valuable feedback. We [36] Gazi, P., Kiayias, A., and Zindros, D. Proof-of-stake Sidechains. In IEEE
Symposium on Security & Privacy (2019).
thank Harmony Protocol for their discussion on cross-shard trans- [37] Green, M., and Miers, I. Bolt: Anonymous Payment Channels for Decentralized
actions. This material is based upon work partially supported by Currencies. In ACM CCS (2017).
NSF under Contract Nos. CNS-1717313 and TWC-1518899, and by [38] Herlihy, M. Atomic Cross-Chain Swaps. In ACM PODC (2018).
[39] Kalodner, H., Goldfeder, S., Chen, X., Weinberg, S. M., and Felten, E. W.
National Key Research and Development Program of China under Arbitrum: Scalable, Private Smart Contracts. In USENIX Security Symposium
grant No. 2018YFB0803605 and NSFC under grant No. 61702045. (2018).
Correspondence authors are Zhuotao Liu and Haoyu Wang. [40] Khalil, R., and Gervais, A. Revive: Rebalancing Off-blockchain Payment Net-
works. In ACM CCS (2017).
[41] Kiayias, A., and Zindros, D. Proof-of-work Sidechains. Tech. rep., Cryptology
REFERENCES ePrint Archive, Report 2018/1048, 2018.
[1] Cosmos WhitePaper. https://cosmos.network/resources/whitepaper, 2019. [42] Killian, C. E., Anderson, J. W., Braud, R., Jhala, R., and Vahdat, A. M. Mace:
[2] Harmony: Technical Whitepaper. https://harmony.one/whitepaper.pdf, 2019. Language support for building distributed systems. In ACM PLDI (2007).
[3] Monoxide: Scale Out Blockchain with Asynchronized Consensus Zones. In [43] Kogias, E. K., Jovanovic, P., Gailly, N., Khoffi, I., Gasser, L., and Ford, B. En-
USENIX NSDI (2019). hancing Bitcoin Security and Performance with Strong Consistency via Collective
[4] Open Source Code for HyperService by HyperService-Consortium. https://github. Signing. In USENIX Security Symposium (2016).
com/HyperService-Consortium, 2019. [44] Kokoris-Kogias, E., Jovanovic, P., Gasser, L., Gailly, N., Syta, E., and Ford, B.
[5] Bitcoin Wiki: Atomic Cross-Chain Trading. https://en.bitcoin.it/wiki/Atomic_ OmniLedger: A Secure, Scale-out, Decentralized Ledger via Sharding. In IEEE
swap, Accessed on 2019. Symposium on Security and Privacy (2018).
[6] CoinMarketCap. https://coinmarketcap.com, Accessed on 2019. [45] Kosba, A., Miller, A., Shi, E., Wen, Z., and Papamanthou, C. Hawk: The
[7] Cosmos. https://cosmos.network, Accessed on 2019. Blockchain Model of Cryptography and Privacy-preserving Smart Contracts. In
[8] DPOS Consensus Algorithm. https://steemit.com/dpos/@dantheman/dpos- IEEE Symposium on Security and Privacy (2016).
consensus-algorithm-this-missing-white-paper, Accessed on 2019. [46] Krupp, J., and Rossow, C. teEther: Gnawing at Ethereum to Automatically
Exploit Smart Contracts. In USENIX Security Symposium (2018).
[47] Lamport, L. Time, Clocks, and the Ordering of Events in a Distributed System. [56] Sergey, I., and Hobor, A. A Concurrent Perspective on Smart Contracts. In
Communications of the ACM (1978). Financial Cryptography and Data Security (2017).
[48] Lamport, L., Shostak, R., and Pease, M. The Byzantine Generals Problem. ACM [57] Sommer, R., Vallentin, M., De Carli, L., and Paxson, V. Hilti: An abstract
Transactions on Programming Languages and Systems (TOPLAS) (1982). execution environment for deep, stateful network traffic analysis. In IMC (2014).
[49] Lee, D., Kohlbrenner, D., Shinde, S., Song, D., and Asanović, K. Keystone: A [58] Vallentin, M., Paxson, V., and Sommer, R. VAST: A Unified Platform for
Framework for Architecting TEEs. arXiv preprint arXiv:1907.10119 (2019). Interactive Network Forensics. In USENIX NSDI (2016).
[50] Loo, B. T., Condie, T., Garofalakis, M., Gay, D. E., Hellerstein, J. M., Maniatis, [59] Van Saberhagen, N. CryptoNote v 2.0. https://cryptonote.org/whitepaper.pdf,
P., Ramakrishnan, R., Roscoe, T., and Stoica, I. Declarative networking: 2013.
Language, execution and optimization. In SIGMOD (2006). [60] Wood, G. Ethereum: A secure decentralised generalised transaction ledger.
[51] Luu, L., Chu, D.-H., Olickel, H., Saxena, P., and Hobor, A. Making Smart Ethereum Project Yellow Paper (2014).
Contracts Smarter. In ACM CCS (2016). [61] Zamani, M., Movahedi, M., and Raykova, M. RapidChain: Scaling Blockchain
[52] Luu, L., Narayanan, V., Zheng, C., Baweja, K., Gilbert, S., and Saxena, P. A via Full Sharding. In ACM CCS (2018).
Secure Sharding Protocol for Open Blockchains. In ACM CCS (2016). [62] Zamyatin, A., Harz, D., Lind, J., Panayiotou, P., Gervais, A., and Knottenbelt,
[53] Malavolta, G., Moreno-Sanchez, P., Kate, A., Maffei, M., and Ravi, S. Con- W. XCLAIM: Trustless, Interoperable, Cryptocurrency-Backed Assets. In IEEE
currency and Privacy with Payment-channel Networks. In ACM CCS (2017). Symposium on Security and Privacy (2019).
[54] Nakamoto, S. Bitcoin: A Peer-to-Peer Electronic Cash System. https://bitcoin. [63] Zhang, F., Cecchetti, E., Croman, K., Juels, A., and Shi, E. Town Crier: An
org/bitcoin.pdf, 2008. Authenticated Data Feed for Smart Contracts. In ACM CCS (2016).
[55] Parr, T. Antlr. https://www.antlr.org/, 2014.
A APPENDIX generated by any HyperService sessions into the StatusMT. An
alternative design for building StatusPool is via the CloseureWatch-
A.1 Specification of ProtNSB and ProtBC
ing which proactively watches all underlying blockchains to col-
The detailed protocol description of ProtNSB and ProtBC is given lected the transaction Merkle roots and state roots packaged in
in Figure 12. We model block generation and consensus in ProtNSB recently finalized blocks. This design is more cost efficient for Hy-
(and ProtBC ) as a discrete clock that proceeds in epochs. The length perService users since they do not need to explicitly claim these
of an epoch is not fixed to reflect the consensus. At the end of roots. Meanwhile, the structure of the StatusMT is changed to the
each epoch, a new block is packaged and added to the append-only same as ActionMT since all its stored data now become static.
public Ledger. Figure 12 further specifies the protocol of each individual honest
The block format of ProtNSB is shown in Figure 5. Each block peer/miner in the NSB to ensure the correctness of both interfaces.
packages two special Merkle trees (i.e., ActionMT and StatusMT) By complying with the protocol, honest peers accept any received
and other Merkle trees (e.g., TxMT) that are common in both ProtNSB claim (i.e., a Merkle root or transaction claim) only after receiving a
and ProtBC . StatusMT and ActionMT are constructed using the quorum of approvals for the claim. The protocol provably ensures
items in the StatusPool and ActionPool, respectively. Considering the correctness of both interfaces, given that the number of Byzan-
the size limit of one block, some items in these pools may not be tine nodes in the permissioned NSB is no greater than the security
included (e.g., due to lower gas prices or random selections), and parameter K [48].
will be rolled over to the next epoch. The ActionPool is constructed in a similar manner as the Sta-
StatusPool is constructed via the CloseureClaim interfaces exe- tusPool. In Figure 12, an interface annotated with override is also
cuted by all NSB peers. The CloseureClaim directly listens for trans- implemented by ProtBC , although the implementation detail may be
actions claimed by HyperService users (VESes and dApp clients). different; for instance ProtBC may have different consensus process
This design avoids including irrelevant transactions that are not than ProtNSB in the DiscreteTimer interface.
1 Init: Data := ∅; Epoch := 0; Ledger := [] 26 Daemon CloseureWatching({ProtBC , ...}): Proactive Streaming Version
2 Daemon DiscreteTimer() override: 27 proactively watch ProtBC for recently finalized blocks { B, ... }
3 continue if the current Epoch is not expired 28 (_, _, StatusPool) := Data[Epoch]; abort if not found
4 (TxPool, ActionPool, StatusPool) := Data[Epoch] 29 retrieve the root Rtx of TxMT and Rstate of StateMT on B
5 initialize a block B with the format shown in Figure 5 30 update StatusPool.Add(Rtx, Rstate )
6 for pool ∈ (TxPool, ActionPool, StatusPool) : 31 # Protocol of an individual honest peer V to ensure correctness
7 construct a (sorted) Merkle tree with selected items in pool 32 Init: V .StatusPool := []
8 populate B with the Merkle tree (TxMT, ActionMT, or StatusMT) 33 Daemon Watching({ProtBC , ...}) and Watching(B, S = {Sig, ... })
9 remove these selected items from pool 34 abort if B is not finalized on ProtBC or B is processed before
10 update Ledger.append(B) and execute trans. captured under TxMT 35 abort if S contains more than K distinguished signatures
11 start a new epoch Epoch := Epoch + 1 36 retrieve the root Rtx of TxMT and Rstate of StateMT on B
12 initialize Data[Epoch] := [TxPool, ActionPool, StatusPool] 37 S.Add(Cert([Rtx, Rstate ]; SigV )); V .StatusPool.Add(Rtx, Rstate )
13 Daemon CloseureClaim(Te, [ChainID, StateRoot, TxRoot ]): 38 multicast (B, S) to other peers of the NSB
14 (_, _, StatusPool) := Data[Epoch]; abort if not found 39 Upon Receive AddAction(Cert):
15 update StatusPool.Add(Te) 40 (_, ActionPool, _) := Data[Epoch]; abort if not found
16 # Protocol of an individual honest peer V to ensure correctness 41 update ActionPool.Add(Cert)
17 Init: V .StatusPool := [] 42 # Similar correctness protocol as in CloseureClaim for honest peers
18 Daemon Watching(Te, S = {Sigpeer, ... }) 43 Upon Receive Exec(Te) override:
19 abort if Te is already in V .StatusPool 44 abort if Te is not correctly constructed and signed
20 abort if S contains more than K distinguished signatures 45 (TxPool, _, _) := Data[Epoch]; abort if not found
21 abort if Te is not finalized on its destination blockchain (ChainID) 46 update TxPool.Add(Te)
22 abort if the reported StateRoot and TxRoot are not authentic 47 Upon Receive BlockHeight() override:
23 update V .StatusPool.Add(Te) 48 return the block number of the last block on Ledger
24 update S.Add(Cert([Te, [ChainID, StateRoot, TxRoot]]; SigV )) 49 Upon Receive MerkleProof(key) override:
25 multicast (Te, S) to other peers of the NSB 50 find the block B on Ledger containing key; abort if not found
51 return a hash chain from key to the Merkle root on B
Figure 12: Detailed protocol description of ProtNSB . Interfaces annotated with override are also implemented by ProtBC . Gray
background denotes the protocol of honest peers in the NSB to ensure the correctness for the corresponding interface.