GithubHelp home page GithubHelp logo

quantadex / distributed_quanta_bridge Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 34.32 MB

The distributed version of the quanta bridge

Go 89.50% Shell 0.30% HTML 0.47% JavaScript 6.24% Makefile 0.12% Dockerfile 0.18% Solidity 3.20%

distributed_quanta_bridge's People

Contributors

coderfi avatar quocble avatar sergey-zee avatar shahpoo415 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

distributed_quanta_bridge's Issues

Reduce 3 nodes to 1 node

Reduce costs of 3 test nodes to 1 test node.

Run ---

3x crosschain_eth, crosschain, crosschain_btc, crosschain_bch, crosschain_ltc

Share 1 set of
ltc, btc, bch

Withdrawal manual pending

Introduce a variable in the config where we can restart the service to stop all withdrawal, but still enable deposits, and manual pending.

mode string

auto - current system where all withdrawals are automatically sent
manual - new status for withdrawal where we can manually audit and flag for consensus

Devise stress test for address generation

I have implemented the new address generation. Read the code first.

Some edge cases you may notice:

  • Automatic repair - 2/3 nodes accept forces (when 2 nodes have same data but 3rd node does not, the 3rd node to repair
  • Duplicate transaction consecutively.
  • Error of address generation of on node that already been processed previously.

Let's devise stress test that mimic live production environment to make sure it works properly.

  • Generate for 100 accounts over period of 2 minutes
  • Mimic variation timing (parallel requests)
  • Simulate failures, such as 1 node going down & expecting repairs

Monitoring

Motivation

There has been a number of incidents where deposits and withdrawals were delayed.... often due to : configuration, versioning issues, out of disk, code error (like SQL insert), and so forth.

Design

How can we build features within /api/status returning
200 - OK
503 - Service Unavailable
504 - Service Degraded

What should we track?

  • Each Coin Top Block and its relative positioning to its peer / thresholds should be configurable OR take look at blocktimestamp and look at age.
  • Age of consensus status' -- means these failed consensus.
  • Track the # of failed consensus

What does it mean to be in degraded?

What does it mean to be unavailable?

type BlockchainStatus {
   CurrentBlock int
  TimeSinceLastBlock int  // sec
  DegradedThreshold int //
  FailureThreshold int //
  TotalAddresses int 
  AddressesCreated24H int
  State: Normal | Degraded | Failure
}

type DepositStatus {
  ConsensusRetries: N,
  DegradedThreshold: N,
  FailureThreshold: N
}

type WithdrawalStatus {
  ConsensusRetries: N,
  DegradedThreshold: N,
  FailureThreshold: N
}

/api/status
{
  "BuildTime": "",
  "GitHash": "",
  "ListenIP": "192.168.137.186",
  "PublicKey": "QA6nkaBAz1vV6cb25vSHXJqHos1AeADzqRAXPvtASXMAhM3SbRFA",
  "Version": "1.0",
  "BTC": {
  },
  "BCH": {
  }
  "Deposit: {
  }
  "Withdrawal": {
  },
  TotalDegraded: N,
  TotalFailures: N
}

Returns 504 code when in Degraded state, totalDegraded > 0
Returns 503 code when in Failure state, totalFailure > 0
Return 200 when both are 0

Links

  1. https://stackoverflow.com/questions/53985294/what-should-the-http-status-code-of-a-degraded-health-check-be

can't generate pooled addresses

steps to reproduce:

  1. run a 2 node network
  2. generate an ethereum address

result: crosschain table in node 1 is updated but not in node2
expect: both tables to update the value.

Notes: The addressconsensus is responsible for validating, and "persisting" on the database when this is agreed. not sure where is going wrong.

We should have assertion on these table changes to make sure this is working properly.

Deposit does not work when a node is stopped and restarted again. (leader node)

Run 3 nodes
Submit Transaction
Stop one node
Submit Transaction
Restart the node


2018/11/30 12:17:46 I [5000] Start new round 0x5018c9cedfcfbeb0ce71f65ab361d205bad3a179533320f7468cbd55bc078d7c ETH to=QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV amount=700000
Propose TX:  ETH QDFLBGRMXEDTLI2LBYQTF7ZX4LPGOWIBN2UDQOZW6VH47LNEX5MEXBST 0.0700000 QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV
2018/11/30 12:17:47 I [cosi] Start new round leader=true nodes=3 threshold=3
2018/11/30 12:17:47 I [cosi] Got commitment 2/3
2018/11/30 12:17:47 I [cosi] Got commitment 3/3
2018/11/30 12:17:47 I [cosi] Got total of 3 commitments, moving forward
2018/11/30 12:17:47 I [5000] Sign msg wGGc8QAAAECWCuxCB7TutpkmUGqfKUA0ib4MH7g27vf+PADbamAEeM0G6ePVNn01DNZReto9dF/D0D5HP0FdzeEv7fqDHoYD
2018/11/30 12:17:47 I [cosi] Got signature 2/3
2018/11/30 12:17:47 I [cosi] Got signature 3/3
2018/11/30 12:17:47 I [5000] Great! Cosi successfully signed deposit
2018/11/30 12:17:47 E [5000] processSubmissions pending=1
2018/11/30 12:17:47 I [5000] Submit TX: 0x5018c9cedfcfbeb0ce71f65ab361d205bad3a179533320f7468cbd55bc078d7c signed=true AAAAAMqwmiy5BzWjSw4hMv834t5nWQFuqDg7NvVPz62kv1hLAAAAZAAPDxkAAAAuAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAQ2ngI+8T11/xdvUwln/vdfFmE79ZOmNe+f6ukF88UUYAAAABRVRIAAAAAADKsJosuQc1o0sOITL/N+LeZ1kBbqg4Ozb1T8+tpL9YSwAAAAAACq5gAAAAAAAAAAPAYZzxAAAAQJYK7EIHtO62mSZQap8pQDSJvgwfuDbu9/48ANtqYAR4zQbp49U2fTUM1lF62j10X8PQPkc/QV3N4S/t+oMehgOnC6puAAAAQCuERUFYwLFiVCTtyIJgTQ5lxcKkUQ9OogmGC+nI4ArnNGHhl1FuKcbVDWcSiQRj3gJZ8A0YmIVJ9JNHPKWMEQkWQn5KAAAAQHpU/EZxxuSt++Syi5IB3dNHs0t3N+FOVQhGSqTL57lhTPiIF2VxsvMRqpnHd9j/4NWhzGM51pn6ALAUwnzSQAk=
2018/11/30 12:17:48 D [5000] Coin2Quanta: No new block last=8226 top=8226
2018/11/30 12:17:48 I [5000] ***** Start # of blocks=0 man.N=3,man.Q=3 *** 
2018/11/30 12:17:48 I [5000] QuantaToCoin refunds []
2018/11/30 12:17:48 I [5000] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 12:17:50 I [5000] Successful tx submission 90bc6ce85b31eedcb6a96c9263cf31ac6655a5e8f45efa45753121230526a087,remove %!s(int=0)


Stopping Node1 (Leader node, Registry Node)

Node2 Log

2018/11/30 12:18:16 I [5001] Block 8228 Got deposits 1 [0xc0004c93b0]
2018/11/30 12:18:16 I [5001] set last block coin=ETH height=8228
2018/11/30 12:18:16 I [5001] QuantaToCoin refunds []
2018/11/30 12:18:16 I [5001] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 12:18:19 D [5001] Coin2Quanta: No new block last=8228 top=8228
2018/11/30 12:18:19 I [5001] ***** Start # of blocks=0 man.N=3,man.Q=3 *** 
2018/11/30 12:18:19 I [5001] QuantaToCoin refunds []
2018/11/30 12:18:19 I [5001] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 12:18:22 D [5001] Coin2Quanta: No new block last=8228 top=8228


Node3 Log

2018/11/30 12:18:16 I [5002] Block 8228 Got deposits 1 [0xc0003dbc00]
2018/11/30 12:18:16 I [5002] set last block coin=ETH height=8228
2018/11/30 12:18:16 I [5002] QuantaToCoin refunds []
2018/11/30 12:18:16 I [5002] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 12:18:19 D [5002] Coin2Quanta: No new block last=8228 top=8228
2018/11/30 12:18:19 I [5002] ***** Start # of blocks=0 man.N=3,man.Q=3 *** 
2018/11/30 12:18:19 I [5002] QuantaToCoin refunds []
2018/11/30 12:18:19 I [5002] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 12:18:22 D [5002] Coin2Quanta: No new block last=8228 top=8228


Restarted Node1

2018/11/30 12:18:51 I [registrar] Server will be started at :5100...
postgres://postgres:@localhost/crosschain_1
2018/11/30 12:18:51 I [5000] Initialize ledger
2018/11/30 12:18:51 I [registrar] Node 0.0.0.0:5000 added to registry
2018/11/30 12:18:51 I [5000] REST API started at :0...```

Confirm blocks, to prevent orphaned blocks scenarios

Motivation

We need to check the # of confirmations before we issue assets. It must meet 3 general requirements:

  1. Provide user the most recent information
  2. Robust enough to handle change of block hash, and top block
  3. Safely handle minimum confirmations

https://testnet.litecore.io/block/1d098a4dfc4f45aa6b637394add9551c0ea6ac5c6c8a43a196cc515208ff4de6
https://www.blockchain.com/btc/orphaned-blocks

Tech design

Introduce configurations: EthereumMinConfirm, BtcMinConfirm, LtcMinConfirm

State transitions:
-->[Pending]-->[Wait_for_Confirm]---->[Consensus]--->[Success]

Pending state is optional, and supported by BTC. Other chains go straight to wait for confirm

At wait_for_confirm, record blockhash for all ETH, LTC, and BTC
Every update API now needs to pass in 3 piece of unique information, Type, TX, BlockHash

At the begin of the block update:

BTC, LTC, BCH

find_and_confirms:

  For all wait_for_confirm tx's
   Lookup blocks with getBlock(blockhash)
   confirm = top_block - block_number
   if block_number == = -1
       mark tx as "orphan"
   else if confirms > min_block_confirm   (configure for each blockchain)
       mark tx as "consensus"
   else
       println("tx has x ", confirms)
func FindAndConfirm(tx db.Transaction, data GetBlockVerboseResult):
   Lookup blocks with getBlock(blockhash)
   confirm = top_block - block_number
   if block_number == = -1
       mark tx as "orphan"
   else if confirms > min_block_confirm   (configure for each blockchain)
       mark tx as "consensus"
   else
       println("tx has x ", confirms)

func FindAllAndConfirm():
    for tx in all confirm:
        data = getBlock(tx.blockHash)
        FindAndConfirm(tx, data)

ETH

For all wait_for_confirm tx's
   latest <- Lookup blocks with getTransaction(txhash)
  Get all tx for <deposit,txhash>
   
   for all txs found in db:
       if tx.blockhash ==   latest.blockhash
           confirm = top_block - latest.block_number
           if confirms > min_block_confirm   (configure for each blockchain)
                mark tx as "consensus"
          else
               println("tx has x ", confirms)
       else:
              // blockhash changed on the transaction, this one is now an orphan 
             println("blockhash is different for this tx=tx, it is now an orphan) 
             mark tx as "orphan"

Useful debug

truffle console --network mainnet
truffle(mainnet)> web3.eth.getTransaction(tx,(err,msg) => console.log(err,msg))

Links

  1. LTC orphans https://chainz.cryptoid.info/ltc/orphans.dws
  2. BTC orphans https://www.blockchain.com/btc/orphaned-blocks
  3. ETH uncles https://etherscan.io/uncles

Deploy LTC, BCH to testnet

Deploying testnet will provide us a safe environment to perform integration testing with the existing setup and help us prepare for mainnet deployment

  • Add litecoin_sync cli, and add to docker configuration
  • Add litecoin configurations in node_test.go , and create a similar test like BTC in trust
  • Back up settings before start (secrets folder, and database) (Quoc)
  • generate 3 new litecoin signing keys for testnet
  • Add "litecoin" configuration in docker-compose. Avoid doing docker-compose up or down
    without the "litecoin" because this will take down all the other containers such as ETH or BTC
  • Add a "crosschain_ltc" instance to monitor for LTC deposit
  • Add a default litecoin configuration in secrets, and bind that to volume to the crosschain_ltc instance, and the crosschain1 instance
  • Add secrets configuration at the end of secrets/crosschain.yml
  • tag litecoin 0.16 docker image ( docker tag litecoin-core quantalabs/litecoin-core:latest )
  • push docker push quantalabs/litecoin-core:latest
  • restart crosschain_ltc to see if connections work. (pull image as neccessary)
  • once that works, repeat for the other 2 nodes
  • restart crosschain_1 on all 3 nodes
  • make a deposit
  • make a withdrawal , monitor logs as neccessary

Crosschain node was down

A node was discovered to be in a stale broken state.

crosschain1_1     | 2019/04/01 20:31:15 E [cosi] Unable to validate transactions: %!(EXTRA string=connection is shut down)
crosschain1_1     | 2019/04/01 20:31:16 E [5000] Failed to get current top block
crosschain1_1     | 2019/04/01 20:31:19 E [5000] Failed to get current top block
crosschain1_1     | 2019/04/01 20:31:22 E [5000] Failed to get current top block
crosschain1_1     | 2019/04/01 20:31:22 I [cosi] Initialize cosi state.
crosschain1_1     | 2019/04/01 20:31:22 E [5000] Unable to decode quanta tx
crosschain1_1     | 2019/04/01 20:31:22 E [cosi] Unable to validate transactions: %!(EXTRA string=connection is shut down)
crosschain1_1     | 2019/04/01 20:31:25 E [5000] Failed to get current top block
crosschain1_1     | 2019/04/01 20:31:28 E [5000] Failed to get current top block
crosschain1_1     | 2019/04/01 20:31:29 I [cosi] Initialize cosi state.
crosschain1_1     | 2019/04/01 20:31:29 E [5000] Unable to decode quanta tx
crosschain1_1     | 2019/04/01 20:31:29 E [cosi] Unable to validate transactions: %!(EXTRA string=connection is shut down)

How can we prevent this? And we should think about how to monitor this.

consensus fail when connection with quanta is terminated

2019/03/08 01:19:24 E [5000] Failed to get current top block
2019/03/08 01:19:27 E [5000] Failed to get current top block
2019/03/08 01:19:30 E [5000] Failed to get current top block
2019/03/08 01:19:32 E [5000] connection is shut down
2019/03/08 01:19:32 I [5000] Start new round 58a52bc745280c9067c699fe3eebc10d1a659bd1226dad63885f7e6560d36804_1 BTC to=quanta amount=1000 type =0
2019/03/08 01:19:32 E [5000] Failed to encode refund 1connection is shut down
2019/03/08 01:19:32 E [5000] failed to create asset, error = connection is shut down
2019/03/08 01:19:33 E [5000] Failed to get current top block
2019/03/08 01:19:36 E [5000] Failed to get current top block
2019/03/08 01:19:39 E [5000] Failed to get current top block
2019/03/08 01:19:42 E [5000] Failed to get current top block
2019/03/08 01:19:45 E [5000] Failed to get current top block

production error

root@crosschain1:containers # docker-compose logs -f --tail 100 crosschain1
Attaching to containers_crosschain1_1
crosschain1_1     | 2019/04/20 00:16:35 I [registrar] Server will be started at :5100...
crosschain1_1     | Log level not parsed
crosschain1_1     | postgres://postgres:Welcome123@db/crosschain_1
crosschain1_1     | 2019/04/20 00:16:48 I [5000] Initialize ledger
crosschain1_1     | panic: -28: Rescanning...
crosschain1_1     |
crosschain1_1     | goroutine 1 [running]:
crosschain1_1     | main.initNode(0x1389, 0xc42051f4c0, 0xc, 0x1388, 0x1, 0xc42051f520, 0xd, 0xc420096fc0, 0x2e, 0xc420594810, ...)
crosschain1_1     | 	/opt/bitnami/apps/jenkins/jenkins_home/workspace/distributed_quanta_bridge/src/github.com/quantadex/distributed_quanta_bridge/node/trust_node.go:225 +0x1695
crosschain1_1     | main.bootstrapNode(0x1389, 0xc42051f4c0, 0xc, 0x1388, 0x1, 0xc42051f520, 0xd, 0xc420096fc0, 0x2e, 0xc420594810, ...)
crosschain1_1     | 	/opt/bitnami/apps/jenkins/jenkins_home/workspace/distributed_quanta_bridge/src/github.com/quantadex/distributed_quanta_bridge/node/trust_node.go:470 +0xbb
crosschain1_1     | main.main()
crosschain1_1     | 	/opt/bitnami/apps/jenkins/jenkins_home/workspace/distributed_quanta_bridge/src/github.com/quantadex/distributed_quanta_bridge/node/main.go:68 +0x522
containers_crosschain1_1 exited with code 2

Add SubmitConfirm_block, and TxId to database

Once transaction has been submitted, we need to track block # it was submitted to.

On deposit, record the block number on QUANTA
on Withdrawal, record the block number on external blockchain

Add 1 more column called SubmitTxHash to store, the ethereum tx hash for withdrawal, and the "blocknum_tx" for the deposit.

crash on production, trying to reconnect

crosschain1_1     | 2019/04/16 01:41:42 I [5000] Trying to reconnect to Quanta
crosschain1_1     | 2019/04/16 01:41:42 E [5000] websocket.Dial ws://mainnet-api.quantachain.io:8090: dial tcp 34.218.12.133:8090: connect: connection refused
crosschain1_1     | 2019/04/16 01:41:47 I [5000] Trying to reconnect to Quanta
crosschain1_1     | 2019/04/16 01:41:47 E [5000] websocket.Dial ws://mainnet-api.quantachain.io:8090: dial tcp 34.218.12.133:8090: connect: connection refused
crosschain1_1     | 2019/04/16 01:41:53 I [5000] Trying to reconnect to Quanta
crosschain1_1     | 2019/04/16 01:41:53 E [5000] websocket.Dial ws://mainnet-api.quantachain.io:8090: dial tcp 34.218.12.133:8090: connect: connection refused
crosschain1_1     | 2019/04/16 01:41:58 I [5000] Trying to reconnect to Quanta
crosschain1_1     | 2019/04/16 01:41:58 E [5000] websocket.Dial ws://mainnet-api.quantachain.io:8090: dial tcp 34.218.12.133:8090: connect: connection refused
crosschain1_1     | panic: runtime error: invalid memory address or nil pointer dereference
crosschain1_1     | [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xa10c6b]
crosschain1_1     |
crosschain1_1     | goroutine 1 [running]:
crosschain1_1     | github.com/quantadex/distributed_quanta_bridge/trust/quanta.(*QuantaGraphene).Reconnect.func1(0x8, 0xb6d801, 0xeed5c0, 0xc42043d500)
crosschain1_1     | 	/opt/bitnami/apps/jenkins/jenkins_home/workspace/distributed_quanta_bridge/src/github.com/quantadex/distributed_quanta_bridge/trust/quanta/quanta_graphene.go:76 +0xdb
crosschain1_1     | github.com/quantadex/distributed_quanta_bridge/vendor/gopkg.in/matryer/try%2ev1.Do(0xc420a91bf8, 0xc420c34b00, 0xc420358be0)
crosschain1_1     | 	/opt/bitnami/apps/jenkins/jenkins_home/workspace/distributed_quanta_bridge/src/github.com/quantadex/distributed_quanta_bridge/vendor/gopkg.in/matryer/try.v1/try.go:20 +0x39
crosschain1_1     | github.com/quantadex/distributed_quanta_bridge/trust/quanta.(*QuantaGraphene).Reconnect(0xc4202e5260)
crosschain1_1     | 	/opt/bitnami/apps/jenkins/jenkins_home/workspace/distributed_quanta_bridge/src/github.com/quantadex/distributed_quanta_bridge/trust/quanta/quanta_graphene.go:68 +0x41

Validate address before we generate them.

Currently we don't check user's address.. This is not good because users can spam for accounts that don't exist, flooding our database.

Check the quanta address against Quanta graphene client.

You may introduce a flag to turn it off for stress testing so you can use any account you want.

Feature request: Get ETH crosschain address easier

Motivation

Most users don't have metamask so they can't create an ethereum address, let's make it easier for them. This is the stats showing them click on disabled button.

image

Scope

Retain the old functionality of forwarding contract which is more secure, while supporting this new feature.

Design

Using Bip32, we can generate many public private key pairs using a single secret using derivation path.

GenerateBip32Key(bip32secret, index)
cc6841e

Let's use the user's account ID 1.2.X (X = accountID) as the index.

We will generate this and add the public key to the generated address.

On receiving of the funds, we detect whether the address is smart contract by looking for an code.
https://ethereum.stackexchange.com/questions/28521/how-to-detect-if-an-address-is-a-contract

Then flush all the coins to the trust contract.

To flush from account, we have to look at the account balance, transfer the funds, signed with the key that we generated. The amount + fee should be precisely equal to the balance.

This is the javascript/webjs equivalent:

    const privateKey = ""
    const gas = web3.toWei("1", "gwei")

    web3.eth.getBalance(acc, (err, balance) => {
        console.log("balance", balance)
        const amount = balance - gas
        var raw = {
            "from": acc,
            "to": mainAcc,
            "value": web3.toHex(amount),
            "gas": web3.toHex(gas),
            "chainId": 1
        };

        web3.eth.accounts.signTransaction(raw, (e,x)=>{}).then(signed=>{
            console.log(raw, signed)

            callback()
        })

    });

Conforming to interfaces:

Use GenerateMultisig interface to generate the address

Use FlushCoin(forwarder string, address string) error to flush the coins (and detecting smart contract or not)

Links

  1. https://goethereumbook.org/transfer-eth/

Notify deposit/withdrawal

Motivation

We need to let users know when the deposit has come in because it is an asynchronous behavior. Letting them know in timing manner, they can take action like trading, and build trust with the user.

Design

We'll design it as a [ Source ] -->[Process]-> [Sink] model so it decouples with the crosschain itself.

http://faculty.babson.edu/dewire/Readings/dfddiag.htm
https://en.wikipedia.org/wiki/Webhook
https://robinhood.engineering/thorn-easy-webhooks-for-python-82a78e170bdb
https://stripe.com/docs/webhooks
https://developer.paypal.com/docs/api/webhooks/v1/#webhooks_post

The source in this case is the rest api to get the history. /api/history

The process is the code that that tracks whether it needs to send the notifications.

The sink is the location where the data is being sent to. Email is the primary sink, but we need to support push notification as well if the user uses the app. Telegram might be a good alternative way the user as well.

Pseudocode

call rest api at last_cursor
loop through data {
   check if deposit/withdrawal was previously sent
   if not sent {
       send to each sink.
       catch error properly so that this loop this not break.
       throw exception if it's fatal such as connection failure to the sinks api.
       mark the tx as sent. (type, tx, blockhash)
   }
}

The application is stateless. States information such as cursor & history data must be stored in a remote database. We can use dynamodb or postgres for this purpose.

Retry logic

https://stripe.com/docs/webhooks/best-practices#events-and-retries

Email API

Refer to SES email credentials

Push notification API

Refer to Android push notification API.
Requires a push registration API.

Operations

This is to be run every 5 minutes as a job. Make this flexible so that it can be deployed on Lambda scheduled services.

Definitions:

RequestMsg {
    url    string
    events []eventType
}

ResponseMsg {
    id     string
    url    string
    events []eventType
    links  []linkDescription
}

eventType {
    name        string
    description string
}

linkDescription {
    href   string
    rel    string
    method string
}
    
events - Deposit.Pending
       - Deposit.Wait_For_Confirmation
       - Deposit.Confirmed
       - Deposit.Failed

       - Withdrawal.Added_To_Queue
       - Withdrawal.In_Consensus
       - Withdrawal.Submitted
       - Withdrawal.Failed
       - Withdrawal.Confirmed

webhooks {
    id string
    url string
    events []eventType
    links []linkDescription
}

Deploy to Mainnet

Deploying testnet will provide us a safe environment to perform integration testing with the existing setup and help us prepare for mainnet deployment

  • Add litecoin configurations in node_test.go , and create a similar test like BTC in trust
  • Back up settings before start (secrets folder, and database) (Quoc)
  • generate 3 new litecoin signing keys for testnet
  • Add "litecoin" configuration in docker-compose. Avoid doing docker-compose up or down
    without the "litecoin" because this will take down all the other containers such as ETH or BTC
  • Add a "crosschain_ltc" instance to monitor for LTC deposit
  • Add a default litecoin configuration in secrets, and bind that to volume to the crosschain_ltc instance, and the crosschain1 instance
  • Add secrets configuration at the end of secrets/crosschain.yml
  • restart crosschain_ltc to see if connections work. (pull image as neccessary)
  • once that works, repeat for the other 2 nodes
  • restart crosschain_1 on all 3 nodes
  • make a deposit
  • make a withdrawal , monitor logs as neccessary

pending tx api

Bitcoin transaction can take a long time to process and we should let the user know that it's pending.

let's merge a pending record in the /api/history call by getting the Bitcoin pending tx from the listunspent with zero confirm and max zero confirm.

See skeleton code.

litecoin stuck after getting tx

crosschain_ltc_1  | 2019/04/28 05:43:47 I [5000] Coin2Quanta: Got blocks [1622178]
crosschain_ltc_1  | events = [{"Tx":"42c328e8b7868bc211114bc5ecb65ce1dbd17454a6c02ef0f1ea0a5f7a4fbcf6","Type":0,"CoinName":"LTC","SenderAddr":"MBR7SYc1QCCm2X3KzUwmyMqR7UFaUQnm2x","QuantaAddr":"airdropuser-179760","Amount":71232200,"BlockID":1622178,"Signatures":null,"BlockHash":"7aa08ce741d54434b7fca03150d10981c712559bf367b488b9eefc6613f3216a"}]
crosschain_ltc_1  | events = [{"Tx":"42c328e8b7868bc211114bc5ecb65ce1dbd17454a6c02ef0f1ea0a5f7a4fbcf6","Type":0,"CoinName":"LTC","SenderAddr":"MBR7SYc1QCCm2X3KzUwmyMqR7UFaUQnm2x","QuantaAddr":"airdropuser-179760","Amount":71232,"BlockID":1622178,"Signatures":null,"BlockHash":"7aa08ce741d54434b7fca03150d10981c712559bf367b488b9eefc6613f3216a"}]
crosschain_ltc_1  | 2019/04/28 05:43:47 I [5000] Block 1622178 Got deposits 1 [0xc42048af80]

litecoind

crosschain_ltc_1  | 2019/04/28 05:18:34 I [5000] Coin2Quanta: Got blocks [1622168]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:18:55 I [5000] Coin2Quanta: Got blocks [1622169]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:19:34 I [5000] Coin2Quanta: Got blocks [1622170]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:20:07 I [5000] Coin2Quanta: Got blocks [1622171]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:21:16 I [5000] Coin2Quanta: Got blocks [1622172]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:24:02 I [5000] Coin2Quanta: Got blocks [1622173]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:24:35 I [5000] Coin2Quanta: Got blocks [1622174]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:27:59 I [5000] Coin2Quanta: Got blocks [1622175]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:32:32 I [5000] Coin2Quanta: Got blocks [1622176]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:39:50 I [5000] Coin2Quanta: Got blocks [1622177]
crosschain_ltc_1  | events = []
crosschain_ltc_1  | 2019/04/28 05:43:47 I [5000] Coin2Quanta: Got blocks [1622178]

other 2 nodes kept going just fine, and moved into consensus

blacklist feature

in the configuration, we add a blacklist such as

Blacklist:
 - airdropuser-60450

which is converted into the a list.

If a user withdraw from this account, we just error it out as "fatal".

Tools for manually process failed transactions

2 addition commands on node that will exit as soon as it is executed , similar to "encrypt"

Currently some nodes was unable to generate the btc addresses that other nodes generated, while I can

./node sync_addresses btc

(works for BCH, and LTC as well)

This commands will loop through the crosschain addresses table for BTC, and call the
GenerateMultisig, which imports the addresses in.

send remain to crosschain

Lower costs by sending remain to crosschain + reduce issues.

Send remain amount to “crosschain” address, which is generated by our CreateMultisigAddress.

Two consecutive deposits do not work

Rebuilt the latest
dep ensure -update
cd node
go build

Steps to reproduce:

  1. send via metamask 100
  2. send via metamask 120 very fast after the first

Result: First tx got funded, second failed

2018/11/28 14:46:47 I [5000] Submit TX: 0x32d25ff2df171f12d23c7d28c15a8de49ce89a70963777fcff1a888fcf9d65c4 signed=true AAAAAGn98QIq3omDyMTyKiSQstDq6j0Z6iBcyeADy7AzYzjJAAAAZAAPCxsAAAAHAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAtPLXJrAzpl8vQeC3aWnpevyKsW/74pC1OszLAbBW5OkAAAABRVRIAAAAAABp/fECKt6Jg8jE8iokkLLQ6uo9GeogXMngA8uwM2M4yQAAAAAADI2zAAAAAAAAAAOspXiTAAAAQIH7OYtlseFXmUbejzgXATD1r/UiHicKbXeCMukGZaqJIxFtIp2As5vVqnE5Teh1LUpE3n0ZsYaLvF0gEwVkYQI+haVNAAAAQIgdmAeo02+lgW2PGQxbnns53VPltqvGCQdb2cj0sx9iV73UCZdIW0X7YcWWAzlesxmlrwPqksJ0QaraPfduHAeCMai/AAAAQBeBVcH0o0UcUzPjpKldmJQvb48tmjDwJcka+tzJPiexWU8pk0WKX2/CxSpayt6dHvcBJcTJZEzAA7B/cDpzago=
2018/11/28 14:46:49 I [5000] Successful tx submission c0a878da60fa7c84aa8df24333a81c03bb542cbe557c49ed0d7f3413e0a5772b,remove %!s(int=0)
2018/11/28 14:46:49 I [5000] Submit TX: 0xa29f71f9d54e9e63c04495a8ac1c28b48ffd0756119ff4a76398d5d4290ff1a4 signed=true AAAAAGn98QIq3omDyMTyKiSQstDq6j0Z6iBcyeADy7AzYzjJAAAAZAAPCxsAAAAHAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAtPLXJrAzpl8vQeC3aWnpevyKsW/74pC1OszLAbBW5OkAAAABRVRIAAAAAABp/fECKt6Jg8jE8iokkLLQ6uo9GeogXMngA8uwM2M4yQAAAAAAvE15AAAAAAAAAAOspXiTAAAAQL+NdN9+mwaWHvEkdtZxdGwXbxC5FxZjJzEs+0GzvjuWX0ZpK6wra4fiMqNR5n3MyFJSjGIHVFeFQnOGfCfNkwqCMai/AAAAQNKtYdKvyIYYxPMj7Q3YFBOZNeHH26HOrg7yHWTZNNQ1zZHMBjq9poJzGsWAu8Onc3K0TOBC6O/IygfZwMb/hgE+haVNAAAAQBX2qn5/SP5IX9sWNtmrXmqswmFQYU/ZLHT1H+qRRvK/EslVXH1Vj/OD/Qi/VDEuHXUkB5vOM9XXFbbnoh+QRwI=
2018/11/28 14:46:49 E [5000] could not submit transaction Horizon error: "Transaction Failed". Check horizon.Error.Problem for more information.The transaction failed when submitted to the stellar network. The `extras.result_codes` field on this response contains further details.  Descriptions of each code can be found at: https://www.stellar.org/developers/learn/concepts/list-of-operations.html
2018/11/28 14:46:49 E [5000] Op codes [] Tx codes 
2018/11/28 14:46:50 I [5000] Submit TX: 0xa29f71f9d54e9e63c04495a8ac1c28b48ffd0756119ff4a76398d5d4290ff1a4 signed=true AAAAAGn98QIq3omDyMTyKiSQstDq6j0Z6iBcyeADy7AzYzjJAAAAZAAPCxsAAAAHAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAtPLXJrAzpl8vQeC3aWnpevyKsW/74pC1OszLAbBW5OkAAAABRVRIAAAAAABp/fECKt6Jg8jE8iokkLLQ6uo9GeogXMngA8uwM2M4yQAAAAAAvE15AAAAAAAAAAOspXiTAAAAQL+NdN9+mwaWHvEkdtZxdGwXbxC5FxZjJzEs+0GzvjuWX0ZpK6wra4fiMqNR5n3MyFJSjGIHVFeFQnOGfCfNkwqCMai/AAAAQNKtYdKvyIYYxPMj7Q3YFBOZNeHH26HOrg7yHWTZNNQ1zZHMBjq9poJzGsWAu8Onc3K0TOBC6O/IygfZwMb/hgE+haVNAAAAQBX2qn5/SP5IX9sWNtmrXmqswmFQYU/ZLHT1H+qRRvK/EslVXH1Vj/OD/Qi/VDEuHXUkB5vOM9XXFbbnoh+QRwI=
2018/11/28 14:46:50 E [5000] could not submit transaction Horizon error: "Transaction Failed". Check horizon.Error.Problem for more information.The transaction failed when submitted to the stellar network. The `extras.result_codes` field on this response contains further details.  Descriptions of each code can be found at: https://www.stellar.org/developers/learn/concepts/list-of-operations.html
2018/11/28 14:46:50 E [5000] Op codes [] Tx codes 
2018/11/28 14:46:50 D [5000] Coin2Quanta: No new block last=2728 top=2728
2018/11/28 14:46:50 I [5000] ***** Start # of blocks=0 man.N=3,man.Q=3 *** 
http://testnet-02.quantachain.io:8000/accounts/QBU734ICFLPITA6IYTZCUJEQWLIOV2R5DHVCAXGJ4AB4XMBTMM4MSB7P/payments?order=asc&limit=100&cursor=0
2018/11/28 14:46:50 I [5000] QuantaToCoin refunds []
2018/11/28 14:46:50 I [5000] Next cursor is = 0, numRefunds=0
2018/11/28 14:46:51 I [5000] Submit TX: 0xa29f71f9d54e9e63c04495a8ac1c28b48ffd0756119ff4a76398d5d4290ff1a4 signed=true AAAAAGn98QIq3omDyMTyKiSQstDq6j0Z6iBcyeADy7AzYzjJAAAAZAAPCxsAAAAHAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAtPLXJrAzpl8vQeC3aWnpevyKsW/74pC1OszLAbBW5OkAAAABRVRIAAAAAABp/fECKt6Jg8jE8iokkLLQ6uo9GeogXMngA8uwM2M4yQAAAAAAvE15AAAAAAAAAAOspXiTAAAAQL+NdN9+mwaWHvEkdtZxdGwXbxC5FxZjJzEs+0GzvjuWX0ZpK6wra4fiMqNR5n3MyFJSjGIHVFeFQnOGfCfNkwqCMai/AAAAQNKtYdKvyIYYxPMj7Q3YFBOZNeHH26HOrg7yHWTZNNQ1zZHMBjq9poJzGsWAu8Onc3K0TOBC6O/IygfZwMb/hgE+haVNAAAAQBX2qn5/SP5IX9sWNtmrXmqswmFQYU/ZLHT1H+qRRvK/EslVXH1Vj/OD/Qi/VDEuHXUkB5vOM9XXFbbnoh+QRwI=

Withdrawal fee.

Each coin will have a new configuration called:

BtcWithdrawMin: 0.00075
BtcWithdrawFee: 0.00025
BchWithdrawMin: 0.0015
BchWithdrawFee: 0.0005
EthWithdrawMin: 0.015
EthWithdrawFee: 0.005
LtcWithdrawFee: 0.0015
LtcWithdrawFee: 0.0005

If withdrawal amount is below the min, bounce it back with reason: too_small
When you're withdrawing:

Input -> output 1 - the user (amount minus fee)
output 2 - remaining amount

input = output1 + output2 (included withdraw fee) + tx fee

remaining amount contains the withdraw fee, implicitly.

Sending 10 ETH

Steps to reproduce:
web3.eth.sendTransaction({from:sender, to:receiver, value: web3.toWei(10, "ether")})

Result:
Node proposes negative number.

Approach:

WeiToStellar(tx.Value().Int64()),

Wei should be an input as BigInt

Ethereum_client.go:196

Submitstate = 'BAD_ADDRESS"

When user withdrawal to a bad address, mark the transaction as bad address.

Set the from address of the deposit as the issuer.

non-leader nodes are attempting to start a round?

crosschain1_1 | Geting txid from trustaddr 0xF8306d5279193146F307dc1c170EA59e7b0C370A
crosschain1_1 | Last TX ID= 8
crosschain1_1 | 2019/03/25 18:34:55 I [5000] Start new round 194098_0 ETH to=0xf29449369cf92b0778fc9aadd27cea35ec1df760 amount=20
crosschain1_1 | 2019/03/25 18:34:55 I [cosi] Start new round leader=false nodes=3 threshold=3
crosschain1_1 | 2019/03/25 18:34:55 E [cosi] Only leader can propose signing

Deposit does not work when a node is stopped and restarted again. (non-leader node)

Run 3 nodes
Submit Transaction
Stop one node
Submit Transaction
Restart the node


2018/11/30 11:44:34 I [5000] Start new round 0x3fd5e39ebf4742e61bd9db018e2c663c01e629a661e15f8043e4a123e2dd7b58 ETH to=QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV amount=400000
Propose TX:  ETH QDFLBGRMXEDTLI2LBYQTF7ZX4LPGOWIBN2UDQOZW6VH47LNEX5MEXBST 0.0400000 QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV
2018/11/30 11:44:34 I [5000] Got blocks [8071 8072]
2018/11/30 11:44:34 I [5000] ***** Start # of blocks=2 man.N=3,man.Q=3 *** 
2018/11/30 11:44:34 I [5000] set last block coin=ETH height=8072
2018/11/30 11:44:34 I [5000] QuantaToCoin refunds []
2018/11/30 11:44:34 I [5000] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 11:44:34 I [cosi] Start new round leader=true nodes=3 threshold=3
2018/11/30 11:44:34 I [cosi] Got commitment 2/3
2018/11/30 11:44:34 I [cosi] Got commitment 3/3
2018/11/30 11:44:34 I [cosi] Got total of 3 commitments, moving forward
2018/11/30 11:44:34 I [5000] Sign msg wGGc8QAAAEBswnde3ksmBxQ1+utUxt3XmtPfAzDGNcrLJMYe2Ydzy0h6U5W2xjdswuNW8EY0XaLR34MUoejeSysazqupKKcL
2018/11/30 11:44:34 I [cosi] Got signature 2/3
2018/11/30 11:44:34 I [cosi] Got signature 3/3
2018/11/30 11:44:34 I [5000] Great! Cosi successfully signed deposit
2018/11/30 11:44:34 E [5000] processSubmissions pending=1
2018/11/30 11:44:34 I [5000] Submit TX: 0x3fd5e39ebf4742e61bd9db018e2c663c01e629a661e15f8043e4a123e2dd7b58 signed=true AAAAAMqwmiy5BzWjSw4hMv834t5nWQFuqDg7NvVPz62kv1hLAAAAZAAPDxkAAAAqAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAQ2ngI+8T11/xdvUwln/vdfFmE79ZOmNe+f6ukF88UUYAAAABRVRIAAAAAADKsJosuQc1o0sOITL/N+LeZ1kBbqg4Ozb1T8+tpL9YSwAAAAAABhqAAAAAAAAAAAPAYZzxAAAAQGzCd17eSyYHFDX661TG3dea098DMMY1ysskxh7Zh3PLSHpTlbbGN2zC41bwRjRdotHfgxSh6N5LKxrOq6kopwunC6puAAAAQBNZ9o3r+5Vl1ybLT+f2A3/ZlM3gYVy/7n6/pm6oxS6ZMeLHNV7+iWZbd81KUw+9N1rAoww9wM5c80OIYh4lggEWQn5KAAAAQIoErPsnbGmnjGcrK/WGIaBT6hBfdWku2iUJiFsJLmaY5XT8xdfj/BCs1K4Kg22SfVpVLcMBLwSg/TSy0a0KrAA=
2018/11/30 11:44:37 I [5000] Successful tx submission d2f553d2024c13239289fe201f58e36b8c6649e5ab90738d2467b7fd608bcec2,remove %!s(int=0)


Stopped node3(Leader Log)

2018/11/30 11:59:25 I [cosi] Start new round leader=true nodes=3 threshold=3
Error! Post http://0.0.0.0:5002/node/api/peer: dial tcp 0.0.0.0:5002: connect: connection refused
2018/11/30 11:59:25 I [cosi] Got commitment 2/3
2018/11/30 11:59:25 D [5000] Coin2Quanta: No new block last=8136 top=8136
2018/11/30 11:59:25 I [5000] ***** Start # of blocks=0 man.N=3,man.Q=3 *** 
2018/11/30 11:59:25 I [5000] QuantaToCoin refunds []
2018/11/30 11:59:25 I [5000] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 11:59:28 E [cosi] Timeout should not happen received 2/3
2018/11/30 11:59:28 E [cosi] Bailing out of leader prep round, not enough nodes
2018/11/30 11:59:28 E [5000] Unable to sign for refund
2018/11/30 11:59:28 D [5000] Coin2Quanta: No new block last=8136 top=8136
2018/11/30 11:59:28 I [5000] ***** Start # of blocks=0 man.N=3,man.Q=3 *** 
2018/11/30 11:59:28 I [5000] QuantaToCoin refunds []
2018/11/30 11:59:28 I [5000] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 11:59:29 I [5000] Start new round 0xc2cde8f9ae68a4ee1f07edb7b347155683709b0f9d469d136c815ae2e5f37571 ETH to=QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV amount=600000
Propose TX:  ETH QDFLBGRMXEDTLI2LBYQTF7ZX4LPGOWIBN2UDQOZW6VH47LNEX5MEXBST 0.0600000 QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV

Restarted node3 (Leader Log)

2018/11/30 11:59:45 I [cosi] Start new round leader=true nodes=3 threshold=3
2018/11/30 11:59:45 I [cosi] Got commitment 2/3
2018/11/30 11:59:47 D [5000] Coin2Quanta: No new block last=8138 top=8138
2018/11/30 11:59:47 I [5000] ***** Start # of blocks=0 man.N=3,man.Q=3 *** 
2018/11/30 11:59:47 I [5000] QuantaToCoin refunds []
2018/11/30 11:59:47 I [5000] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 11:59:48 E [cosi] Timeout should not happen received 2/3
2018/11/30 11:59:48 E [cosi] Bailing out of leader prep round, not enough nodes
2018/11/30 11:59:48 E [5000] Unable to sign for refund
2018/11/30 11:59:49 I [5000] Start new round 0xc2cde8f9ae68a4ee1f07edb7b347155683709b0f9d469d136c815ae2e5f37571 ETH to=QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV amount=600000
Propose TX:  ETH QDFLBGRMXEDTLI2LBYQTF7ZX4LPGOWIBN2UDQOZW6VH47LNEX5MEXBST 0.0600000 QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV
2018/11/30 11:59:49 I [cosi] Start new round leader=true nodes=3 threshold=3
2018/11/30 11:59:50 I [5000] Got blocks [8139 8140]
2018/11/30 11:59:50 I [5000] ***** Start # of blocks=2 man.N=3,man.Q=3 *** 
2018/11/30 11:59:50 I [5000] set last block coin=ETH height=8140
2018/11/30 11:59:51 I [5000] QuantaToCoin refunds []
2018/11/30 11:59:51 I [5000] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 11:59:52 E [cosi] Timeout should not happen received 1/3
2018/11/30 11:59:52 E [cosi] Bailing out of leader prep round, not enough nodes
2018/11/30 11:59:52 E [5000] Unable to sign for refund
2018/11/30 11:59:53 I [5000] Start new round 0xc2cde8f9ae68a4ee1f07edb7b347155683709b0f9d469d136c815ae2e5f37571 ETH to=QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV amount=600000
Propose TX:  ETH QDFLBGRMXEDTLI2LBYQTF7ZX4LPGOWIBN2UDQOZW6VH47LNEX5MEXBST 0.0600000 QBBWTYBD54J5OX7RO32TBFT75527CZQTX5MTUY267H7K5EC7HRIUNTDV
2018/11/30 11:59:53 I [cosi] Start new round leader=true nodes=3 threshold=3
2018/11/30 11:59:54 D [5000] Coin2Quanta: No new block last=8140 top=8140
2018/11/30 11:59:54 I [5000] ***** Start # of blocks=0 man.N=3,man.Q=3 *** 
2018/11/30 11:59:54 I [5000] QuantaToCoin refunds []
2018/11/30 11:59:54 I [5000] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 11:59:56 E [cosi] Timeout should not happen received 1/3
2018/11/30 11:59:56 E [cosi] Bailing out of leader prep round, not enough nodes
2018/11/30 11:59:56 E [5000] Unable to sign for refund

Node3 log when restarted

2018/11/30 11:59:39 I [5002] Initialize ledger
2018/11/30 11:59:39 I [5002] REST API started at :0...
2018/11/30 11:59:40 I [5002] Added to quorum
2018/11/30 11:59:40 I [5002] Trust initialized
2018/11/30 11:59:41 I [5002] Got blocks [8135 8136 8137 8138]
2018/11/30 11:59:41 I [5002] ***** Start # of blocks=4 man.N=3,man.Q=3 *** 
2018/11/30 11:59:41 I [5002] Block 8135 Got deposits 1 [0xc0004b48c0]
2018/11/30 11:59:41 E [cosi] Unable to validate transactions: %!(EXTRA string=Unable to verify: 0xc2cde8f9ae68a4ee1f07edb7b347155683709b0f9d469d136c815ae2e5f37571 not found)
2018/11/30 11:59:42 I [5002] set last block coin=ETH height=8138
2018/11/30 11:59:42 I [5002] QuantaToCoin refunds []
2018/11/30 11:59:42 I [5002] Next cursor is = 4779830449016833, numRefunds=0
2018/11/30 11:59:45 D [5002] Coin2Quanta: No new block last=8138 top=8138
2018/11/30 11:59:45 I [5002] ***** Start # of blocks=0 man.N=3,man.Q=3 *** 
2018/11/30 11:59:45 I [5002] QuantaToCoin refunds []
2018/11/30 11:59:45 I [5002] Next cursor is = 4779830449016833, numRefunds=0```

hanging issue

2019/06/21 02:11:27 I [5000] Quanta2Coin: Got blocks [8113470 8113471 8113472]
2019/06/21 13:57:25 I [cosi] Start new round leader=true nodes=3 threshold=3
2019/06/21 13:57:26 I [cosi] Got commitment 2/3
2019/06/21 13:57:27 I [cosi] Got commitment 3/3
2019/06/21 13:57:27 I [cosi] Got total of 3 commitments, moving forward
2019/06/21 13:57:27 I [cosi] Got signature 2/3
2019/06/21 13:57:27 I [cosi] Got signature 3/3
2019/06/21 13:57:27 I [5000] Cosi successfully agreed on address 32eBtnp9QwkxXx3VRJ5UZix4W483x1uu6G for airdropuser-35646
2019/06/21 13:57:27 I [5000] Updated the crosschain address for account : airdropuser-35646 to 32eBtnp9QwkxXx3VRJ5UZix4W483x1uu6G

Looks like it's caused when the quanta websocket goes down, and it hangs from attempting to connect with no apparent timeout , or retry.

Impact: All 3 nodes.

improve performance of BTC

It takes about 20 minutes to read a whole block.

Let's do this...

in GetDeposit, retrieve listunspent first (which gets indexed by the bitcoin node when we add a multisig address), then create a map lookup table based on txid.

If any deposit can be found in txid, we process it. This saves a lot of time from getting "raw" transaction and everything else.

Tune pingdom alerts

Currently pingdom is sending a few false alerts. Please look into the history responses and see how we can tune our configurations better to reduce these false alarms. Use my credentials from slack.

Feature request: Get ETH crosschain address easier V2

Least Recently Used

type CrosschainAddress struct {
	Address    string
	QuantaAddr string
	TxHash     string
	Blockchain string
        Shared bool
        LastBlockNumber  uint64 // new
	Updated    time.Time
}

On new transaction

Everytime we see a transaction, update the LastBlockNumber

Implementation
Configuration

  • Set MINIMUM_BLOCK_REUSE > (24*60*60*5)/14 greater than 5 days old.

Add new address pool

  • Introduce a new type of address with a quanta_addr: "address-pool"
  • if quanta_addr = address-pool, mark as shared
  • If we detect forward address with address-pool, add it in the address table.

GenerateMultisig*

  • Only generate for user that do not an address (prevent spamming)
  • Everytime a user generate the address,
    • Get Shared=1 AND MIN(LastBlockNumber) AND Ensure that HeadBlockNumber - LastBlockNumber > MINIMUM_BLOCK_REUSE (easy to implement as a SQL)
  • Update the toAddress to the new account (Yes we will take away from someone else if it is more than 5 days old)
  • Return error if we do not have an address that meets such criteria

Request&Commit
Since nodes could be different states, we should introduce a request and commit. MORE INFO later.

Exit 137

Exited mysteriously , no error:

4517d8024f49 crosschain:latest "/usr/bin/quanta-bri…" 22 hours ago Exited (137) 18 hours ago containers_crosschain1_run_483758a5f9a7

2019/07/17 01:37:30 I [5000] Quanta2Coin: Got blocks [10256825 10256826 10256827]
2019/07/17 01:37:33 I [5000] Quanta2Coin: Got blocks [10256828 10256829 10256830]
2019/07/17 01:37:36 I [5000] Quanta2Coin: Got blocks [10256831 10256832 10256833]
2019/07/17 01:37:39 I [5000] Quanta2Coin: Got blocks [10256834 10256835 10256836]
2019/07/17 01:37:42 I [5000] Quanta2Coin: Got blocks [10256837 10256838 10256839]
2019/07/17 01:37:45 I [5000] Quanta2Coin: Got blocks [10256840 10256841 10256842]
2019/07/17 01:37:48 I [5000] Quanta2Coin: Got blocks [10256843 10256844 10256845]
2019/07/17 01:37:51 I [5000] Quanta2Coin: Got blocks [10256846 10256847 10256848]
2019/07/17 01:37:54 I [5000] Quanta2Coin: Got blocks [10256849 10256850 10256851]
2019/07/17 01:37:57 I [5000] Quanta2Coin: Got blocks [10256852 10256853 10256854]
2019/07/17 01:38:00 I [5000] Quanta2Coin: Got blocks [10256855 10256856 10256857]
2019/07/17 01:38:03 I [5000] Quanta2Coin: Got blocks [10256858 10256859 10256860]
2019/07/17 01:38:06 I [5000] Quanta2Coin: Got blocks [10256861 10256862 10256863]
2019/07/17 01:38:09 I [5000] Quanta2Coin: Got blocks [10256864 10256865 10256866]
2019/07/17 01:38:12 I [5000] Quanta2Coin: Got blocks [10256867 10256868 10256869]
2019/07/17 01:38:15 I [5000] Quanta2Coin: Got blocks [10256870 10256871 10256872]
2019/07/17 01:38:18 I [5000] Quanta2Coin: Got blocks [10256873 10256874 10256875]
2019/07/17 01:38:21 I [5000] Quanta2Coin: Got blocks [10256876 10256877 10256878]

Registry remembers the nodes manifiest if it goes down.

The use case here, is that we can take down any node independently of each other. Right now , if we take the registry node down, we have to restart all the other nodes to register.

  1. Registry serializes into JSON the manifest
  2. Load up on startup.

It should be based on public key, and update the ip if the user has changed.

Use case 1:

  1. stop registry node
  2. restart registry node
    expect: consensus to work as normal

Use case 2:

  1. stop a single node (non registry)
  2. start the node again
    expect: consensus work as normal

Use case 3:

  1. stop a single node (non registry)
  2. start a node again with different port or ip, but same public key

expect manifest to update & broadcast & consensus work as normal

node2 occassionally missed the 3rd message.. on creating BTC addresses

2019/05/17 19:00:52 I [5201] Quanta2Coin: Got blocks [5168652 5168653 5168654]
2019/05/17 19:00:53 I [cosi] Initialize cosi state.
2019/05/17 19:00:54 E [cosi] Bailing out of follower commit round, not enough nodes 2/3
2019/05/17 19:00:54 I [cosi] stunnel Follower got prepare 3/3
2019/05/17 19:00:55 I [5201] Quanta2Coin: Got blocks [5168655 5168656 5168657]
2019/05/17 19:00:58 I [5201] Quanta2Coin: Got blocks [5168658 5168659 5168660]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.