Research Article

Efficient Concurrent Execution of Smart Contracts in Blockchain Sharding

Algorithm 1

A Variable Shadow Speculative Concurrency Control (SCC-VS).
(A) Start Rule : When the execution of a new transaction is requested, create and execution an Optimistic shadow ;
(1)  Compute the number of shadows ;
(2)  Pessimistic Shadows () ← 0;
(3)  ReadSet () ← φ;
(4)  WriteSet () ← φ;
(B) Read Rule : Whenever a transaction wishes to read object X, a conflict may be found out, then
(1)  ReadSet () ← {X};
(2)  if (Pessimistic Shadows () < N() − 1) then {
(2.1)   Fork a new pessimistic shadow ;
(2.2)    WaitFor () ← {(), X};
(2.3)     Pessimistic Shadow () ← Pessimistic Shadow () + 1};
(2.4)   else if (Pessimistic Shadows () ≮ N() − 1) then{Abort ()};
(C) Write Rule : Whenever a transaction wishes to write object X, a conflict may be found out, then
(1)  WriteSet () ← {X};
(2)  if (Pessimistic Shadows () < N() − 1) then{
(2.1)   Fork a new pessimistic shadow ;
(2.1.1)    WaitFor () ← {(), X};
(2.1.2)     Pessimistic Shadow () ← Pessimistic Shadow(() + 1};
(2.2)   else if (existence conflict) then {
(2.2.1)     Abort the shadow and replace it by a new shadow ;
(2.2.2)     WaitFor () ← {(), X};
(3)  else if (Pessimistic Shadows () = N() − 1) then {Abort };
(D) Blocking Rule : Block a pessimistic shadow at the earliest point at which it wishes to read on object X
(E) Commit Rule: whenever it is decided to commit an optimistic shadow on behalf of a transaction , then
(1)  Abort other pessimistic shadows except ;
(2)  Deal with everything that conflicts with ;