Skip to content

[Feature] - Atomic Transaction #1304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open

[Feature] - Atomic Transaction #1304

wants to merge 21 commits into from

Conversation

astaphobia
Copy link
Contributor

@astaphobia astaphobia commented Oct 21, 2020

Description

Atomic Transaction, new transaction type, allowing to post bulk transactions in single wrapper called AtomicTransaction.

type AtomicTransactionBody struct {
	// UnsignedTransactionBytes is collection of unsigned transaction bytes
	UnsignedTransactionBytes [][]byte 
	// Signatures is <addressHex, Signature>
	Signatures           map[string][]byte 
}

Similiar with MultiSignatureTransaction, the different part is AtomicTransaction only offchain flow.

Now Transaction have ChildType indicating that transaction is a non child transaction or not.

enum TransactionChildType {
    NoneChild = 0;
    MultiSignatureChild = 1;
    AtomicChild = 2;
}

And the last added now schema for atomic and also new table called atomic_transaction. It will manually stored records when TransactionType.AtomicTransaction applying confirmed happened.

message Atomic {
    int64 ID = 1;
    // TransactionID is reference transaction.id which is the wrapper
    int64 TransactionID =2;
    bytes SenderAddress = 3;
    uint32 BlockHeight = 4;
    bytes UnsignedTransaction = 5;
    bytes Signature = 6;
    uint32 AtomicIndex = 7;
}

Breakdown

  • Implemented AtomicTransaction
  • New sub transaction command called atomic
  • Fix bug cmd generate transaction with seed
  • Migration and model for explorer folk
  • Rollback
  • Snapshot
  • Unit test
  • Update wiki

Reference Issue

Close #1309

Reference PR

zoobc/zoobc-schema#168

Step to Test (optional)

  • step 1
  • step 2
  • step 3

@astaphobia astaphobia self-assigned this Oct 21, 2020
@astaphobia astaphobia added CMD command line tool feature EXPERIMENT FEATURE New feature or request labels Oct 21, 2020
@astaphobia astaphobia marked this pull request as ready for review October 22, 2020 00:23
@astaphobia astaphobia added WIP REQUIRE_RESET require changes that are not backward compatible, blockchain reset needed CORE core functionalities labels Oct 22, 2020
@abiman7u abiman7u added this to the V.0.0.2.W.02 milestone Nov 12, 2020
@@ -298,7 +298,7 @@ func (m *Migration) Init() error {
`,
`
ALTER TABLE "transaction"
ADD COLUMN "multisig_child" INTEGER DEFAULT 0
ADD COLUMN "child_type" INTEGER DEFAULT 0 -- indicate transaction has a child of transaction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should indicates transaction is a child instead of has a child

func (tq *TransactionQuery) GetTransactionsByBlockID(blockID int64) (str string, args []interface{}) {
query := fmt.Sprintf("SELECT %s FROM %s WHERE block_id = ? AND multisig_child = false "+
query := fmt.Sprintf("SELECT %s FROM %s WHERE block_id = ? AND child_type = 0 "+
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have constant for child_type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not contant actually, its as enum proto message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah better to use enum instead, on it :)

@@ -88,7 +111,7 @@ func (tq *TransactionQuery) GetTransactionsByIds(txIds []int64) (str string, arg
args = append(args, id)
}
return fmt.Sprintf(
"SELECT %s FROM %s WHERE multisig_child = false AND id IN(?%s)",
"SELECT %s FROM %s WHERE child_type = 0 AND id IN(?%s)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

child_type here should be using constant right?

@astaphobia astaphobia changed the base branch from experimental to develop November 23, 2020 00:48
@astaphobia astaphobia linked an issue Nov 25, 2020 that may be closed by this pull request
@astaphobia astaphobia changed the title Atomic Transaction [Feature] - Atomic Transaction Nov 30, 2020
@iltoga iltoga requested a review from bzpython as a code owner January 6, 2021 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMD command line tool feature CORE core functionalities EXPERIMENT FEATURE New feature or request postponed REQUIRE_RESET require changes that are not backward compatible, blockchain reset needed WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tech: Atomic Transaction
6 participants