Skip to content
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

Update rollapp state #45

Closed
liorzilp opened this issue Aug 2, 2022 · 1 comment · Fixed by #63
Closed

Update rollapp state #45

liorzilp opened this issue Aug 2, 2022 · 1 comment · Fixed by #63
Assignees
Labels
c:rollapp Rollapp module

Comments

@liorzilp
Copy link
Contributor

liorzilp commented Aug 2, 2022

Overview

When a sequencer is attached to a rollapp it can start to serve the rollapp chain and publish state updates. Create a UpdateState transaction.

Update State Message

Block description object:

  • height: is the height of the block.
  • stateRoot: is the state root of the block.
  • intermediateStatesRoot: is the root of a Merkle tree built from the ISRs of the block (Intermediate State Root).

The following fields are required for updating a state:

  • creator: is the bech32-encoded address of the sequencer account sent the transaction.
  • rollappId: is the rollapp that the sequencer belongs to and asking to update
  • startHigh: is the block height of the first block in the batch.
  • numBlocks: is the number of blocks included in this batch update.
  • DApath: is the description of the location on the DA layer.
  • version: is the version of the rollapp.
  • lastBD: the latest block descriptor of the last state update.
  • BDs: is a list of block description objects (one per block). the list must be ordered by height, start from startHeight to startHeight+numBlocks

State in store

StateInfo object:

  • sequencer: is the bech32-encoded address of the sequencer account sent the transaction.
  • rollappId: is the rollapp that the sequencer belongs to and asking to update
  • startHeight: is the block height of the first block in the batch.
  • numBlocks: is the number of blocks included in this batch update.
  • DApath: is the description of the location on the DA layer.
  • version: is the version of the rollapp.
  • BDs: is a list of block description objects (one per block). the list must be ordered by height, starting from startHeight to startHeight+numBlocks-1
  • additional:
  • creationHeight: is the height at which the UpdateState took place
  • status: is the status of the state update (see Rollapp states' status #49)

Validations

Basic validations

  1. blockDescriptors list size should be equal to numBlocks -> ErrInvalidNumBlocks
  2. blockDescriptors should contain all the high start from startHeight to (startHeight+numBlocks-1) in increasing order -> ErrInvalidBlockSequence
  3. blockDescriptors startHeight should be equal to lastBlockDescriptor.high+1

Stateful validation

  1. The rollapp exists -> ErrUnknownRollappId
  2. The sequencer is registered (can retrieve the rollapp object) -> ErrUnknownSequencer
  3. The rollappId is the rollappId that the sequencer belongs to -> ErrSequencerRollappMismatch
  4. Version is the currently active version of the rollapp -> ErrVersionMismatch
  5. If the rollapp has PermissionedAddress list, check that the sequencer is in list -> ErrLogic
  6. The StartHeight should be the latest+1 -> ErrWrongBlockHeight
  7. Only one update per rollapp is eligible in a block ->ErrMultiUpdateStateInBlock

Basic flow

Sending a transaction

  1. Sequencer can send a transaction for updating a batch
  2. If it is the first state update:
    • the lastBlockDescriptor.high should be zero
    • str&isrRoot are ignored
    • the start version is 0

Queries

  1. Retrieving the latest state update by rollapp
@liorzilp liorzilp added the enhancement New feature or request label Aug 2, 2022
@liorzilp liorzilp self-assigned this Aug 2, 2022
@liorzilp liorzilp added c:rollapp Rollapp module and removed enhancement New feature or request labels Aug 2, 2022
@liorzilp
Copy link
Contributor Author

Removing lastBD as we can check the lastest state from store

@liorzilp liorzilp linked a pull request Aug 25, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:rollapp Rollapp module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant