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(x/ecocredit): update batch proto to support dynamic minting #937

Merged
merged 25 commits into from
Apr 5, 2022

Conversation

robert-zaremba
Copy link
Collaborator

@robert-zaremba robert-zaremba commented Mar 25, 2022

Description

Closes: #924


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@robert-zaremba robert-zaremba added the Scope: x/ecocredit Issues that update the x/ecocredit module label Mar 25, 2022
x/ecocredit/go.mod Outdated Show resolved Hide resolved
@ryanchristo
Copy link
Member

The name of the branch and the title of the pull request are basket-mint but this does not have anything to do with baskets. Can you please update and use the appropriate type prefix. Thanks!

@clevinson
Copy link
Member

Can we reduce this PR to just updated proto files (no codegen files, and no stubs implementing interfaces, etc.)?

I think if its only a PR with proto files for now then it will be a great companion to the #924 issue so we can talk concretely about what an implementation hypothetically would look like.

@clevinson clevinson changed the title Robert/basket mint Update batches to support dynamic minting Mar 28, 2022
@robert-zaremba robert-zaremba changed the title Update batches to support dynamic minting Feat: update ecocredit batch proto to support dynamic minting Mar 28, 2022
@robert-zaremba robert-zaremba changed the title Feat: update ecocredit batch proto to support dynamic minting feat: update ecocredit batch proto to support dynamic minting Mar 28, 2022
@robert-zaremba
Copy link
Collaborator Author

Reducing this PR only to proto updates.

@robert-zaremba robert-zaremba marked this pull request as ready for review March 28, 2022 20:18
@codecov
Copy link

codecov bot commented Mar 28, 2022

Codecov Report

Merging #937 (0161a5a) into master (4c52522) will increase coverage by 0.02%.
The diff coverage is 7.69%.

@@            Coverage Diff             @@
##           master     #937      +/-   ##
==========================================
+ Coverage   72.97%   73.00%   +0.02%     
==========================================
  Files         206      210       +4     
  Lines       23350    23363      +13     
==========================================
+ Hits        17039    17055      +16     
+ Misses       4968     4951      -17     
- Partials     1343     1357      +14     
Flag Coverage Δ
experimental-codecov 72.87% <7.69%> (-0.01%) ⬇️
stable-codecov 67.80% <7.69%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

// enable_future_minting tells if it's possible to mint new credits in
// the future. Once the enable_future_minting is set to false, it can't be
// toggled any more.
bool enable_future_minting = 8;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if we have enable_future_minting, max_supply is not needed any more. so I removed max_supply.

Copy link
Member

Choose a reason for hiding this comment

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

I actually think the default should be sealed. So if we want a different name let's use open

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's in the state, so we control the defaults. Good naming is a challenge.
If we want to rename this, then let's use open everywhere.

// the id of a transaction based on a type (tx id, serial number)
string id = 2;
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both, the note and origin_tx will service the accounting purpose.

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

Generally looks good. I think minting permissions should be more restrictive

proto/regen/ecocredit/v1/tx.proto Outdated Show resolved Hide resolved
proto/regen/ecocredit/v1/tx.proto Show resolved Hide resolved
proto/regen/ecocredit/v1/tx.proto Show resolved Hide resolved
proto/regen/ecocredit/v1/tx.proto Outdated Show resolved Hide resolved
@robert-zaremba
Copy link
Collaborator Author

  • changed enable_future_minting to sealed
  • updated docs
  • added issuer to BatchInfo

string note = 3;

// batch_denom is the unique ID of the credit batch.
string batch_denom = 4;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Normally I would prefer to not storing everything. We have events to keep that information. But events are not guaranteed to be permanent.
So ideally we don't store everything here and we sort out the events in SDK.

What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in fact, since I'm adding this fields here, I've slimmed down the EventMintBatchCredits event

@ryanchristo
Copy link
Member

ryanchristo commented Apr 2, 2022

When writing the proto API for new features, we should either include dummy implementation methods or comment out any new rpc methods that will cause tests to fail after generating the proto files.

Ideally changes to the existing API would not be made in the same pull request, which would prevent the need to update any code in the existing implementation. In cases like this where BatchIssuance is being pulled out of BatchInfo, we should generate the proto files and make sure the necessary changes are made in the existing implementation.

A potential process for designing new features starting with proto API updates:

  1. a pull request is created with only proto API definitions
  2. the pull request is reviewed and the design is approved
  3. the proto files are generated and a dummy implementation is added (e.g. a dummy implementation for MintBatchCredits) and the minimal changes required to successfully build and and run tests are made (e.g. updating any existing references of MsgCreateBatch_BatchIssuance to BatchIssuance).

@ryanchristo ryanchristo changed the title feat: update ecocredit batch proto to support dynamic minting feat(x/ecocredit): update batch proto to support dynamic minting Apr 2, 2022
@ryanchristo ryanchristo removed the Scope: x/ecocredit Issues that update the x/ecocredit module label Apr 2, 2022
Comment on lines 205 to 208
// open=true keeps the batch unlocked for future minting.
// Othrwise we will seal the batch after the mint.
// Throws an error if the batch is already sealed.
bool open = 4;
Copy link
Member

Choose a reason for hiding this comment

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

Could we update this to actually be a separate message? I think in most use cases (thinking of bridges), the issuer won't actually ever want to seal the batch. Adding this here requires the user to explicitly set this value every time they call MsgMintBatchCredits, and if they forget, then it would lock the batch and prevent the issuer from being able to issue more credits to that vintage (assuming we have the appropriate restrictions on project <> credit type duplicate issuances).

I think I'd rather see something like:

message MsgSealBatch {
  string issuer = 1;
}

Copy link
Member

Choose a reason for hiding this comment

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

@aaronc I know you had initially proposed this bool open = 4; what do you think of this upgrade?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it makes that big of a difference. This should all be done automatically anyway. But I don't object

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yesterday we had a session with Cory about the process and we found that it would make sense to separate the toggle functionality to a separate message. So if nobody objects I will make the update.

@clevinson
Copy link
Member

I think the proto gen stubs suggested from @ryanchristo makes sense.

Im happy to give a concept ACK on the general design now- the only api change i'd still like to see is a MsgSealBatch message separated out.

@robert-zaremba can you add go stubs and address the related go changes to prevent tests from breaking?

@robert-zaremba
Copy link
Collaborator Author

robert-zaremba commented Apr 5, 2022

Sorry but we are going back and forth without being constructive. 2 weeks ago I started with basic implementation for Msg methods and wanted to add dummy implementation for the RPC implementation while waiting for reviews (which would prevent troubles when someone generates the code and introduces additional changes). It got a criticism (#937 (comment) and and discord) to ONLY do proto code (so NO code generation and NO other methods).

The tests are not breaking because this PR doesn't include generated code.

Now, I prefer to merge this PR and do other PR with implementation to not hold on this PR any more.

@robert-zaremba
Copy link
Collaborator Author

I've added MsgSealBatch

@ryanchristo
Copy link
Member

Sorry but we are going back and forth without being constructive. 2 weeks ago I started with basic implementation for Msg methods and wanted to add dummy implementation for the RPC implementation while waiting for reviews (which would prevent troubles when someone generates the code and introduces additional changes). It got a criticism (#937 (comment) and and discord) to ONLY do proto code (so NO code generation and NO other methods).

I just want to start out by saying I really appreciate all the work you are doing with this new feature. I do think this has been constructive despite some back and forth.

I could be wrong, but if I recall correctly, there was more than a simple dummy implementation in the original changes (I am unable to verify due to force push). Either way, we want to start with only the proto definitions, and then once the design is approved, we would generate proto files and add the dummy implementation, and if necessary, minimal changes to make build and tests pass.

If we don't generate and make minimal changes, we will block other pull requests that are making changes to the proto files, which will need to generate proto and implement the missing messages from this pull request. I can add the dummy implementation to help move this along given the design has been approved.

@clevinson clevinson merged commit bb2f17c into master Apr 5, 2022
@clevinson clevinson deleted the robert/basket-mint branch April 5, 2022 17:27
@clevinson
Copy link
Member

Sorry about the back & forth @robert-zaremba, but I also remembered a bit more than dummy implementation in what you originally was putting forward (I think I remember some implementation work as well). Happy to have this merged now, and let's discuss maybe on one of our next dev calls to make sure we're not going back and forth too much with process around proto PRs as design.

@glandua
Copy link

glandua commented Apr 5, 2022

Great work Robert. Although I was originally pretty restrained about the dynamic batch approach, I am quite pleased how this has turned out.

@robert-zaremba
Copy link
Collaborator Author

@ryanchristo , @clevinson there was:

basic implementation for Msg methods

@robert-zaremba
Copy link
Collaborator Author

thanks for merging! 🍻

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.

Extend Credit Batch functionality to allow dynamic minting
5 participants