-
Notifications
You must be signed in to change notification settings - Fork 373
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(stdlibs/std)!: namespace minted coins with realm path #875
feat(stdlibs/std)!: namespace minted coins with realm path #875
Conversation
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.
Hi @r3v4s, we discussed on how to best tackle this, both to try avoiding duplicating std
into internal/std
and also to have the code here effectively make sense.
Let's work to do this instead:
- Remove
stdlibs/internal/std
and the current changes tostdlibs.go
(to add PrevRealm to internal/std) - Create a new type of banker inside of
stdlibs/banker.go
, calledRealmIssueBanker
.- This shall be returned by the native
GetBanker
withBankerType
BankerTypeRealmIssue
- The realm is initialized with the PrevRealm values
pkgPath
andaddr
. Maybe split out the internal code ofPrevRealm
(with the for-loop etc.) into a function which returns 2 strings:(pkgPath, addr string)
- This shall be returned by the native
- When
RealmIssueBanker.IssueCoins
is called, you add the code you inserted intognovm/stdlibs/std/banker.gno
, and you remove it from there.
WDYT?
Thanks!
@thehowl Looking good! That will remove inevitable use of code redundancy and logic will be more simple. Will work on that // UPDATE |
4a067d5
to
040fdd1
Compare
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.
gno.land/cmd/gnoland/testdata/realm-banker-issued-coin-denom.txtar
Outdated
Show resolved
Hide resolved
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.
I am approving these changes, because this PR has been stuck in review forever and it already does an important step in the right direction. Please, tackle these last comments and we're good to go. Sorry for the long wait.
That said, soon after this is merged, I think we'll need to change this API again. This current implementation creates an inconsistency within the Banker API. All other banker methods now require you to pass in the full realm path to the token you're referring to, but IssueCoin and RemoveCoin do not.
Thus, I think a few more changes are in order:
- There should be a
RealmDenom(pkgpath, denom string)
function instd
, which creates a realm denomination (ie./gno.land/r/morgan:bitcoin
). There can be a helper methodRealm.Denom(denom string)
(so you can dostd.CurrentRealm().Denom("bitcoin")
- Instead of modifying
denom
's value in the native function, we should check it matches what we expect. ie.strings.HasPrefix(denom, RealmDenom(std.CurrentRealm().PkgPath())
, then check the last part of the denom to see that it matches the Gno regex. (This can all be done in gno, without needing to put it in native code)
This should make it more consistent & easier to use realm denominations. Still, it's a UX issue, while this one tackles what is effectively a security issue; so let's start from here.
gno.land/cmd/gnoland/testdata/realm-banker-issued-coin-denom.txtar
Outdated
Show resolved
Hide resolved
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.
Sorry. The test LGTM
<!-- Please provide a brief summary of your changes in the Title above --> # Previous & Related PR gnolang#393 # Description ## BREAKING CHANGE: banker will not use raw(input) denom for minting Currently, there is a bug that additional coins are mintable using banker. Lots of discussing were made in gnolang#393, this PR include following. 1. It aims to use `pkg_path` that called (banker or Mint) as prefix for denom(Similar to IBC Spec) ``` ibc_denom := 'ibc/' + hash('path' + 'base_denom') denom_in_this_pr := '{pkg_path}:denom' ``` ~2. As @piux2 mentioned [here](gnolang#393 (comment)) currently gno has very inflexible format regexp for denom -- Changed to same as Cosmos's regex, but without capitals~ ~### is some issue about using `std.GetOrigCaller` or `std.PrevRealm` Some of you might be wonder why I made some packaged called `istd`, I made a issue: gnolang#876~ Update: After @thehowl's native binding PR, doesn't need this kind of work around ## Contributors Checklist - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests ## Maintainers Checklist - [ ] Checked that the author followed the guidelines in `CONTRIBUTING.md` - [ ] Checked the conventional-commit (especially PR title and verb, presence of `BREAKING CHANGE:` in the body) - [ ] Ensured that this PR is not a significant change or confirmed that the review/consideration process was appropriate for the change --------- Co-authored-by: Morgan <[email protected]>
Introduced in #875, but only managed to review after it was merged.
…#2106) Introduced in gnolang#875, but only managed to review after it was merged.
Just to avoid [this comment](#875 (comment)) again :)
Previous & Related PR
#393
Description
BREAKING CHANGE: banker will not use raw(input) denom for minting
Currently, there is a bug that additional coins are mintable using banker.
Lots of discussing were made in #393, this PR include following.
pkg_path
that called (banker or Mint) as prefix for denom(Similar to IBC Spec)2. As @piux2 mentioned here currently gno has very inflexible format regexp for denom-- Changed to same as Cosmos's regex, but without capitals
### is some issue about usingstd.GetOrigCaller
orstd.PrevRealm
Some of you might be wonder why I made some packaged called
istd
, I made a issue: #876Update: After @thehowl's native binding PR, doesn't need this kind of work around
Contributors Checklist
BREAKING CHANGE: xxx
message was included in the descriptionMaintainers Checklist
CONTRIBUTING.md
BREAKING CHANGE:
in the body)