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

enable sending BpMevMatches and ProposalReceiveTime to MEV indexer #840

Merged
merged 2 commits into from
Dec 5, 2023

Conversation

lucas-dydx
Copy link
Contributor

@lucas-dydx lucas-dydx commented Dec 5, 2023

Changelist

Duplicate of #832, but committed from my account so that the commits are signed.

Also updated indexer protos to fix indexer proto verification workflow.

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Copy link
Contributor

coderabbitai bot commented Dec 5, 2023

Walkthrough

The updates across various files indicate an expansion of the MevNodeToNodeMetrics data structure to include new metrics related to block proposer MEV matches (bpMevMatches) and the time a proposal is received (proposalReceiveTime). These changes reflect a broader scope for tracking and analyzing Miner Extractable Value (MEV) within the system, providing more detailed insights into MEV dynamics and the behavior of validators and block proposers.

Changes

File Path Change Summary
indexer/.../clob/mev.ts Added bpMevMatches and proposalReceiveTime to interfaces; updated createBaseMevNodeToNodeMetrics function; modified encoding/decoding logic.
proto/.../mev.proto Introduced bp_mev_matches and proposal_receive_time fields to MevNodeToNodeMetrics message.
protocol/x/clob/keeper/mev.go Twice listed, but the same change: Added BpMevMatches and ProposalReceiveTime to MevNodeToNodeMetrics struct.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 11fd8a0 and 9d72ff6.
Files ignored due to filter (1)
  • protocol/x/clob/types/mev.pb.go
Files selected for processing (2)
  • indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/mev.ts (6 hunks)
  • proto/dydxprotocol/clob/mev.proto (1 hunks)
Additional comments: 7
indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/mev.ts (6)
  • 94-99: The addition of bpMevMatches and proposalReceiveTime to the MevNodeToNodeMetrics interface aligns with the PR objectives to include these properties for MEV indexing.

  • 105-110: The addition of bp_mev_matches and proposal_receive_time to the MevNodeToNodeMetricsSDKType interface aligns with the PR objectives to include these properties for MEV indexing.

  • 452-458: The createBaseMevNodeToNodeMetrics function has been correctly updated to initialize the new properties bpMevMatches and proposalReceiveTime.

  • 468-477: The encoding logic for MevNodeToNodeMetrics has been correctly updated to include the new properties bpMevMatches and proposalReceiveTime.

  • 496-504: The decoding logic for MevNodeToNodeMetrics has been correctly updated to include the new properties bpMevMatches and proposalReceiveTime.

  • 517-522: The fromPartial method for MevNodeToNodeMetrics has been correctly updated to handle the new properties bpMevMatches and proposalReceiveTime.

proto/dydxprotocol/clob/mev.proto (1)
  • 57-62: The changes from lines 57 to 62 correctly introduce the new fields bp_mev_matches and proposal_receive_time to the MevNodeToNodeMetrics message as described in the PR objectives and the AI-generated summaries. Ensure that all dependent systems that consume or produce MevNodeToNodeMetrics messages are updated to handle these new fields.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9d72ff6 and a16195e.
Files selected for processing (1)
  • protocol/x/clob/keeper/mev.go (1 hunks)

Comment on lines 345 to 350
MevNodeToNode: types.MevNodeToNodeMetrics{
ValidatorMevMatches: validatorMevMatches,
ClobMidPrices: mevClobMidPrices,
BpMevMatches: blockProposerMevMatches,
ProposalReceiveTime: uint64(time.Now().Second()),
},
Copy link
Contributor

Choose a reason for hiding this comment

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

The ProposalReceiveTime is being set to the current second using time.Now().Second(). This may not provide a granular enough timestamp for some use cases, as it will only capture the second part of the current time, not the full timestamp. Consider using time.Now().UnixNano() to capture a more precise timestamp in nanoseconds since the Unix epoch.

- ProposalReceiveTime: uint64(time.Now().Second()),
+ ProposalReceiveTime: uint64(time.Now().UnixNano()),

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
MevNodeToNode: types.MevNodeToNodeMetrics{
ValidatorMevMatches: validatorMevMatches,
ClobMidPrices: mevClobMidPrices,
BpMevMatches: blockProposerMevMatches,
ProposalReceiveTime: uint64(time.Now().Second()),
},
MevNodeToNode: types.MevNodeToNodeMetrics{
ValidatorMevMatches: validatorMevMatches,
ClobMidPrices: mevClobMidPrices,
BpMevMatches: blockProposerMevMatches,
ProposalReceiveTime: uint64(time.Now().UnixNano()),
},

@lucas-dydx lucas-dydx merged commit 56d653a into main Dec 5, 2023
31 of 32 checks passed
@lucas-dydx lucas-dydx deleted the lucas-dydx/skip-enable-sending-bp-matches branch December 5, 2023 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants