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
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
19e9506
feat: update ecocredit batch proto for dynamic minting
robert-zaremba Mar 28, 2022
f59cc0c
Merge branch 'master' into robert/basket-mint
robert-zaremba Mar 28, 2022
2afd92f
Merge branch 'master' into robert/basket-mint
robert-zaremba Mar 28, 2022
6a401ca
Merge branch 'master' into robert/basket-mint
robert-zaremba Mar 31, 2022
19d90da
Update MintBatch
robert-zaremba Mar 31, 2022
ff27970
remove max_supply
robert-zaremba Mar 31, 2022
fdbaf9a
Apply suggestions from code review
robert-zaremba Mar 31, 2022
286bfcc
use sealed instead of enable_future_minting
robert-zaremba Mar 31, 2022
d005b03
store batch creator address
robert-zaremba Mar 31, 2022
86873b2
rename sealed to unlocked
robert-zaremba Mar 31, 2022
e7b570c
Apply suggestions from code review
robert-zaremba Apr 1, 2022
18ccb52
renane unlocked to open
robert-zaremba Apr 2, 2022
7269996
adding origin_tx to MsgBatchCreate
robert-zaremba Apr 2, 2022
67393d5
update MsgMintBatch and MsgCreateBatch and add misisng events
robert-zaremba Apr 2, 2022
d141133
rename MintBatch to MintBatchCredits
robert-zaremba Apr 2, 2022
b5c8ad4
create BatchOrigTx index
robert-zaremba Apr 2, 2022
41eca96
Merge remote-tracking branch 'origin/master' into robert/basket-mint
robert-zaremba Apr 2, 2022
1cef6d1
add all orig tx info to the OrigTx index
robert-zaremba Apr 2, 2022
ee04a29
slim down EventMintBatchCredits - we moved some data to BatchOrigTx i…
robert-zaremba Apr 2, 2022
9035092
Merge branch 'master' into robert/basket-mint
aaronc Apr 4, 2022
a7d6323
add MsgSealBatch
robert-zaremba Apr 5, 2022
5977f4b
fix state proto
robert-zaremba Apr 5, 2022
694a82a
generate proto
ryanchristo Apr 5, 2022
087c0c3
add dummy implementation
ryanchristo Apr 5, 2022
0161a5a
update batch issuance
ryanchristo Apr 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions proto/regen/ecocredit/v1/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ message BatchInfo {

// issuance_date is the timestamp when the credit batch was issued.
google.protobuf.Timestamp issuance_date = 7;

// issuer is an account address which created the batch and which is
// authorized to issue more credits if sealed=false.
string issuer = 8;

// locked tells if it's possible to mint new credits in the future.
// Once the locked is set to true, it can't be toggled any more.
bool locked = 9;
}
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.


// ClassSequence is a sequence number for creating credit class identifiers for
Expand Down
87 changes: 67 additions & 20 deletions proto/regen/ecocredit/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ service Msg {
// be distributed to recipients in either tradable or retired form.
rpc CreateBatch(MsgCreateBatch) returns (MsgCreateBatchResponse);

// MintBatch issues new token in a given batch.
// The issuer must be the account who created (or delegated using x/authz),
// the batch.
// The request will fail if the batch is locked.
// NOTE: this method is only for bridge purpose. It must not be used
// for issuing native credits on Regen. More specifically, we
// enable minting more credits in an existing batch, when the batch
// represents a vintage originally registered in another chain.
rpc MintBatch(MsgMintBatch) returns (MsgMintBatchResponse);

// Send sends tradable credits from one account to another account. Sent
// credits can either be tradable or retired on receipt.
rpc Send(MsgSend) returns (MsgSendResponse);
Expand Down Expand Up @@ -133,30 +143,34 @@ message MsgCreateBatch {
// quantified and verified.
google.protobuf.Timestamp end_date = 6 [ (gogoproto.stdtime) = true ];

// BatchIssuance represents the issuance of some credits in a batch to a
// single recipient.
message BatchIssuance {
// If unlocked is set to true, we will seal the batch and disable the
// future minting.
bool unlocked = 7;
}

// recipient is the account of the recipient.
string recipient = 1;
// BatchIssuance represents the issuance of some credits in a batch to a
// single recipient.
message BatchIssuance {

// tradable_amount is the number of credits in this issuance that can be
// traded by this recipient. Decimal values are acceptable.
string tradable_amount = 2;
// recipient is the account of the recipient.
string recipient = 1;

// retired_amount is the number of credits in this issuance that are
// effectively retired by the issuer on receipt. Decimal values are
// acceptable.
string retired_amount = 3;
// tradable_amount is the number of credits in this issuance that can be
// traded by this recipient. Decimal values are acceptable.
string tradable_amount = 2;

// retirement_location is the location of the beneficiary or buyer of the
// retired credits. This must be provided if retired_amount is positive. It
// is a string of the form
// <country-code>[-<sub-national-code>[ <postal-code>]], with the first two
// fields conforming to ISO 3166-2, and postal-code being up to 64
// alphanumeric characters.
string retirement_location = 4;
}
// retired_amount is the number of credits in this issuance that are
// effectively retired by the issuer on receipt. Decimal values are
// acceptable.
string retired_amount = 3;

// retirement_location is the location of the beneficiary or buyer of the
// retired credits. This must be provided if retired_amount is positive. It
// is a string of the form
// <country-code>[-<sub-national-code>[ <postal-code>]], with the first two
// fields conforming to ISO 3166-2, and postal-code being up to 64
// alphanumeric characters.
string retirement_location = 4;
}

// MsgCreateBatchResponse is the Msg/CreateBatch response type.
Expand All @@ -165,6 +179,39 @@ message MsgCreateBatchResponse {
string batch_denom = 1;
}

// MsgMintBatch is a request type for MintBatch Msg RPC.
message MsgMintBatch {
// Issuer must equal to the batch.issuer address.
// Signer of the msg.
string issuer = 1;

// issuance are the credits issued in the batch.
repeated BatchIssuance issuance = 2;
Copy link
Member

Choose a reason for hiding this comment

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

If there are multiple BatchIssuances for a given MsgMintBatch is it expected that they all have the same origin_tx?

We could alternatively evaluate nesting origin_tx inside BatchIssuance message, so that an on-chain minting event can batch together multiple issuances (coming from multiple different bridge transactions). This may be suboptimal though, as leveraging events becomes quite cumbersome and annoying if in the current event system if we have multiple event attributes corresponding to different origin bridge transactions for one SDK tx.

Also- do we need to support origin_tx information in MsgCreateBatch() in cases where a bridge action triggers a new batch creation? Or do we expect that the bridge creator does not mint any credits when they create a new batch for a bridge (so all minting of credits via a bridge always happen through a MsgMintBatch() call).

I see a few options:

All issuances from bridges must happen through MsgMintBatch()

In this case, we don't need origin_tx information in MsgCreateBatch(), and we should make sure we have some on-chain validation that MsgCreateBatch() fails if sealed == false and issuance != nil.

Allow issuances from bridges in MsgCreateBatch()

In this case, we should add origin_tx into MsgCreateBatch()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also- do we need to support origin_tx information in MsgCreateBatch() in cases where a bridge action triggers a new batch creation?

Good point. yes!

Copy link
Collaborator Author

@robert-zaremba robert-zaremba Apr 2, 2022

Choose a reason for hiding this comment

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

I've updated the MsgCreatBatch - so bridge will create a batch and mint at the same time. Also it will make it clear if the batch creation done with a related transfer / minting or not. It will be consistent with the minting we have now. Subsequent mints will use MsgMintBatch


// A reference to a transaction or an event referencing the transaction
// which caused the transfer from other chain or registry.
OriginTx origin_tx = 3;

// reference note for accounting, will be passed to an event
string note = 4;

// If unlocked=true keeps the batch unlocked for future minting.
// Othrwise it will lock the batch after the mint.
// Will throw an error if the batch is already locked.
bool unlocked = 5;

message OriginTx {
// type of the transaction originating the mint process. Eg: Polygon,
// Ethereum, Verra,
string typ = 1;
// 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.


// MsgMintBatchResponse is the Msg/MintBatch response type.
message MsgMintBatchResponse {}

// MsgSend is the Msg/Send request type.
message MsgSend {

Expand Down