XRP - Sequence number

Dahun Yoo·2021년 6월 14일
0

BlockChain and QA

목록 보기
3/5
post-thumbnail

XRP의 특징 중 하나인 Sequence number 에 대해 알아봅니다.


Sequence number

Account Sequence

A sequence number is a 32-bit unsigned integer that is used to make sure transactions from a given sender execute only once each, and in the correct order.

Every account in the XRP Ledger has a sequence number in its Sequence field, which increases by 1 whenever that account sends a transaction and that transaction gets included in a validated ledger. Each transaction also has a sequence number in its Sequence field, which must match the account's current sequence number when the transaction executes. For each account, each sequence number can only be used once, in numerical order.

Tickets make some exceptions from these rules so that it is possible to send transactions out of the normal order. Tickets represent sequence numbers reserved for later use; a transaction can use a Ticket instead of a normal sequence number.

With the DeletableAccounts amendment, the starting Sequence number for an account matches the Ledger Index of the ledger version where the account was created. Before DeletableAccounts, every account started with Sequence number 1.

Whenever a transaction is included in a ledger, it uses up a sequence number (or Ticket) regardless of whether the transaction executed successfully or failed with a tec-class error code. Other transaction failures don't get included in ledgers, so they don't change the sender's sequence number (or have any other effects).

Within the ledger, an Address and a sequence number are sometimes used together to identify an object that was created by the validated transaction with that sender and sequence number. Escrows and Offers are examples of objects identified this way.

It is possible for multiple unconfirmed transactions to have the same sender and sequence number. Such transactions are mutually exclusive, and at most one of them can be included in a validated ledger. (Any others ultimately have no effect.)

https://xrpl.org/basic-data-types.html#account-sequence

XRP Transaction들을 Explorer에서 확인하면 Sequence 필드를 확인할 수 있습니다.

Sequence number는 출고하고자 하는 어드레스로부터 트랜잭션이 올바른 순서대로 한 번 만 실행되도록 하기 위해 사용합니다.
어드레스는 sequence 필드를 가지고 있으며, 이 번호를 가진 transaction이 ledger에 기록되면, 어드레스의 sequence 필드의 숫자가 1씩 증가하게 됩니다.

즉, XRP 네트워크 상에서 transaction이 인정받기 위해서는 어드레스의 sequence 값과 Transaction에 기록된 sequence 값이 동일해야합니다.

Broadcast되기 전의 Raw tx를 여러개 만들면, 같은 Sequence number를 가진 transaction을 여러개 만들게 됩니다. 이때, 이것들을 동시에 다 업로드 한다고 하여도, 이미 특정한 한 건이 broadcast에 성공하여 ledger에 기록된다면, 같은 sequence number를 가진 다른 transaction들은 자동으로 실행 실패하게 됩니다.

이것으로 인해 XRP의 Double spending 문제를 막을 수 있고, 각각의 Transaction의 고유함을 증명할 수 있게 됩니다.

즉, XRP는 특정한 순서대로 broadcast되어야 하며, 그렇지 않으면 실패하게 됩니다.


Ref

profile
QA Engineer

0개의 댓글