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(sequencer): store currency pair id mapping along with committed extended commit info #1832

Open
wants to merge 6 commits into
base: feat/oracle
Choose a base branch
from

Conversation

noot
Copy link
Collaborator

@noot noot commented Nov 21, 2024

Summary

the price data posted by validators is of the form currency pair ID -> price, however when this is sent to a rollup there is then no way to determine the ID -> actual currency pair without referencing the sequencer state. this is non ideal as we don't want to have to perform lookups using a sequencer node for the oracle data.

Background

see above

Changes

  • create ExtendedCommitInfoWithCurrencyPairMapping type which contains ExtendedCommitInfo (as previous) as well as the ID->currency pair mapping for the price data inside that ExtendedCommitInfo
  • the proposer fills this mapping using the current sequencer state (before tx execution)
  • encoded ExtendedCommitInfoWithCurrencyPairMapping is then used as the third injected tx in the block, whereas before it was just ExtendedCommitInfo
  • the other validators then verify this mapping using the current sequencer state (before tx execution) in process_proposal

Testing

unit tests + CI tests

Related Issues

required for #1818

@noot noot requested review from a team as code owners November 21, 2024 15:30
@github-actions github-actions bot added proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate labels Nov 21, 2024
Copy link
Contributor

@Fraser999 Fraser999 left a comment

Choose a reason for hiding this comment

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

This looks correct to me, but I'd like to see a test for the new validation functionality provided by validate_id_to_currency_pair_mapping. However, as discussed offline, this is probably best done on top of the noot/more-tests branch where there are a bunch of other fixes and additional tests, so I'm fine to merge this, then prioritise adding the test into that branch and opening a PR.

Comment on lines +143 to +147
let extended_commit_info = ExtendedCommitInfo::try_from(
<astria_vendored::tendermint::abci::ExtendedCommitInfo as Into<
tendermint_proto::abci::ExtendedCommitInfo,
>>::into(extended_commit_info),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let extended_commit_info = ExtendedCommitInfo::try_from(
<astria_vendored::tendermint::abci::ExtendedCommitInfo as Into<
tendermint_proto::abci::ExtendedCommitInfo,
>>::into(extended_commit_info),
)
let extended_commit_info = ExtendedCommitInfo::try_from(
tendermint_proto::abci::ExtendedCommitInfo::from(extended_commit_info),
)

Comment on lines +115 to +123
#[must_use]
pub fn extended_commit_info(&self) -> &ExtendedCommitInfo {
&self.extended_commit_info
}

#[must_use]
pub fn id_to_currency_pair(&self) -> &IndexMap<CurrencyPairId, CurrencyPair> {
&self.id_to_currency_pair
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd remove these two getters as the struct's fields are public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants