trust-net / dag-lib-go

Go library for DAG protocol
MIT License
3 stars 0 forks source link

Check and initiate double spending resolution on received network transactions #35

Closed gnulib closed 5 years ago

gnulib commented 5 years ago

Objective

A honest node should validate a received network transaction against any previously seen transaction from same submitter and sequence ID, so that double spending situation can be prevented.

Assumption

Acceptance Criteria

As per "A simple double spending resolution protocol" rules described in #30, a honest node should check a received network transaction if it has a sequence number matching another transaction from that submitter already known/recorded by DLT stack, and initiate double spending resolution for such cases as following:

Step 1: Check Current Sequence

Step 2: Check Previous Sequence


Old

gnulib commented 5 years ago

Relaxed Sequence Requirements

Q: When either an unknown ancestor transaction is received (i.e. last submitter seq tx on local node is different from peer's last submitter seq tx), or a double spending transaction is received (i.e. local submitter seq tx is different from peer's submitter seq tx) -- do we need to sync submitter history? What if the two shards are different?
A: Depends! The absolute MUST is that there must not be 2 different transactions with same submitter ID and Seq for same shard. So, if the shard ID for the 2 different transactions are different, we are safe to accept the transactions. This would basically be similar to submitter client maintaining separate sequences for each shard they work with. Our assumption for using a single sequence across all shards is a "stricter" requirement, to help simplify submitter implementation and implicitly provides more than enough protection.

This is being called relaxed sequence requirement

Do we really need to relax?

The only reason we are considering relaxation is to resolve a specific condition when:

With above condition, its non-deterministic to resolve the situation, since two transactions are intended for different shards. There is no good way to sync the two peers, since different shards are impacted. However, due to the fact that "resource visibility is shard specific", this situation does not results in double spending, since transactions cannot update same resource. Therefore, it is safe to let the transaction go through without requiring any of the shard to be flushed/re-synced.

Situation is resolvable when shard ID of the two transactions submitted across network is same. Since both transactions occur on same shard, it has double spending situation (both transactions can update same resource). Therefore, in this case when peers exchange the transactions a sync can be done deterministically for that single shard.

Impact of relaxed sequence requirement to Tx submission

Q: Is is possible to determine with accuracy whether a node accepted multiple transactions from a submitter for same seq?
A: We can check the "node id" in Tx anchor to determine whether same node accepted two different transaction from submitter for same seq across different shards.

Q: If we relax our sequence requirement, then why should we require the DLT stack to still check for uniqueness of submitter seq across all shards?
A: With relaxed requirement, it may not be necessary anymore to require DLT stack to impose uniqueness constraint across all shards. A node may choose to impose uniqueness for specific shard only. If in future we extend DLT stack to support multiple app registrations simultaneously, then it will be desirable for have node only enforce uniqueness within specific shard.

gnulib commented 5 years ago

Relax sequence check at endorser

Endorsement layer need to relax the sequence history check as following:

Relaxed requirements state that there must not be any 2 different (shard id: tx id) for same submitter/seq.

gnulib commented 5 years ago

Endorser validation for submitter's sequence

Following is the final logic for validating a requested anchor, submitted transaction's anchor, or network transaction's anchor:

gnulib commented 5 years ago

Endorsement layer checks implemented for submitter sequence validation and report SUCCESS / ORPHAN / DOUBLE SPEND