trust-net / dag-lib-go

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

Test driver to show double spending submission #36

Closed gnulib closed 5 years ago

gnulib commented 5 years ago

Objective

Write a test driver that can attempt to submit double spending transaction, either on same node, or on two different nodes across the network, so that I can validate the double spending resolution protocol described in #30

Acceptance Criteria

Test driver should provide following capabilities:

Assumption

gnulib commented 5 years ago

Application Shard Specs

We'll run the test driver application on the shared trust-net network, where all other application (e.g. network counter) are running. This test driver application will register with DLT stack using following specs:

Application Transactions

Test driver will implement "ops" that will be submitted via transaction and processed by the application's registered transaction handlers. Following Ops specs will be used to submit as serialized and signed payload:

type Ops struct {
  // op code
  Code uint64
  // serialized arguments
  Args []byte
}

In above structure, application will define a unique value for Code for each specific operation defined below. Also, application will define a corresponding structure of arguments that will be stored as a serialized blob with Args.

Transaction Ops

Resource Creation Op

Driver will provide CLI to create a resource with initial value:

CLI> create <resource name> <initial value>

Above command will submit an Ops with following values:

Code value

0x01

Args structure

type ArgsCreate struct {
  // resource name
  Name string
  // initial value
  Value  int64
}

Rules of processing

Value Transfer Op

Driver will provide CLI to transfer value from owned resource to another resource:

CLI> xfer <owned resource name> <xfer value> <recipient resource name>

Above command will submit an Ops with following values:

Code value

0x02

Args structure

type ArgsXfer struct {
  // xfer source name
  Source string
  // xfer destination name
  Destination string
  // xfer value
  Value  int64
}

Rules of processing

gnulib commented 5 years ago

Local Double Spending Transactions

Shard Sibling Double Spend

Test driver will implement a new CLI command that can be used to submit two double spending transactions as following:

CLI> dupe <owned resource name> <xfer value> <recipient 1 resource name> <recipient 2 resource name>

Above command will submit 2 value transfer transactions with two Anchors from same tip (i.e., same shard seq) using the same submitter seq on both anchors.

Shard Descendent Double Spend

Test driver will implement a new CLI command that can be used to submit two double spending transactions as following:

CLI> double <owned resource name> <xfer value> <recipient 1 resource name> <recipient 2 resource name>

Above command will submit 2 value transfer transactions in succession (i.e., sequential shard seq) using the same submitter seq on both anchors.

gnulib commented 5 years ago

Remote Double Spending Transactions

Submitting remote double spending transactions

In order to submit double spending transactions across different nodes, we'll extend the test driver application to instantiate multiple DLT stacks listening on different ports. This way the CLI can submit transactions to those different instances of the stack, each of which is effectively a separate node.

Cross Submit Transaction

Test driver will implement a new CLI command that can be used to submit a transaction that has anchor from one node, but is submitted to another nodeas following:

CLI> xover <owned resource name> <xfer value> <recipient resource name>

Above command will get anchor from first node, but sumit transaction to second node, which should fail due to anchor signature validation.

Multiple Node Submission

Test driver will implement a new CLI command that can be used to submit a redundant transactions on two different nodes, so that even if one fails there is a redundancy and another submission passes.

CLI> multi <owned resource name> <xfer value> <recipient resource name>

Above command will submit same value transfer operation using 2 different transactions in parallel to two different nodes using the same submitter seq, using the anchors fetched from respective nodes. Network should only accept 1 of the two transactions, while the other transaction should be rejected as double spending.

Split Shard Submission

Test driver will implement a new CLI command that can be used to submit two double spending transactions on two different nodes to transfer same value to different recipients. Goal is to try and split the shard across network by submitting conflicting/double spending transaction on different nodes.

CLI> usage: split <owned resource name> <xfer value> <recipient 1> <recipient 2>

Above command will submit 2 different value transfer operations as 2 separate transactions in parallel to two different nodes using the same submitter seq, using the anchors fetched from respective nodes. Network should eventually detect this double spending attempt and consistently converge on only one of the value transfer operation while rejecting the other operation on all nodes. World state on all nodes should show consistent and correct values for all recipients.