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

fix: apply types/address.go from [email protected] #603

Merged
merged 16 commits into from
Jul 25, 2022

Conversation

ulbqb
Copy link
Member

@ulbqb ulbqb commented Jul 21, 2022

Description

This PR enable to apply types/address.go from [email protected].

Major changes:

  • types.AccAddress, types.ValAddress and types.ConsAddress have changed from string type to byte array type.
  • types.ValidateAccAddress(STRING) + types.AccAddress(STRING)types.AccAddressFromBech32(STRING)
  • types.ValidateValAddress(STRING) + types.ValAddress(STRING)types.ValAddressFromBech32(STRING)
  • types.ValidateConsAddress(STRING) + types.ConsAddress(STRING)types.ConsAddressFromBech32(STRING)
  • types.AccAddress(STRING)types.AccAddressFromBech32(STRING)
  • types.ValAddress(STRING)types.ValAddressFromBech32(STRING)
  • types.ConsAddress(STRING)types.ConsAddressFromBech32(STRING)
  • types.BytesToAccAddress(BYTES)types.AccAddress(BYTES)
  • types.BytesToValAddress(BYTES)types.ValAddress(BYTES)
  • types.BytesToConsAddress(BYTES)types.ConsAddress(BYTES)

Additional changes:

closes: #578

Motivation and context

How has this been tested?

Screenshots (if appropriate):

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

@ulbqb ulbqb changed the title Apply types/address.go from [email protected] fix: apply types/address.go from [email protected] Jul 21, 2022
@ulbqb ulbqb marked this pull request as draft July 21, 2022 05:43
ulbqb and others added 3 commits July 21, 2022 16:56
Fix the bug that should be used `operator` address when `to` address is nil on CreateFTClass
@codecov
Copy link

codecov bot commented Jul 21, 2022

Codecov Report

Merging #603 (88b2e28) into main (1bc3aac) will decrease coverage by 1.18%.
The diff coverage is 39.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #603      +/-   ##
==========================================
- Coverage   60.60%   59.41%   -1.19%     
==========================================
  Files         814      814              
  Lines       94798    95390     +592     
==========================================
- Hits        57448    56680     -768     
- Misses      34097    35158    +1061     
- Partials     3253     3552     +299     
Impacted Files Coverage Δ
client/rpc/validators.go 1.53% <0.00%> (ø)
server/config/config.go 41.35% <ø> (-0.44%) ⬇️
server/init.go 0.00% <0.00%> (ø)
simapp/export.go 12.30% <0.00%> (-0.50%) ⬇️
simapp/simd/cmd/root.go 81.81% <ø> (+0.96%) ⬆️
simapp/test_helpers.go 6.72% <0.00%> (+0.02%) ⬆️
x/auth/client/cli/query.go 2.15% <0.00%> (ø)
x/auth/client/cli/validate_sigs.go 0.00% <0.00%> (ø)
x/auth/client/testutil/suite.go 96.50% <0.00%> (+0.08%) ⬆️
x/auth/client/tx.go 36.66% <0.00%> (ø)
... and 213 more

@ulbqb ulbqb requested a review from zemyblue July 22, 2022 02:19
@ulbqb ulbqb marked this pull request as ready for review July 22, 2022 02:22
@0Tech 0Tech self-requested a review July 22, 2022 02:39
@zemyblue
Copy link
Member

Please add this changes to CHANGELOG.md

@ulbqb ulbqb self-assigned this Jul 22, 2022
@dudong2 dudong2 self-requested a review July 22, 2022 07:14
Copy link
Member

@tnasu tnasu left a comment

Choose a reason for hiding this comment

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

LGTM


toAddr, err := sdk.AccAddressFromBech32(req.To)
if err != nil {
toAddr = operatorAddr
Copy link
Member

Choose a reason for hiding this comment

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

memo: Bugfix of lbm-sdk

if !valOk {
_, file, no, ok := runtime.Caller(1)
if ok {
fmt.Printf("CollectTxs-2, called from %s#%d - %s\n", file, no, sdk.BytesToAccAddress(valAddr).String())
fmt.Printf("CollectTxs-2, called from %s#%d - %s\n", file, no, valAddr.String())
Copy link
Member

Choose a reason for hiding this comment

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

memo: Bugfix of cosmos-sdk

signingInfo, found := k.GetValidatorSigningInfo(ctx, sdk.ConsAddress(params.ConsAddress))
// https://github.com/cosmos/cosmos-sdk/issues/12573
// Will be removed, but fix this
addr, err := sdk.ConsAddressFromBech32(params.ConsAddress)
Copy link
Member

Choose a reason for hiding this comment

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

memo: Bugfix of cosmos-sdk

_, _, addr3 := testdata.KeyTestPubAddr()
consAddr := sdk.AccAddress(addr3).ToConsAddress()
consAddr := sdk.ConsAddress(addr3)
Copy link
Member

Choose a reason for hiding this comment

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

memo: Bugfix of cosmos-sdk

Copy link
Member

@zemyblue zemyblue left a comment

Choose a reason for hiding this comment

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

Please remove AddressDelimiter of staking and distribution module if we don't need anymore.

Copy link
Collaborator

@0Tech 0Tech left a comment

Choose a reason for hiding this comment

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

Also, I have submitted a relevant PR to your repository.

if _, err := s.keeper.GetGrant(ctx, req.ContractId, granter, req.Permission); err != nil {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

if _, err := s.keeper.GetGrant(ctx, req.ContractId, grantee, req.Permission); err != nil {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

@@ -27,7 +27,7 @@ func (a CreateValidatorAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (foun
}

func (a CreateValidatorAuthorization) ValidateBasic() error {
if err := sdk.ValidateValAddress(a.ValidatorAddress); err != nil {
if _, err := sdk.AccAddressFromBech32(a.ValidatorAddress); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if _, err := sdk.AccAddressFromBech32(a.ValidatorAddress); err != nil {
if _, err := sdk.ValAddressFromBech32(a.ValidatorAddress); err != nil {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Which means, the logic is not covered by unit tests. I should revisit x/stakingplus later and add the tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will that tests be included in this PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, it would be added on another PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, It might be better to submit an issue about it.

@@ -30,14 +28,14 @@ func (a cosmwasmAPIImpl) humanAddress(canon []byte) (string, uint64, error) {
gas := a.gasMultiplier.FromWasmVMGas(5)
if err := sdk.VerifyAddressFormat(canon); err != nil {
//nolint:stylecheck
Copy link
Member

Choose a reason for hiding this comment

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

This is very small thing. Does this nolint need?

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks good to delete it.

Copy link
Member

@zemyblue zemyblue left a comment

Choose a reason for hiding this comment

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

I think AddressDenomDelimiter also isn't used. and AddressToPrefixKey function of bank module also.

Fix validation in the tests to avoid modifying test cases
@0Tech 0Tech self-requested a review July 24, 2022 07:42
Copy link
Collaborator

@0Tech 0Tech left a comment

Choose a reason for hiding this comment

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

Approval, with some minor comments.

@@ -249,15 +249,15 @@ func TestEncoding(t *testing.T) {
srcMsg: wasmvmtypes.CosmosMsg{
Staking: &wasmvmtypes.StakingMsg{
Delegate: &wasmvmtypes.DelegateMsg{
Validator: sdk.BytesToAccAddress(valAddr).String(),
Validator: valAddr.String(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

The type of valAddr is sdk.ValAddress, so technically, it should be converted to sdk.AccAddress first.
However, from the background, it seems that it should have been sdk.ValAddress. Is it a bug-fix?

Copy link
Member

Choose a reason for hiding this comment

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

This is changed from CosmWasm/wasmd-v0.27.0. Yes, it's our bug fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added this bug fix to description.

Comment on lines +121 to +122
bz, err := keeper.QuerySmart(ctx, contractAddr, msg)
return bz, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
bz, err := keeper.QuerySmart(ctx, contractAddr, msg)
return bz, err
return keeper.QuerySmart(ctx, contractAddr, msg)

I would like to know the reason for this change. By the linter?

Copy link
Member

Choose a reason for hiding this comment

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

This is changed from CosmWasm/wasmd-v0.27.0. We should be the same since we continue to merge from CosmWasm/wasmd.

@@ -293,7 +291,7 @@ func TestLegacyQueryContractHistory(t *testing.T) {
var defaultQueryGasLimit sdk.Gas = 3000000
q := NewLegacyQuerier(keeper, defaultQueryGasLimit)
queryContractAddr := spec.srcQueryAddr
if queryContractAddr.Empty() {
if queryContractAddr == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if queryContractAddr == nil {
if len(queryContractAddr) == 0 {

It will cover both of nil and an empty array. Is the comparison with nil intentional?

Copy link
Member

Choose a reason for hiding this comment

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

This is changed from CosmWasm/wasmd-v0.27.0. We should be the same since we continue to merge from CosmWasm/wasmd.

@ulbqb ulbqb requested a review from zemyblue July 25, 2022 02:41
@ulbqb ulbqb merged commit 253d07e into Finschia:main Jul 25, 2022
@dudong2 dudong2 mentioned this pull request Sep 5, 2022
4 tasks
@zemyblue zemyblue mentioned this pull request Oct 27, 2022
5 tasks
@zemyblue zemyblue mentioned this pull request Nov 28, 2022
5 tasks
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.

Effectiveness of Address Format Change and Next Action
4 participants