-
Notifications
You must be signed in to change notification settings - Fork 353
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(rollapp): allow rollapps with no native token #1654
Conversation
3dd0742
to
1e42c03
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1654 +/- ##
==========================================
+ Coverage 22.59% 22.62% +0.02%
==========================================
Files 590 590
Lines 129299 129316 +17
==========================================
+ Hits 29217 29254 +37
+ Misses 96191 96176 -15
+ Partials 3891 3886 -5 ☔ View full report in Codecov by Sentry. |
return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "genesis bridge data: to IBC denom")) | ||
// handle rollapp's denom metadata | ||
var raDenomOnHUb string | ||
if genesisBridgeData.GenesisInfo.NativeDenom.IsSet() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you comment this a bit more in detail
for _, data := range genesisPackets { | ||
if err := w.transferKeeper.OnRecvPacket(ctx, packet, data); err != nil { | ||
return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "handle genesis transfer")) | ||
} | ||
} | ||
|
||
err = w.EnableTransfers(ctx, packet, ra, denom.Base) | ||
err = w.EnableTransfers(ctx, packet, ra, raDenomOnHUb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if genesisBridgeData.GenesisInfo.NativeDenom.IsSet() == false
, raDenomOnHUb
would be empty string, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right. as the rollapp doesn't have native denom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just making sure that w.EnableTransfers
is ok with empty string, and also the event below
x/rollapp/types/genesis_info.go
Outdated
@@ -33,14 +33,32 @@ func (gi GenesisInfo) GenesisTransferAmount() math.Int { | |||
return total | |||
} | |||
|
|||
// native denom is optional | |||
func (gi GenesisInfo) AllSet() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AllSet
might not be an appropriate name for this method anymore, since it doesn't check NativeDenom
anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to Launchable
if _, exists := accountSet[a.Address]; exists { | ||
return fmt.Errorf("duplicate genesis account: %s", a.Address) | ||
|
||
if gi.InitialSupply.IsNil() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if InitialSupply is zero here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fail in if total.GT(gi.InitialSupply) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you maybe leave a comment about it, just to remove doubt
x/rollapp/types/genesis_info.go
Outdated
if a.Amount.IsNil() { | ||
return fmt.Errorf("invalid amount: %s", a.Address) | ||
} | ||
|
||
if !a.Amount.IsPositive() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two checks can be merged into one
x/rollapp/types/genesis_info.go
Outdated
if !gi.InitialSupply.IsNil() && !gi.InitialSupply.IsZero() { | ||
return ErrNoNativeTokenRollapp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems that the error here is not really the lack of native denom, but the fact that initial supply is non-zero while having no native tokens.
x/rollapp/types/genesis_info.go
Outdated
if l := len(gi.Accounts()); l > 0 { | ||
return ErrNoNativeTokenRollapp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, for accounts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
x/rollapp/types/genesis_info.go
Outdated
} else { | ||
// if native denom is not set, initial supply must be 0 and no accounts | ||
if !gi.InitialSupply.IsNil() && !gi.InitialSupply.IsZero() { | ||
return ErrNoNativeTokenRollapp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ErrNoNativeTokenRollapp | |
return ErrInvalidInitialSupply |
x/rollapp/types/genesis_info.go
Outdated
if !gi.InitialSupply.IsPositive() { | ||
return ErrInvalidInitialSupply | ||
if l := len(gi.Accounts()); l > 0 { | ||
return ErrNoNativeTokenRollapp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ErrNoNativeTokenRollapp | |
return ErrTooManyGenesisAccounts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should document on genesis info and genesis bridge info protos that native denom can be zero type, and why
- should doc no IRO plan possible for such rollapps
return errorsmod.Wrapf( | ||
errors.Join(gerrc.ErrInvalidArgument, err), | ||
"invalid genesis info", | ||
) | ||
} | ||
|
||
if !m.NewGenesisInfo.AllSet() { | ||
if !m.NewGenesisInfo.Launchable() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
launchable is somewhat misleading, since rollapp is not launchable until after. pre launch time, which is not included
needs a better docstring
if update.GenesisInfo != nil { | ||
if update.GenesisInfo.GenesisChecksum != "" { | ||
current.GenesisInfo.GenesisChecksum = update.GenesisInfo.GenesisChecksum | ||
} | ||
|
||
if update.GenesisInfo.Bech32Prefix != "" { | ||
current.GenesisInfo.Bech32Prefix = update.GenesisInfo.Bech32Prefix | ||
} | ||
|
||
if update.GenesisInfo.NativeDenom.Base != "" { | ||
current.GenesisInfo.NativeDenom = update.GenesisInfo.NativeDenom | ||
} | ||
|
||
if !update.GenesisInfo.InitialSupply.IsNil() { | ||
current.GenesisInfo.InitialSupply = update.GenesisInfo.InitialSupply | ||
} | ||
|
||
// Frontend always passes new value | ||
current.GenesisInfo.GenesisAccounts = update.GenesisInfo.GenesisAccounts | ||
current.GenesisInfo = *update.GenesisInfo | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this definitely fine?
// It also calls the after transfers enabled hook (used to settle IRO plans) | ||
func (w IBCModule) EnableTransfers(ctx sdk.Context, packet channeltypes.Packet, ra *types.Rollapp, rollappIBCtrace string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should say it can be empty
x/rollapp/types/genesis_info.go
Outdated
if l := len(gi.Accounts()); l > 0 { | ||
return errorsmod.Wrap(ErrNoNativeTokenRollapp, "non empty genesis accounts") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why define l
// if native denom is not set, initial supply must be 0 and no accounts | ||
if !gi.NativeDenom.IsSet() { | ||
if !gi.InitialSupply.IsNil() && !gi.InitialSupply.IsZero() { | ||
return errorsmod.Wrap(ErrNoNativeTokenRollapp, "non zero initial supply") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't check initial supply is zero, since it can be nil
if total.GT(gi.InitialSupply) { | ||
return ErrInvalidInitialSupply | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not !=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supply != genesis bridge transfers (e.g can have 1B tokens with 1M transferred on genesis)
// genesis info is not validated here, as we allow to update partial fields | ||
// it will be validated when trying to apply the update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine grained update is removed now though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved,
check #1654 (comment)
(cherry picked from commit a9d5d6b)
Description
Closes #XXX
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.
PR review checkboxes:
I have...
Unreleased
section inCHANGELOG.md
godoc
commentsSDK Checklist
map
time.Now()
sendCoin
and notSendCoins
Full security checklist here
For Reviewer:
After reviewer approval: