2

I can't understand the channel concept.

How does channel keep transactions' order? Is there a channel account for a special operation or any channel account can do any operation?

5

You need to understand how transaction sequence numbers first.

Every transaction has a source account, which pays for the operations contained inside it. To stop replay attacks, every transaction also has a sequence number, which must match the sequence number of the source account. (To be more specific the transaction sequence number has to be equal to the source account sequence number PLUS one).

This becomes an issue when you're submitting lots of transactions fast -- The transactions are created in a specific order, but might be accepted in a different order, where some of them ultimately fail because the sequence numbers don't match any longer.

This is where using channels enter the picture.

The transaction source account can be any account, as long as the sequence numbers match up, and it has enough funds to pay for the fees.

A channel is simply an account only used as a transaction source. It is used for its sequence number, for paying fees, and signing transactions.

By using channel accounts, you can increase your transaction throughput. E.g., ten channels can submit ten transactions per ledger update, with no dependence on what order they get executed in.

  • thanks Johan. I understood sequence number and channel. but i can't understand this sentence : "Channels take advantage of the fact that the “source” account of a transaction can be different than the source account of the operations inside the transaction". what is role of channel for operations? – Roya Nasiri Sep 23 '18 at 12:58
  • None. The only purpose of the transaction source account is to specify who pays the fees, and whose sequence number gets consumed. Operations can have their own source accounts, to specify what account the operations should execute as. – Johan Stén Sep 23 '18 at 13:08
  • This answer would be improved by explaining what a channel is or at least linking to the use of the term. You describe channels as if they are some feature of stellar-core, when they are just an abstraction built on top of stellar-core (which has no inherent support for "channel accounts"). – user3188445 Sep 23 '18 at 16:43
  • Doesn't "A channel is simply an account only used as a transaction source" cover that? I could point to the official docs, but I read somewhere that answers should be self-contained. – Johan Stén Sep 24 '18 at 4:02
  • I have another question : "how can we prevent reply attack when we use channel?" – Roya Nasiri Sep 24 '18 at 9:49
0

Additionally, to address this specific question:

how does channel keep transactions' order?

It doesn't I believe. In fact, the introduction of channels creates a potential race condition for operations that are sequence sensitive. Or at least I think it would. I haven't tested it.

Given operations A & B, where A must be considered before B can succeed (e.g. establish a trust line then pay using the trusted asset), then A must precede B in the operations list when they appear in the same transaction. But if they are in separate transactions, then the transaction with operation A must be processed before the transaction with operation B can be considered.

A naive channel implementation may simply bucket operations into concurrent transactions without considering how operations should be grouped.

In addition to Johan's excellent answer, please see my article on the topic.

  • I have another question : "how can we prevent reply attack when we use channel?" – Roya Nasiri Sep 24 '18 at 10:09
  • Another great question. A channel mechanism necessarily needs to know how to sign as all of the transaction sources and operation sources. If an attacker gained access they could do much worse than simply replay messages. However, if you are talking about duplication of upstream messages being sent to a channel implementation, then I think you need to build in idempotent message handling. It may be a challenge to know which messages are erroneous dupes vs which are legitimate. It makes sense to also require sequence ids of your upstream message producers. – Synesso Sep 24 '18 at 10:43
0

Channel accounts are also very useful to handle preseigned transactions on foreign accounts.

If somebody presignes a transaction the sequence number must be correct. As you don't know if the user performs other transactions meanwhile (and increases the sequence number). You can't be sure the presigned transaction is valid any more.

Here you can use a channel account to avoid that issue.

0

I like to explain it like this:

Imagine you want to send 100 letters in the mail (transactions), however, the receptionist(stellar) will only accept one letter from you at a time (1 sequence per ledger).

So you give the other 99 letters to 99 of your friends (channels), and each of them sends a letter from you.

So basically they use their "1 letter at once" for you.

This is how channels work, they use their sequence number and fee for this ledger, to send a transaction from you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.