You are on page 1of 6

2022 IEEE 42nd International Conference on Distributed Computing Systems Workshops (ICDCSW)

A Distributed Energy Trading Framework with


secure and effective Consensus Protocol
2022 IEEE 42nd International Conference on Distributed Computing Systems Workshops (ICDCSW) | 978-1-6654-8879-2/22/$31.00 ©2022 IEEE | DOI: 10.1109/ICDCSW56584.2022.00010

Jin Ye, Jiahua Liang Xiaohuan Li, Qian Chen


School of Computer and Electronic Information School of Information and Communication
Guangxi University Guilin University of Electronic Technology
Nanning 530000, China Guilin 541000, China
yejin@gxu.edu.cn, 2013391034@st.gxu.edu.cn lxhguet@guet.edu.cn, chenqian@mails.guet.edu.cn

Abstract—With the rapid increase of DER(distributed energy can trade with each other. However, distributed energy trading
resources), it has become a global trend to establish a distributed market has not been popularized on a large scale. There are
energy trading markets to coordinate these DERs. However, many challenges on the transaction in which biggest barrier is
the construction of distributed energy trading market faces
various challenges, in which trusted transaction among market trust crisis [5] among participants in the market and makes it
participants is crisis. Since the existing solutions need numerical difficult for trading center to ensure fairness and transparency
calculation and communication resource that lead to large delay, of transaction.
this paper proposes a distributed energy trading framework Blockchain is essentially a distributed, chain-structured
with secure and effective consensus protocol. Different from the database with shared ledgers [6]. There is not doubt that
traditional PBFT(Practical Byzantine Fault Tolerance) that is
the notable debasement on interaction flow between processes, a blockchain is a state-of-the-art powerful technic to address
threshold signature mechanism is introduced and the consensus above problems in energy transaction due to its decentralized,
process of trading is reconstructed. Theoretical analysis shows tamper-proof and traceable characteristics. In [7], blockchain
that the communication complexity of the proposed framework is is applied to solve the single point of failure of P2P energy
optimized from O(n2 ) to O(n), and the computation complexity trading market and ensures the safe operation of bidirectional
of the participants is also reduced from O(n) to O(1). Our
simulation results also show that the task delay of our consensus auction with trusted transaction at the same time. In [8], a two-
protocol begins to be lower than PBFT when the number of layer distributed P2P energy transaction platform is designed.
participants exceeds a certain threshold. In particular, the trusted The market layer is responsible for the settlement of auction
transaction delay using our consensus protocol is reduced by pool. Furthermore, blockchain layer provides secure and reli-
12.14% when the number of participants increases to 100. able transaction for platform by implicating smart contracs. In
Index Terms—distributed energy trading, blockchain, consen-
sus protocol, threshold signature [9], a hierarchical bidding and transaction structure based on
blockchain was proposed, which is implicated by Hyperledger
Fabric to achieve safe transaction and inalterable ledgers.
I. I NTRODUCTION
As a self-organizing decentralized network, the consensus
With the rapid development of power system, more and protocol embedded in blockchain is an significant mechanism
more distributed energy resources(DERs) are connected to to coordinate all network nodes without centralized man-
the grid. DERs are most likely to cause fluctuations in grid agement and third party supervision. However, few studies
operation due to unstable output power of solar photovoltaic noticed that consensus protocol will give rise to high deley
arrays and wind turbines. Therefore, coordinating DERs to in settlement of energy transaction. It usually take less than
build microgrids is an important solution to these problem. five minutes to settle energy transaction [10] but the existing
Since the microgrid enables energy P2P(peer-to-peer) transfer consensus protocols generally has the problem of low effi-
among entities, it can operate independently that increasing its ciency, which makes it difficult to meet the requirements in
flexiblity and scalability [1]. large-scale distributed energy trading scenarios. At present,
In order to improve the utilization rate of energy in micro- consensus protocols for energy trading can be categoried into
grid, a common approach is to establish distributed energy two classes: consensus with mining and consensus without
trading market which allows participants in the market to mining.
negotiate with each other to determine price of energy for For the consensus with mining, network nodes packag-
trading. Actually, distributed energy trading market has been ing the transactions information into blocks according to a
piloted around the world. For example, in USA, TeMix [2] is certain rule, which is called mining. Meanwhile, the nodes
a transactive energy platform, providing energy trading and conducting mining are called miners. Consensus with mining
distributed management services; in Germany, Peer Energy often requires miners to consume amounts of computing
Cloud [3] is a commercial cloud for a virtual market enabling resources(including electricity) to contend transaction settle-
local energy trading; in UK, Piclo [4] is an independent trading ment. In [11], a P2P trading platform of producers and
market in which renewables, batteries and electric vehicles consumers is constructed based on PoW(Proof of Work)

2332-5666/22/$31.00 ©2022 IEEE 1


DOI 10.1109/ICDCSW56584.2022.00010
Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY GUWAHATI. Downloaded on November 13,2023 at 06:10:51 UTC from IEEE Xplore. Restrictions apply.
TABLE I
P ERFORMANCE COMPARISON OF DIFFERENT CONSENSUS MECHANISMS

Consensus Mining Latency Computation burden Byzantine fault tolerance Paper


PoW yes very high very high 50% [10]
PoS yes high very high 50% [11], [12]
PBFT no high high 33.33% [13], [14]
Raft no low low nonsupport [15]

consensus. In addition, the rules for producers and consumers computational complexity. The typical example of intolerant
to participate in market transactions are defined through smart byzantine fault is Raft, which has very low latency and low
contracts which realize complete energy trading process in- computational complexity, but it is difficult to be applied to
cluding transaction publishing, bidding matching and account- real energy transactions due to intolerant byzantine fault, so
ing. In [12], an optimized PoS(Proof of Stake) consensus that it is rarely mentioned in current researches.
protocol is introduced to solve high mining expenses and In this paper, a distributed energy trading framework is
large energy consumption of PoW in decentralized P2P energy proposed and an efficient and secure consensus protocol is
trading market. Compared with PoW, PoS has less computing designed to prevent dishonest participants act evil. Compared
resources requirement. However, it is still a non-neglectful with existing studies, the framework proposed in this paper
waste. Furthermore, miners with higher stake are more likely significantly reduces communication complexity and compu-
to obtain accounting rights result in miners with lower stake tation complexity which is deployed in real distributed energy
are less willing to participate in mining, which forms the transaction scenarios easier.
Matthew Effect [13]. PoCS, a PoS-like consensus protocol
based on credit proof is proposed in [14]. By introducing a II. P ROPOSED DISTRIBUTED ENERGY TRADING
credit mechanism, the node with higher credit value has a FRAMEWORK
greater probability of obtaining accounting right, so as to en-
courage nodes to participate in market transactions. Whereas, In order to address the problems of trust crisis and low
it doesn’t solve Matthew Effect problem of PoS. efficiency in distributed energy trading, in this paper we
propose a distributed energy trading framework with efficient
For the consensus without mining, it achieve consensus
and secure consensus protocol. The framework is based on
among network nodes through communication instead of con-
blockchain which can guarantee the robustness of trading
suming meaningless computing resources. In [15], a consen-
system. Meanwhile, a consensus protocol for energy trading
sus mechanism based on PBFT is proposed. The consensus
is designed, which not only brings secure to energy trading,
process of multi-energy subjects is designed to achieve high
but also has higher efficiency compared with the traditional
robustness of consensus by dividing multiple energy regulatory
method such as PBFT, PoW, PoS, etc. The price scheme was
subjects, and effectively prevent the evil behavior of multi-
introduced to protect fairness for all market participants.
energy subjects. PBFT requires a large amount of broadcasting
and verification in the consensus process, resulting in high
communication and computing resource costs and high delay A. Distributed energy trading market
in reaching consensus. In [16], the PBFT-like method is The distributed energy trading market framework is shown
adopted to design a hierarchical energy trading framework. as Fig. 1(A). The market participants are composed of commit-
Meanwhile, the and the mutual verification of committee nodes tee members and communities. The committee contains one
enables byzantine fault nodes are detected and removed from leader and several candidates. Candidates are elected by com-
the market. The consensus process of this paper requires a munities and leader is elected by candidates. For simplicity,
huge amount of communication due to several iterations. In this paper will not discuss election rules for candidates and
[17], comparing with the existing consensus protocols used leader.
for energy transaction, Raft is excellent in terms of delay and All the communities interact with leader to implement
throughput. However it does not tolerate byzantine fault and consensus protocol, transmit supply/demand messages and
is only suitable for strictly trusted distributed networks, not agree on market clearing price during trading cycles. After all
for real energy trading markets. the market participants have reached a consensus, distributed
It can be seen in TABLE I that the current consensus system operator(DSO) conducts energy transmission and trans-
protocols with mining generally consume a lot of computing action settlement according to consensus results.
resource and have very high delay, which is difficult to meet The blockchain will stores the necessary transaction infor-
the performance requirements of fast settlement in energy mation such as consensus results, energy transmission results
trading market. The consensus without mining can be further and transaction settlement results. Because of the advantages
classified into tolerable and intolerable for byzantine fault. of immutable and traceable blockchain, it is easier for system
The classic example of byzantine fault tolerance is PBFT, maintainers to trace the party responsible for the transaction
which does not require mining but still has high latency and failure.

Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY GUWAHATI. Downloaded on November 13,2023 at 06:10:51 UTC from IEEE Xplore. Restrictions apply.
Fig. 1. Distributed energy trading framework.

B. Consensus protocol once receive < EN D, λsig >, which proof all partici-
pants agree to trading by market clearing price < λsig >.
In distributed energy trading market, each participant holds Communities can save the consensus results in their local
a private key share and a public key for signing and verifying storage.
market clearing price generated in the consensus process. The
Algorithm 1 and Algorithm 2 define the actions of leader
proposed consensus protocol includes 6 stage, as Fig.1(A)
and communities in the consensus process respectively.
illustrates.
• Demand: All the communities send their supply/demand C. Threshold signature
requests < pi > to leader. Each community has its own one public key and one private
• Broadcast: Leader collect all the supply/demand mes- key share. The community i signing for market clearing price
sages < pi > for determining the market clearing price through its private key share is as follows:
in this trading cycle. The market clearing price < λ >
will be produced by price scheme. And then leader should λisig = signi (λ, sharei ) (1)
broadcast < λ¿ to all communities. Where sharei denotes the share of private key held by
• Sign: All the communities receive < λ > and then sign community i.
for it by their private keys. Then communities send their For a signature collection {λisig }i∈I and threshold k, when
signature < λisig > to the leader. |i| = k, the signatures is aggregated into a single signature by
• Verify: Leader receives enough signatures < λisig > to method combine(), as follow:
aggregate them into a single signature < λsig >, and then  
broadcasts < λisig > to all communities for verifying. λsig = aggregate λ, {λisig }i∈I (2)
• Confirm: Communities generate their acknowledge char- Where I denotes communities set.
acter < ACK i > by verifying < λisig > in big public All the communities can verify λsig with public key, as
key. Then transmiting their < ACK i > to leader. follow:
• End: Leader receives enough < ACK i >, cerates result = (λ, λsig , P U BKEY ) (3)
consensus ending signal < EN D, λsig >, and broadcasts
< EN D, λsig > to all communities. Every community Fig. 1(B) illustrates the process of threshold signature.

Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY GUWAHATI. Downloaded on November 13,2023 at 06:10:51 UTC from IEEE Xplore. Restrictions apply.
Algorithm 1: Proposed consensus protocol for leader Algorithm 2: Proposed consensus protocol for com-
1 Initialization. stage, Pt , Dt ; munity i
2 while stage = End do 1 Initialization. stage, pi ;
3 while stage == DEM AN D do 2 while stage = EN D do
4 if receive M number of < pi > then 3 while stage == DEM AN D do
5 update Pt and Dt with pi per equation (5 - 4 send < pi > to leader
6); stage ← BROADCAST
6 stage ← BROADCAST ; 5 end
7 end 6 while stage == BROADCAST do
8 end 7 receive λ from leader;
9 while stage == BROADCAST do 8 stage ← Sign;
10 calculate λ based equation (7-11); 9 end
11 broadcast < λ > toallcommunities; 10 while stage == SIGN do
12 stage ← SIGN ; 11 generate signature λisig by sharei and λ based
13 end equation (1);
14 while stage == SIGN do 12 send < λisig > to leader;
15 receive λisig from Mi ; 13 stage ← V ERIF Y ;
16 Sλ ← Sλ ∪ {λisig }; 14 end
17 if receive M number of < λisig > then 15 while stage == V ERIF Y do
18 generate λsig by aggregating Sλ based 16 receive λsig from leader;
equation (2); 17 stage ← CON F IRM
19 stage ← V ERIF Y ; 18 end
20 end 19 while stage == CON F IRM do
21 end 20 generate result by verifying λsig with
22 while stage == V ERIF Y do P U BKEY based equation (3);
23 broadcast < λsig > to all communities; 21 if result == SU CCESS then
24 stage ← CON F IRM 22 send ACK i to leader;
25 end 23 stage ← EN D;
26 while stage == CON F IRM do 24 else
27 if receive M number of ACK i then 25 stage ← DEM AN D;
28 generate EN D; 26 end
29 broadcast < EN D, λsig > to all 27 end
communities ; 28 while stage == END do
30 stage ← EN D; 29 receive EN D, λsig from leader;
31 end 30 save λsig in local ledger;
32 end 31 return
33 end 32 end
33 end

D. Pricing Scheme
At time t, the supply and demand ratio t of microgrid show
Suppose there are N communities in microgrid. At time t, as follow:
nb communities plan to buy energy and ns communities plant Pt
t = (7)
to sell energy. Then nb and ns are constrained as follow: Dt
nb + ns = N (4) The energy price should be inversely proportional to the
ratio of supply and demand t .
And the whole energy demand Dt in the microgrid sum as b
follow: St = (8)
γt +1
 
Dt = dt1 + dt2 + . . . + dtnb , t ∈ [t1 , t2 , . . . , tn ] (5) Suppose that S (0) denotes the energy price that community
sell energy to grid, and B (0) denotes the energy price that
The whole energy supply Pt in the microgrid sum as follow: community buy energy from grid. At time t, the selling price
  at n + 1 iterations is donated as S t (n + 1) and updated by
Pt = pt1 + pt2 + . . . + dtns , t ∈ [t1 , t2 , . . . , tn ] (6)
follow:
Where dti denotes energy demand of community i at time B t (n)
S t (n + 1) = B t (n)−S t (n) (9)
t, and pt denotes energy supply of community i at time t. S t (n) t + 1

Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY GUWAHATI. Downloaded on November 13,2023 at 06:10:51 UTC from IEEE Xplore. Restrictions apply.
TABLE II
C OMMUNICATION COMPLEXITY OF PBFT AND PROPOSED CONSENSUS

Stage Request Pre-prepare Prepare Commit Reply Ttrans (N )


PBFT
Number of communication 1 n n2 n2 n O(n2 )
Stage Broadcast Sign Verify Confirm End Ttrans (N )
Proposed consensus
Number of communication n n n n n O(n)

TABLE III
V ERIFICATION COMPLEXITY OF PBFT AND PROPOSED CONSENSUS

Consensus Number of communities in microgrid Number of verification Tvalid (N )


PBFT n n O(n)
Proposed consensus n 1 O(1)

The buying price at n + 1 iterations donates B t (n + 1), As a traditional consensus protocol, PBFT has been widely
it is updated by follow: used in consortium blockchain, such as Hyperledger Fabric
  and Tendermint. TABLE II illustrates the communication com-
Dt B t (n) = P t S t (n + 1) + Dt − P t B t (n) (10) plexity comparison between PBFT and proposed consensus
  protocol. We can conclude that the communication complexity
B t (n + 1) = S t (n + 1) t + B t (n) 1 − t (11)
of PBFT is O(n2 ), and proposed consensus protocol is O(n).
The iterations will stop when S t (n) = B t (n). So that the It is a great improvement that the communication complexity
market clearing price λ = S t (n) = B (n). of proposed consensus protocol is one order of magnitude
lower than that of PBFT. Fig 2 shows the number of com-
III. E VALUATION munication comparison between two protocols.
This paper focus on the efficiency of consensus protocols.
The measurement of efficiency mainly depends on the com- B. Computation Complexity
munication complexity and message verification complexity of For computation complexity, it is defined as follows:
consensus protocol. 
Tverif y (N ) = Ti (N ) (13)
A. Communication Complexity
i∈I
For communication complexity, it is defined as follows:
 Where I denotes the number of computation.
Ttrans (N ) = Ti (N ) (12) PBFT transmits messages encrypted by asymmetric en-
i∈K cryption, which means that communities have to verify the
messages it receives to ensure that everyone agrees. On the
contrary, proposed consensus encrypts messages by threshold
signature. Leader will combine all the messages signed by
every communities into one single signature, and this signature
could be verified by every communities.

Fig. 2. Number of communication comparison.

Where K denotes the stages of consensus process. N de-


notes the size of problems. The communication complexity
Fig. 3. Number of computation comparison.
of consensus stage Ti (N ) is determined by the number of
communication between each community in the stage.

Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY GUWAHATI. Downloaded on November 13,2023 at 06:10:51 UTC from IEEE Xplore. Restrictions apply.
As TABLE III shows. Suppose that there are n communities ACKNOWLEDGMENT
in the microgrid. As mentioned above, the PBFT will cost This work was supported in part by the National Natural
O(n) computation complexity, but proposed consensus will just Science Foundation of China under Grants, China (61762030),
cost O(1) computation to verify. Fig 3 shows the number of and in part by the Guangxi Natural Science Foundation
computation comparison between two protocols. under Grants, China(2019GXNSFFA245007), Key Research
and Development Program of Guangxi(2021AB06002), Open
C. Task Latency Foundation of Innovation Center for Hebei Intelligent Grid
Distribution Technology.
In order to compare the task delay of PBFT and proposed
consensus protocol, this paper implemented the two protocols R EFERENCES
respectively by using GO language, and simulated multiple [1] Tushar W, Saha T K, Yuen C, et al. Peer-to-peer trading in electricity
market participants in laboratory computer(CPU: 2.7 GHz networks: An overview[J]. IEEE Transactions on Smart Grid, 2020,
dual-core Intel Core i5, memory: 16 GB 1867 MHz DDR3, 11(4): 3185-3200.
[2] TeMiX. 2022, http://temix.com/.
operating system: macOS version 11.6.4) for simulation test. [3] Peer Energy Cloud. 2022, http://software-cluster.org/projects/peer-
The experimental results are shown in Fig 4. energy-cloud/.
[4] Piclo. Building a smarter energy future. 2022,
https://piclo.energy/about/whitepaper/.
[5] Dong Z, Luo F, Liang G. Blockchain: a secure, decentralized, trusted
cyber infrastructure solution for future energy systems[J]. Journal of
Modern Power Systems and Clean Energy, 2018, 6(5): 958-967.
[6] Dong Z, Luo F, Liang G. Blockchain: a secure, decentralized, trusted
cyber infrastructure solution for future energy systems[J]. Journal of
Modern Power Systems and Clean Energy, 2018, 6(5): 958-967.
[7] Saxena S, Farag H, Brookson A, et al. Design and field implementation
of blockchain based renewable energy trading in residential communi-
ties[C]. 2019 2nd international conference on smart grid and renewable
energy (SGRE). IEEE, 2019: 1-6.
[8] Esmat A, de Vos M, Ghiassi-Farrokhfal Y, et al. A novel decentralized
platform for peer-to-peer energy trading market with blockchain tech-
nology[J]. Applied Energy, 2021, 282: 116123.
[9] Yu Y, Guo Y, Min W, et al. Trusted transactions in micro-grid based on
blockchain[J]. Energies, 2019, 12(10): 1952.
[10] Liu S, Chen F, Shen L, et al. A high-performance local energy trading
cyber-physical system based on blockchain technology[C]. IOP Confer-
ence Series: Earth and Environmental Science. IOP Publishing, 2019,
Fig. 4. Task latency comparison. 227(3): 032009.
[11] Shan J, Dong Z, Hu J, et al. P2P Smart Power Trading Contract Based
on Blockchain Technology[J]. Power System Technology, 2021, 45(10):
3830-3839.
[12] Yang J, Paudel A, Gooi H B, et al. A Proof-of-Stake public blockchain
The experimental results show that when the number of based pricing scheme for peer-to-peer energy trading[J]. Applied Energy,
participants is more than 60, the delay of proposed consensus 2021, 298: 117154.
protocol is lower than PBFT. When the number of participants [13] Cheng Y, Hu X, Zhang J. An Improved Scheme of Proof-of-Stake
Consensus Mechanism[C]//2019 4th International Conference on Me-
is 100, the delay of proposed consensus protocol is reduced chanical, Control and Computer Engineering (ICMCCE). IEEE, 2019:
by 12.14% compared with PBFT. 826-8263.
[14] Qin J, Sun W, Li Z, et al. Credit Consensus Mechanism for Microgrid
Blockchain[J]. Automation of Electric Power Systems, 2020, 44(15):
IV. C ONCLUSION 10-18.
[15] Wang D, Wang L. Consensus Mechanism of Multi-energy Interactive
In general, this paper proposes a distributed electricity trad- Subject Based on Practical Byzantine Fault Tolerance Algorithm[J].
Automation of Electric Power Systems, 2019, 43(09): 41-49.
ing market framework based on blockchain, which integrates [16] Chen S, Shen Z, Zhang L, et al. A trusted energy trading framework by
secure and efficient consensus protocol and price mechanism marrying blockchain and optimization[J]. Advances in Applied Energy,
to ensure the fairness of market transactions. Through the 2021, 2: 100029.
[17] Abdella J, Tari Z, Anwar A, et al. An architecture and performance
theoretical analysis of the communication complexity and evaluation of blockchain-based peer-to-peer energy trading[J]. IEEE
computation complexity of consensus protocol, the results Transactions on Smart Grid, 2021, 12(4): 3364-3378.
show that the proposed framework has a significant improve-
ment on efficiency of consensus protocol. Especially when the
number of participants grows rapidly, our framework has more
significant advantages on task latency.
The framework proposed in this paper is a consensus
scenario for energy trading among market participants, and
is also suitable for other tasks. Therefore, the method has
important reference value for the safe and efficient application
of distributed energy system.

Authorized licensed use limited to: INDIAN INSTITUTE OF TECHNOLOGY GUWAHATI. Downloaded on November 13,2023 at 06:10:51 UTC from IEEE Xplore. Restrictions apply.

You might also like