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

Store the base asset id in the metadata #781

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

xgreenx
Copy link
Collaborator

@xgreenx xgreenx commented Jun 21, 2024

Having the base asset id allows to get the base asset balance by just using metadata without consensus parameters.

Before requesting review

  • I have reviewed the code myself

@xgreenx xgreenx requested a review from a team June 21, 2024 18:10
@xgreenx xgreenx self-assigned this Jun 21, 2024
Copy link
Member

@MitchTurner MitchTurner left a comment

Choose a reason for hiding this comment

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

Why do we need to get the asset id without consensus params?

This seems like a harmless change, but it's also redundant, so I just want to understand the justification. It's not like the base asset will be different for txs in a block or likely ever change for the chain.

@xgreenx
Copy link
Collaborator Author

xgreenx commented Jun 21, 2024

It is possible to change the base asset id via consensus parameters.

While checked transactions live inside of the memory pool, consensus parameters could change. When we try to ask for a transaction about its base asset balance, it will return the wrong value.

Another reason for the change is to make the Checked transaction self-contained. You can request the base balance without providing the consensus parameters.

Taking into account that each time to get the latest consensus parameters, we need to lock and clone the consensus parameters from the cache, it will not affect performance.

@xgreenx xgreenx enabled auto-merge June 21, 2024 18:27
@xgreenx xgreenx requested review from MitchTurner and a team June 21, 2024 18:30
@MitchTurner
Copy link
Member

But we don't want to let a tx submitter just choose some arbitrary base asset. I guess we are going to still check that the base asset is correct for the block when we call into_ready, maybe?

@xgreenx
Copy link
Collaborator Author

xgreenx commented Jun 21, 2024

The TX submitter can't choose it. We cached the value from consensus parameters. The Checked transactions created within the node=)

In the same way, we could just case base_asset_amount. But having a base asset it is more flexible.

Copy link
Member

@MitchTurner MitchTurner left a comment

Choose a reason for hiding this comment

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

Looks good assuming we implement the things we talked about offline.

@xgreenx xgreenx added this pull request to the merge queue Jun 21, 2024
Merged via the queue into master with commit b349da1 Jun 21, 2024
39 checks passed
@xgreenx xgreenx deleted the feature/add-access-to-base-asset-id branch June 21, 2024 19:33
@xgreenx xgreenx mentioned this pull request Jul 4, 2024
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.

2 participants