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

Refactor of batching stores and APIs #420

Merged
merged 16 commits into from
Nov 29, 2024
Merged

Refactor of batching stores and APIs #420

merged 16 commits into from
Nov 29, 2024

Conversation

hacheigriega
Copy link
Member

@hacheigriega hacheigriega commented Nov 19, 2024

Motivation

  • Tree entry store refactor
  • Merge batch signature store with validator tree entry store
  • Batch query now returns its tree entries and signatures as well.
  • Remove separate query endpoints for batch signatures and tree entries.
  • Querying data result also returns its batch assignment, if exists. (nil if a batch has not been assigned to a data result)
  • Fix logic for retrieving latest batch whose signatures have been collected
  • Add a flag for querying batches without signatures
  • Update Swagger docs

Explanation of Changes

There is no longer a separate query endpoint for batch signatures or tree entries. To obtain them, query the corresponding batch instead:

❯ sedad query batching batch 3 -o json | jq
{
  "batch": {
    "batch_number": "3",
    "block_height": "23",
    "current_data_result_root": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
    "data_result_root": "56c4f39b7564ea6a32877fc98743652998753c4cd8a4b455c26dcb3b92774b73",
    "validator_root": "96452cb1ee0deb9c44e992f6b1d807abc00e216fb4b0c4a85d54ec854db024bc",
    "batch_id": "YsZCbHoVhEk/lBg7MxZjyekdUsgMGbYYwQHKd7JPAv4=",
    "proving_metadata": null
  },
  "data_result_entries": {
    "entries": []
  },
  "validator_entries": [
    {
      "validator_address": "sedavaloper14aknletrd5wgys5ypchrp463txvlq27pelzg7j",
      "voting_power_percent": 50000000,
      "eth_address": "W7bYkKmLRmI9wHXcstpF0VCgHkk="
    },
    {
      "validator_address": "sedavaloper1hmkpuzyq8f2nzvwxltne34yk956mft34yd7s6l",
      "voting_power_percent": 50000000,
      "eth_address": "DJ/0RmJT0bSiIOwMCEHIQzU8tJw="
    }
  ],
  "batch_signatures": [
    {
      "validator_address": "sedavaloper15xgmjrur7lr48ye0tfeu30cjs8evrxd77rf8c8",
      "secp256k1_signature": "y4C9kJzRaEZM2e50enCRYUUzfjt3otRcjF9IR5Ma1MEyIRiwgvJ2FzmwuDyd75rj+MYZPNBWdVLL1TsLkM14YQE="
    },
    {
      "validator_address": "sedavaloper14aknletrd5wgys5ypchrp463txvlq27pelzg7j",
      "secp256k1_signature": "Evro8bGJwBWKCEZvT+t5hJhw1SqEJSgfsoht/uzaz2lgh5yUwDLG05HIY7QeHPDVWnM+l+W7C6Lv0B3dKnwUcQE="
    },
    {
      "validator_address": "sedavaloper1hmkpuzyq8f2nzvwxltne34yk956mft34yd7s6l",
      "secp256k1_signature": "nTcVAzt8R7WwjvMn7X5vGWagxOcD2Ft//9d81TScEpc8goL7Pagvw5EvuG0fDChBNUVsoXxAa3889tlLKE+05gE="
    }
  ]
}

To query the latest batch whose signatures have been collected, make the same query without any arguments.

List of batches in the store can now be queried with the flag --with-unsigned to include new batches without signatures.

❯ sedad query batching batches
❯ sedad query batching batches --with-unsigned

Also note that validator tree entries are now stored separately from data result tree entries in a struct:

// ValidatorTreeEntry is an entry in the validator tree.
type ValidatorTreeEntry struct {
	ValidatorAddress   sdk.ValAddress 
	VotingPowerPercent uint32
	EthAddress         []byte
}

// Entries of data result tree of a given batch.
type DataResultTreeEntries struct {
	Entries []byte
}

// BatchSignatures contains basic validator data and its batch signatures
// under various cryptographic schemes.
type BatchSignatures struct {
	ValidatorAddress   sdk.ValAddress
	Secp256K1Signature []byte              
}

Store schema:

0x05 | batch_num | operator    -> BatchSignatures
0x06 | batch_num               -> DataResultEntry
0x07 | batch_num | operator    -> ValidatorEntry

Related PRs and Issues

Closes #423

@hacheigriega hacheigriega force-pushed the hy/polish-batch branch 6 times, most recently from c2200ab to 748536b Compare November 26, 2024 21:55
@hacheigriega hacheigriega marked this pull request as ready for review November 26, 2024 22:05
@hacheigriega hacheigriega requested a review from a team November 27, 2024 09:44
// Secp256k1Entry is the secp256k1 signature component of a validator
// tree entry.
message Secp256k1Entry {
bytes eth_address = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have to be an eth address right? Could be any evm network, and even then I don't think it's limited to only evm networks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right but I think we will have to create a new struct every time we add a new signature scheme

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would make more sense to have this labeled with the scheme then? Since different chains could use the same scheme.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eth_address means more like ethereum-style address format. So different chains could still use this if they use this address format.

x/batching/keeper/querier.go Show resolved Hide resolved
x/batching/keeper/querier.go Outdated Show resolved Hide resolved
app/abci/handlers.go Outdated Show resolved Hide resolved
plugins/indexing/batching/module.go Outdated Show resolved Hide resolved
Copy link
Member

@Thomasvdam Thomasvdam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not also remove the batching params key?

@hacheigriega
Copy link
Member Author

Should we not also remove the batching params key?

Ah yes I will remove it before I merge this PR

@hacheigriega hacheigriega merged commit 100951e into main Nov 29, 2024
15 of 17 checks passed
@hacheigriega hacheigriega deleted the hy/polish-batch branch November 29, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

♻️ Improve batching RPC calls for the solver
3 participants