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: sync develop to master #629

Merged
merged 10 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions .github/workflows/docker-build-workflow-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker-Invisible

on: workflow_dispatch

env:
IMAGE_NAME: ghcr.io/bnb-chain/greenfield-invisible
IMAGE_SOURCE: https://github.com/bnb-chain/greenfield

jobs:
# Push image to GitHub Packages.
push:
strategy:
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Build image
run: |
docker build . \
--label "org.opencontainers.image.source=${IMAGE_SOURCE}" \
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
--label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \
--label "org.opencontainers.image.licenses=AGPL-3.0,GPL-3.0" \
-f ./Dockerfile -t "${IMAGE_NAME}"
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_ACCESS_SECRET }}

- name: Push image
run: |
VERSION=${GITHUB_SHA}
echo IMAGE_NAME=$IMAGE_NAME
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_NAME:$VERSION
docker tag $IMAGE_NAME $IMAGE_NAME:latest
docker push $IMAGE_NAME:$VERSION
docker push $IMAGE_NAME:latest
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ func (app *App) initBridge() {

func (app *App) initStorage() {
storagemodulekeeper.RegisterCrossApps(app.StorageKeeper)
storagemodulekeeper.InitPaymentCheck(app.StorageKeeper, app.appConfig.PaymentCheck.Enabled,
app.appConfig.PaymentCheck.Interval)
}

func (app *App) initGov() {
Expand Down
20 changes: 20 additions & 0 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type AppConfig struct {
serverconfig.Config

CrossChain CrossChainConfig `mapstructure:"cross-chain"`

PaymentCheck PaymentCheckConfig `mapstructure:"payment-check"`
}

type CrossChainConfig struct {
Expand All @@ -18,6 +20,11 @@ type CrossChainConfig struct {
DestOpChainId uint32 `mapstructure:"dest-op-chain-id"`
}

type PaymentCheckConfig struct {
Enabled bool `mapstructure:"enabled"`
Interval uint32 `mapstructure:"interval"`
}

var CustomAppTemplate = serverconfig.DefaultConfigTemplate + `
###############################################################################
### CrossChain Config ###
Expand All @@ -29,6 +36,15 @@ src-chain-id = {{ .CrossChain.SrcChainId }}
dest-bsc-chain-id = {{ .CrossChain.DestBscChainId }}
# chain-id for op bnb destination chain
dest-op-chain-id = {{ .CrossChain.DestOpChainId }}

###############################################################################
### PaymentCheck Config ###
###############################################################################
[payment-check]
# enabled - the flag to enable/disable payment check
enabled = {{ .PaymentCheck.Enabled }}
# interval - the block interval run check payment
interval = {{ .PaymentCheck.Interval }}
`

func NewDefaultAppConfig() *AppConfig {
Expand All @@ -54,5 +70,9 @@ func NewDefaultAppConfig() *AppConfig {
DestBscChainId: 2,
DestOpChainId: 3,
},
PaymentCheck: PaymentCheckConfig{
Enabled: false,
Interval: 100,
},
}
}
2 changes: 1 addition & 1 deletion cmd/gnfd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (a appCreator) newApp(
cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
a.encodingConfig,
&app.AppConfig{Config: *serverConfig, CrossChain: appConfig.CrossChain},
&app.AppConfig{Config: *serverConfig, CrossChain: appConfig.CrossChain, PaymentCheck: appConfig.PaymentCheck},
appOpts,
baseapp.SetPruning(pruningOpts),
baseapp.SetEventing(cast.ToString(appOpts.Get(server.FlagEventing))),
Expand Down
1 change: 0 additions & 1 deletion deployment/localup/localup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ function generate_genesis() {
echo -e '[[upgrade]]\nname = "Pawnee"\nheight = 23\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml
echo -e '[[upgrade]]\nname = "Serengeti"\nheight = 24\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml
echo -e '[[upgrade]]\nname = "Erdos"\nheight = 25\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml
echo -e '[payment-check]\nenabled = true\ninterval = 1' >> ${workspace}/.local/validator${i}/config/app.toml
done

# enable swagger API for validator0
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/virtualgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (s *VirtualGroupTestSuite) TestBasic() {
s.Require().Contains(spAvailableGvgFamilyIds, gvg.FamilyId)

spOptimalGvgFamilyId := s.querySpOptimalGlobalVirtualGroupFamily(primarySP.Info.Id, virtualgroupmoduletypes.Strategy_Maximize_Free_Store_Size)
s.Require().Equal(spOptimalGvgFamilyId, gvg.FamilyId)
s.Require().Contains(spAvailableGvgFamilyIds, spOptimalGvgFamilyId)

srcGVGs := s.queryGlobalVirtualGroupsByFamily(gvg.FamilyId)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ replace (
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v1.3.0
github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v1.7.2
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v1.7.3-0.20240527082454-48d116d99ca4
github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/wercker/journalhook => github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ github.com/bnb-chain/greenfield-cometbft v1.3.0 h1:v3nZ16ledTZGF5Csys7fTQGZcEV78
github.com/bnb-chain/greenfield-cometbft v1.3.0/go.mod h1:0D+VPivZTeBldjtGGi9LKbBnKEO/RtMRJikie92LkYI=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI=
github.com/bnb-chain/greenfield-cosmos-sdk v1.7.2 h1:Xr7NLxXZKHhRX1ccVCgOwo1miw4HcQ+POirvMKzKLLo=
github.com/bnb-chain/greenfield-cosmos-sdk v1.7.2/go.mod h1:2bwmwdXYBISnQoMwgAcZTVGt21lMsHZSeeeMByTvDlQ=
github.com/bnb-chain/greenfield-cosmos-sdk v1.7.3-0.20240527082454-48d116d99ca4 h1:0UFOOdVKbiIEfKkL15NJ/VtE6TSdlwM4HtJJuukJfio=
github.com/bnb-chain/greenfield-cosmos-sdk v1.7.3-0.20240527082454-48d116d99ca4/go.mod h1:2bwmwdXYBISnQoMwgAcZTVGt21lMsHZSeeeMByTvDlQ=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210 h1:GHPbV2bC+gmuO6/sG0Tm8oGal3KKSRlyE+zPscDjlA8=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210/go.mod h1:vhsZxXE9tYJeYB5JR4hPhd6Pc/uPf7j1T8IJ7p9FdeM=
github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230816082903-b48770f5e210 h1:FLVOn4+OVbsKi2+YJX5kmD27/4dRu4FW7xCXFhzDO5s=
Expand Down
4 changes: 3 additions & 1 deletion proto/greenfield/permission/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ enum PrincipalType {
message Principal {
PrincipalType type = 1;
// When the type is an account, its value is sdk.AccAddress().String();
// when the type is a group, its value is math.Uint().String()
// When the type is a group, its value can be in one of two formats:
// 1. group id
// 2. grn:g:ownerAddress:groupName
string value = 2;
}
8 changes: 8 additions & 0 deletions proto/greenfield/storage/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ message EventMigrationBucket {
];
// The id of the destination primary sp
uint32 dst_primary_sp_id = 4;
// status define the status of the bucket.
BucketStatus status = 5;
}

message EventCancelMigrationBucket {
Expand All @@ -528,6 +530,8 @@ message EventCancelMigrationBucket {
(gogoproto.customtype) = "Uint",
(gogoproto.nullable) = false
];
// status define the status of the bucket.
BucketStatus status = 4;
}

message EventRejectMigrateBucket {
Expand All @@ -541,6 +545,8 @@ message EventRejectMigrateBucket {
(gogoproto.customtype) = "Uint",
(gogoproto.nullable) = false
];
// status define the status of the bucket.
BucketStatus status = 4;
}

message EventCompleteMigrationBucket {
Expand All @@ -559,6 +565,8 @@ message EventCompleteMigrationBucket {
uint32 global_virtual_group_family_id = 4;
// The src_primary_sp_id defines the primary sp id of the bucket before migrate.
uint32 src_primary_sp_id = 5;
// status define the status of the bucket.
BucketStatus status = 6;
}

message EventSetTag {
Expand Down
55 changes: 44 additions & 11 deletions swagger/static/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5201,8 +5201,12 @@ paths:
When the type is an account, its value is
sdk.AccAddress().String();

when the type is a group, its value is
math.Uint().String()
When the type is a group, its value can be in one of
two formats:

1. group id

2. grn:g:ownerAddress:groupName
description: >-
Principal define the roles that can be grant permissions
to. Currently, it can be account or group.
Expand Down Expand Up @@ -5397,8 +5401,12 @@ paths:
When the type is an account, its value is
sdk.AccAddress().String();

when the type is a group, its value is
math.Uint().String()
When the type is a group, its value can be in one of
two formats:

1. group id

2. grn:g:ownerAddress:groupName
description: >-
Principal define the roles that can be grant permissions
to. Currently, it can be account or group.
Expand Down Expand Up @@ -5597,8 +5605,12 @@ paths:
When the type is an account, its value is
sdk.AccAddress().String();

when the type is a group, its value is
math.Uint().String()
When the type is a group, its value can be in one of
two formats:

1. group id

2. grn:g:ownerAddress:groupName
description: >-
Principal define the roles that can be grant permissions
to. Currently, it can be account or group.
Expand Down Expand Up @@ -34654,7 +34666,11 @@ definitions:
When the type is an account, its value is
sdk.AccAddress().String();

when the type is a group, its value is math.Uint().String()
When the type is a group, its value can be in one of two formats:

1. group id

2. grn:g:ownerAddress:groupName
description: >-
Principal define the roles that can be grant permissions to.
Currently, it can be account or group.
Expand Down Expand Up @@ -34784,7 +34800,9 @@ definitions:
type: string
title: |-
When the type is an account, its value is sdk.AccAddress().String();
when the type is a group, its value is math.Uint().String()
When the type is a group, its value can be in one of two formats:
1. group id
2. grn:g:ownerAddress:groupName
description: >-
Principal define the roles that can be grant permissions to. Currently, it
can be account or group.
Expand Down Expand Up @@ -36657,7 +36675,12 @@ definitions:
When the type is an account, its value is
sdk.AccAddress().String();

when the type is a group, its value is math.Uint().String()
When the type is a group, its value can be in one of two
formats:

1. group id

2. grn:g:ownerAddress:groupName
description: >-
Principal define the roles that can be grant permissions to.
Currently, it can be account or group.
Expand Down Expand Up @@ -36811,7 +36834,12 @@ definitions:
When the type is an account, its value is
sdk.AccAddress().String();

when the type is a group, its value is math.Uint().String()
When the type is a group, its value can be in one of two
formats:

1. group id

2. grn:g:ownerAddress:groupName
description: >-
Principal define the roles that can be grant permissions to.
Currently, it can be account or group.
Expand Down Expand Up @@ -36965,7 +36993,12 @@ definitions:
When the type is an account, its value is
sdk.AccAddress().String();

when the type is a group, its value is math.Uint().String()
When the type is a group, its value can be in one of two
formats:

1. group id

2. grn:g:ownerAddress:groupName
description: >-
Principal define the roles that can be grant permissions to.
Currently, it can be account or group.
Expand Down
2 changes: 1 addition & 1 deletion testutil/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewTestApp(
app.DefaultNodeHome,
0,
encCfg,
&app.AppConfig{CrossChain: app.NewDefaultAppConfig().CrossChain},
&app.AppConfig{CrossChain: app.NewDefaultAppConfig().CrossChain, PaymentCheck: app.NewDefaultAppConfig().PaymentCheck},
simtestutil.EmptyAppOptions{},
options...,
)
Expand Down
2 changes: 1 addition & 1 deletion x/payment/keeper/stream_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (k Keeper) GetAllStreamRecord(ctx sdk.Context) (list []types.StreamRecord)
for ; iterator.Valid(); iterator.Next() {
var val types.StreamRecord
k.cdc.MustUnmarshal(iterator.Value(), &val)
val.Account = string(iterator.Key())
val.Account = sdk.AccAddress(iterator.Key()).String()
list = append(list, val)
}

Expand Down
4 changes: 3 additions & 1 deletion x/permission/types/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions x/storage/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,13 @@ func EndBlocker(ctx sdk.Context, keeper Keeper) {

// Permission GC
keeper.GarbageCollectResourcesStalePolicy(ctx)

// Payment Data Check
interval := int64(keeper.GetPaymentCheckInterval())
if keeper.IsPaymentCheckEnabled() && interval > 0 && ctx.BlockHeight()%interval == 0 {
err = keeper.RunPaymentCheck(ctx)
if err != nil {
panic(err)
}
}
}
Loading
Loading