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: Configurable Base Asset ID #573

Merged
merged 20 commits into from
Sep 7, 2023

Conversation

bvrooman
Copy link
Contributor

@bvrooman bvrooman commented Aug 29, 2023

Related issues:

@bvrooman bvrooman self-assigned this Aug 29, 2023
@bvrooman bvrooman changed the title Configurable Base Asset ID feat: Configurable Base Asset ID Aug 30, 2023
@bvrooman bvrooman requested a review from a team August 31, 2023 05:37
@bvrooman bvrooman marked this pull request as ready for review August 31, 2023 05:38
@Dentosal
Copy link
Member

Surprisingly clean changeset, I expected this was hardcoded in more places. I'm not sure wheter we need more test coverage to protect against possible issues with this, mostly because I don't know what ares would beed testing. Generally this looks good to me, and the only potential issue I found is this:

Does this part of the code use AssetId::default() for a good reason?

Output::Change { asset_id, .. }
if asset_id != &AssetId::default()
&& input_asset_id == asset_id =>
{
Some(())
}

@bvrooman
Copy link
Contributor Author

bvrooman commented Aug 31, 2023

Does this part of the code use AssetId::default() for a good reason?

Going forward, AssetId::default() should only be used in tests. Now that it's part of the consensus parameters, a default Asset ID isn't really meaningful, and is not tied to the configured value. Rather, it's just a convenience function that produces "some" Asset ID that can be used in tests.

I will create a tech-debt ticket to place the impl Default under a cfg(test) compile guard, or replace default with a test-specific name, like test_default(). Issue here: #577

Dentosal
Dentosal previously approved these changes Sep 1, 2023
Copy link
Member

@Dentosal Dentosal left a comment

Choose a reason for hiding this comment

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

LGTM; would appreciate another review as well as I might have missed something

@bvrooman bvrooman requested a review from a team September 1, 2023 15:11
@Voxelot
Copy link
Member

Voxelot commented Sep 4, 2023

@bvrooman looks like there's some new clippy lints after merging master

Dentosal
Dentosal previously approved these changes Sep 5, 2023
Copy link
Member

@Dentosal Dentosal left a comment

Choose a reason for hiding this comment

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

I still would appreciate another reviewer, but I think this is good to go.

@MitchTurner
Copy link
Member

I'm curious why the asset id ended up on the "fee" configs. Seems like a misleading name at least. I'll read through the code a bit, but I assume that it's used in similar places as the fee stuff.

@bvrooman
Copy link
Contributor Author

bvrooman commented Sep 5, 2023

I'm curious why the asset id ended up on the "fee" configs. Seems like a misleading name at least. I'll read through the code a bit, but I assume that it's used in similar places as the fee stuff.

As I understand it, fees are generally paid in the base asset. So we can assert that the asset we use for fees is the base asset throughout the VM. In a lot of areas, we hardcoded this assumption (using AssetId::BASE). But it's conceivable that fees can be paid in other assets, like a native token, and we can configure that.

@MitchTurner
Copy link
Member

MitchTurner commented Sep 5, 2023

As I understand it, fees are generally paid in the base asset. So we can assert that the asset we use for fees is the base asset throughout the VM. In a lot of areas, we hardcoded this assumption (using AssetId::BASE). But it's conceivable that fees can be paid in other assets, like a native token, and we can configure that.

Yeah. I guess that makes sense in the context of places that are dealing with fees.
I feel like the base asset is relevant to more places than just fees though. So I'd be comfortable if it was just its own field on ConsensusParameters. Thoughts?

@bvrooman
Copy link
Contributor Author

bvrooman commented Sep 5, 2023

As I understand it, fees are generally paid in the base asset. So we can assert that the asset we use for fees is the base asset throughout the VM. In a lot of areas, we hardcoded this assumption (using AssetId::BASE). But it's conceivable that fees can be paid in other assets, like a native token, and we can configure that.

Yeah. I guess that makes sense in the context of places that are dealing with fees. I feel like the base asset is relevant to more places than just fees though. So I'd be comfortable if it was just its own field on ConsensusParameters. Thoughts?

I can understand motivation behind moving it to the top level in ConsensusParameters. I think that is worth exploring. If anyone else feels strongly about this, please feel free to weigh in. In the meantime, I will try it out locally to see how that looks.

@bvrooman
Copy link
Contributor Author

bvrooman commented Sep 6, 2023

I pushed a commit that moves base_asset_id to the root of ConsensusParameters. This was fairly straightforward. It did introduce extra plumbing, since we now have to pass base_asset_id along with other fee parameters in some areas. But overall, the changes are minor.

Copy link
Member

@Voxelot Voxelot left a comment

Choose a reason for hiding this comment

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

lgtm - i also participated in pairing on this and already familiar with the changes.

@bvrooman bvrooman added this pull request to the merge queue Sep 7, 2023
Merged via the queue into master with commit 5030f96 Sep 7, 2023
33 checks passed
@bvrooman bvrooman deleted the bvrooman/feat/configurable-base-asset-id branch September 7, 2023 02:52
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.

4 participants