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

feat: extract sbtc contract calls block observer #315

Merged
merged 10 commits into from
Jul 11, 2024

Conversation

djordon
Copy link
Contributor

@djordon djordon commented Jul 11, 2024

Description

This might also address #209, but I'm not sure.

Changes

  1. Modify one of the functions in the DbWrite trait to use the model types as input. This keeps the interface a bit more logical and makes it easier to test.
  2. Rewrote the functions that wrote stacks blocks to send slices of the correct type, instead of sending JSON. This allows us to make use of the actual type that we want to write.
  3. Finish implementation of the function that writes stacks blocks in the block observer.

Testing information

This PR is mostly a refactor. The core functionality was added in 2e30ef3, but subsequent commits addressed some oddities in the previous code.

Copy link
Contributor

@netrome netrome left a comment

Choose a reason for hiding this comment

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

This is great stuff so far. What we should also do (either here or as follow-ups) is to populate some dedicated tables for the different transaction types. We should:

  • Parse any calls to rotate-keys-wrapper and write the updated signer set into a table. Right now the storage model has the aggregate_key_transactions table that tracks the aggregate keys. I think we could rename this to key_rotations, and we also need to track the updated signer set, so we need to add a field for that as well.
  • Populate the deposit_responses and withdraw_responses tables in the state model.

Copy link
Collaborator

@AshtonStephens AshtonStephens left a comment

Choose a reason for hiding this comment

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

LGTM, though how are we ultimately getting the data from the deleted functions? For example with the function below:

    fn extract_update_signer_set_transactions(&self, _transactions: &[stacks::StacksTransaction]) {
        // TODO(#208): Implement
    }

Do we no longer need that data?

@djordon
Copy link
Contributor Author

djordon commented Jul 11, 2024

LGTM, though how are we ultimately getting the data from the deleted functions? For example with the function below:

    fn extract_update_signer_set_transactions(&self, _transactions: &[stacks::StacksTransaction]) {
        // TODO(#208): Implement
    }

Do we no longer need that data?

We do, it's just done in the BlockObserver::write_stacks_blocks function. That function extracts the relevant transactions and writes them all to the database as two queries.

@djordon djordon merged commit 32f51ff into main Jul 11, 2024
4 checks passed
@djordon djordon deleted the 313-extract-sbtc-contract-calls-block-observer branch July 11, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment