7

According to the stellar docs

Sequence number

The current transaction sequence number of the account. This number starts equal to the ledger number at which the account was created

This does not appear to be true. Take, for example the following account:

https://horizon-testnet.stellar.org/accounts/GAH4Q7KMQAYQQHXS5763UNPG5ZSOLROEZZHC4Y45BU3HIVH6RW3TBYBD

It was created in ledger 697113, but its sequence number started at 2994077536616448.

Where did this sequence number come from?

1 Answer 1

4

The ledger is bit shifted (but I don't know the reason why). 697113 << 32 = 2994077536616448

This is from stellar-core source:

getStartingSequenceNumber(LedgerTxnHeader const& header)
{
    return static_cast<uint64_t>(header.current().ledgerSeq) << 32;
}
2
  • Thanks! I guess the undocumented rationale for this is that you can easily get the starting sequence for an account by discarding the 32 least significant bits
    – David Kosz
    Commented Apr 10, 2019 at 15:14
  • 1
    I think the reason is here: github.com/stellar/stellar-protocol/blob/master/core/… The shift to signed sequence numbers is backward compatible from a data point of view as the top 32 bits of sequence numbers are seeded with the legder sequence number in older versions of the protocol. Some SDKs may have to be slightly updated if they enforce strong typing. In addition, existing code even with the updated range will continue to work as sequence numbers are within a subset of the range that was supported before. Commented Apr 10, 2019 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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