From 0cfb7c7c94f2181ff9087e7e27a4caba9d3e7d27 Mon Sep 17 00:00:00 2001 From: tarumi Date: Wed, 29 Nov 2023 17:42:44 +0100 Subject: [PATCH 1/5] add compose for arm --- Makefile | 10 ++++++++++ compose-arm.yml | 27 +++++++++++++++++++++++++++ dockerfile | 4 ++-- dockerfile-arm | 22 ++++++++++++++++++++++ docs/static/openapi.yml | 6 ++++++ 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 compose-arm.yml create mode 100644 dockerfile-arm diff --git a/Makefile b/Makefile index 136d1293..58f40433 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,16 @@ serve: build: $(DOCKER_RUN_CMD) ignite chain build +## Docker compose +docker-compose-build: + docker compose build +docker-compose-up: + docker compose up +docker-compose-build-arm: + docker compose -f compose-arm.yml build +docker-compose-up-arm: + docker compose -f compose-arm.yml up + ## Test test-all-module: go test ./x/.../ diff --git a/compose-arm.yml b/compose-arm.yml new file mode 100644 index 00000000..5e04f498 --- /dev/null +++ b/compose-arm.yml @@ -0,0 +1,27 @@ +version: "3.9" + +services: + node1: + build: + context: . + dockerfile: dockerfile-arm + networks: + - mycelnet + ports: + - "1317:1317" + - "4500:4500" + - "26657:26657" + volumes: + - "~/.mycel:/root/.mycel" + node2: + build: + context: . + dockerfile: dockerfile-arm + networks: + - mycelnet + command: bash + tty: true + +networks: + mycelnet: + diff --git a/dockerfile b/dockerfile index 2200fd7d..0be041ac 100644 --- a/dockerfile +++ b/dockerfile @@ -14,9 +14,9 @@ RUN tar -zxvf release/mycel_linux_amd64.tar.gz FROM --platform=linux/amd64 ubuntu ENV LD_LIBRARY_PATH=/usr/local/lib RUN apt-get update \ - && apt-get install -y ca-certificates vim curl + && apt-get install -y ca-certificates vim curl jq WORKDIR /root/ -RUN curl -fL 'https://github.com/CosmWasm/wasmvm/releases/download/v1.4.0/libwasmvm.x86_64.so' > /usr/local/lib/libwasmvm.x86_64.so +RUN curl -fL 'https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm.x86_64.so' > /usr/local/lib/libwasmvm.x86_64.so COPY --from=builder /build/myceld /usr/local/bin CMD ["myceld", "start"] diff --git a/dockerfile-arm b/dockerfile-arm new file mode 100644 index 00000000..2db707b8 --- /dev/null +++ b/dockerfile-arm @@ -0,0 +1,22 @@ +FROM --platform=linux/arm64 golang AS builder +USER root +WORKDIR /build/ +COPY ./ /build/ +RUN apt-get update \ + && apt-get install -y curl +RUN curl 'https://get.ignite.com/cli@v0.27.2'! | bash +RUN ignite chain build \ + --release.targets linux:arm64 \ + --output ./release \ + --release +RUN tar -zxvf release/mycel_linux_arm64.tar.gz + +FROM --platform=linux/arm64 ubuntu +ENV LD_LIBRARY_PATH=/usr/local/lib +RUN apt-get update \ + && apt-get install -y ca-certificates vim curl jq +WORKDIR /root/ +RUN curl -fL 'https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm.aarch64.so' > /usr/local/lib/libwasmvm.aarch64.so +COPY --from=builder /build/myceld /usr/local/bin +CMD ["myceld", "start"] + diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 373c7675..de3c218a 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -50270,6 +50270,9 @@ paths: description: A successful response. schema: type: object + properties: + role: + type: string default: description: An unexpected error response. schema: @@ -82007,6 +82010,9 @@ definitions: description: QueryParamsResponse is response type for the Query/Params RPC method. mycel.registry.QueryRoleResponse: type: object + properties: + role: + type: string mycel.registry.SecondLevelDomainResponse: type: object properties: From a8dd485bc9a44c90adfa25b3faa2efd83ecb2932 Mon Sep 17 00:00:00 2001 From: tarumi Date: Wed, 29 Nov 2023 20:59:44 +0100 Subject: [PATCH 2/5] [wip] update subdomain config generation --- .../keeper/query_domain_registration_fee.go | 2 +- x/registry/keeper/top_level_domain.go | 2 +- x/registry/types/genesis.go | 4 ++- x/registry/types/subdomain_config.go | 31 +++++++++++++------ 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/x/registry/keeper/query_domain_registration_fee.go b/x/registry/keeper/query_domain_registration_fee.go index 93667304..10d00c3e 100644 --- a/x/registry/keeper/query_domain_registration_fee.go +++ b/x/registry/keeper/query_domain_registration_fee.go @@ -31,7 +31,7 @@ func (k Keeper) DomainRegistrationFee(goCtx context.Context, req *types.QueryDom config := types.GetDefaultSubdomainConfig(1) domain := types.TopLevelDomain{ Name: req.Name, - SubdomainConfig: &config, + SubdomainConfig: config, } err := k.ValidateTopLevelDomainIsRegistrable(ctx, domain) if err != nil { diff --git a/x/registry/keeper/top_level_domain.go b/x/registry/keeper/top_level_domain.go index 3fb07034..6b61f2f7 100644 --- a/x/registry/keeper/top_level_domain.go +++ b/x/registry/keeper/top_level_domain.go @@ -169,7 +169,7 @@ func (k Keeper) RegisterTopLevelDomain(ctx sdk.Context, creator string, domainNa Name: domainName, ExpirationDate: expirationDate, Metadata: nil, - SubdomainConfig: &defaultRegistrationConfig, + SubdomainConfig: defaultRegistrationConfig, AccessControl: accessControl, TotalWithdrawalAmount: sdk.NewCoins(), } diff --git a/x/registry/types/genesis.go b/x/registry/types/genesis.go index 239139ad..766083f1 100644 --- a/x/registry/types/genesis.go +++ b/x/registry/types/genesis.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "math" ) // DefaultIndex is the default global index @@ -16,10 +17,11 @@ func GetDefaultTLDNames() []string { // Get default TLDs func GetDefaultTLDs() (defaultTLDs []TopLevelDomain) { defaultRegistrationConfig := GetDefaultSubdomainConfig(3030) + defaultRegistrationConfig.MaxSubdomainRegistrations = math.MaxInt64 for _, v := range GetDefaultTLDNames() { defaultTLDs = append(defaultTLDs, TopLevelDomain{ Name: v, - SubdomainConfig: &defaultRegistrationConfig, + SubdomainConfig: defaultRegistrationConfig, }) } return defaultTLDs diff --git a/x/registry/types/subdomain_config.go b/x/registry/types/subdomain_config.go index 2996f4c0..0a54e96c 100644 --- a/x/registry/types/subdomain_config.go +++ b/x/registry/types/subdomain_config.go @@ -2,7 +2,9 @@ package types import ( "errors" - math "math" + "fmt" + + "cosmossdk.io/math" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -10,24 +12,33 @@ import ( "github.com/mycel-domain/mycel/app/params" ) -func GetDefaultSubdomainConfig(baseFee int64) SubdomainConfig { +func GetDefaultSubdomainConfig(baseFee int64) *SubdomainConfig { defaultFee := sdk.NewCoin(params.DefaultBondDenom, sdk.NewInt(baseFee)) - fees := GetFeeByNameLength(10, int(baseFee)) + fees := GetFeeByNameLength(10, baseFee, 4) - return SubdomainConfig{ + return &SubdomainConfig{ MaxSubdomainRegistrations: 100_000, SubdomainRegistrationFees: &SubdomainRegistrationFees{ - FeeByLength: fees, DefaultFee: &defaultFee, + FeeByLength: fees, }, } } -func GetFeeByNameLength(base int, baseFee int) map[uint32]*Fee { - fees := make(map[uint32]*Fee) - for i := uint32(1); i < 5; i++ { - amount := baseFee * int(math.Pow(float64(base), float64((5-i)))) - fee := sdk.NewCoin(params.DefaultBondDenom, sdk.NewInt(int64(amount))) +func GetFeeByNameLength(base int64, baseFee int64, step int64) map[uint32]*Fee { + fees := make(map[uint32]*Fee, step) + baseDec, err := math.LegacyNewDecFromStr(fmt.Sprintf("%d", base)) + if err != nil { + panic(err) + } + baseFeeDec, err := math.LegacyNewDecFromStr(fmt.Sprintf("%d", baseFee)) + if err != nil { + panic(err) + } + for i := uint32(1); i <= uint32(step); i++ { + exponent := uint64(step+1) - uint64(i) + amount := baseFeeDec.Mul(baseDec.Power(exponent)).RoundInt() + fee := sdk.NewCoin(params.DefaultBondDenom, amount) fees[i] = &Fee{ IsRegistrable: true, Fee: &fee, From 66a4135d53c2af0767949942a0394420b82d46fa Mon Sep 17 00:00:00 2001 From: tarumi Date: Fri, 1 Dec 2023 11:14:57 +0100 Subject: [PATCH 3/5] rm FeeByNameLength --- x/registry/types/subdomain_config.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x/registry/types/subdomain_config.go b/x/registry/types/subdomain_config.go index 0a54e96c..d725c222 100644 --- a/x/registry/types/subdomain_config.go +++ b/x/registry/types/subdomain_config.go @@ -14,17 +14,16 @@ import ( func GetDefaultSubdomainConfig(baseFee int64) *SubdomainConfig { defaultFee := sdk.NewCoin(params.DefaultBondDenom, sdk.NewInt(baseFee)) - fees := GetFeeByNameLength(10, baseFee, 4) return &SubdomainConfig{ MaxSubdomainRegistrations: 100_000, SubdomainRegistrationFees: &SubdomainRegistrationFees{ DefaultFee: &defaultFee, - FeeByLength: fees, }, } } +// TODO: This function will cause consensus failure func GetFeeByNameLength(base int64, baseFee int64, step int64) map[uint32]*Fee { fees := make(map[uint32]*Fee, step) baseDec, err := math.LegacyNewDecFromStr(fmt.Sprintf("%d", base)) From bcd5976e3173994c5f49c33f3a1cd697c9b58cea Mon Sep 17 00:00:00 2001 From: tarumi Date: Fri, 1 Dec 2023 11:18:33 +0100 Subject: [PATCH 4/5] lint --- x/registry/types/genesis.go | 4 ++-- x/registry/types/subdomain_config.go | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/x/registry/types/genesis.go b/x/registry/types/genesis.go index 766083f1..b9c57025 100644 --- a/x/registry/types/genesis.go +++ b/x/registry/types/genesis.go @@ -2,7 +2,7 @@ package types import ( "fmt" - "math" + "math" ) // DefaultIndex is the default global index @@ -17,7 +17,7 @@ func GetDefaultTLDNames() []string { // Get default TLDs func GetDefaultTLDs() (defaultTLDs []TopLevelDomain) { defaultRegistrationConfig := GetDefaultSubdomainConfig(3030) - defaultRegistrationConfig.MaxSubdomainRegistrations = math.MaxInt64 + defaultRegistrationConfig.MaxSubdomainRegistrations = math.MaxInt64 for _, v := range GetDefaultTLDNames() { defaultTLDs = append(defaultTLDs, TopLevelDomain{ Name: v, diff --git a/x/registry/types/subdomain_config.go b/x/registry/types/subdomain_config.go index d725c222..98d256b9 100644 --- a/x/registry/types/subdomain_config.go +++ b/x/registry/types/subdomain_config.go @@ -4,9 +4,8 @@ import ( "errors" "fmt" - "cosmossdk.io/math" - errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/mycel-domain/mycel/app/params" @@ -18,7 +17,7 @@ func GetDefaultSubdomainConfig(baseFee int64) *SubdomainConfig { return &SubdomainConfig{ MaxSubdomainRegistrations: 100_000, SubdomainRegistrationFees: &SubdomainRegistrationFees{ - DefaultFee: &defaultFee, + DefaultFee: &defaultFee, }, } } From c7be9d2058c3d61ef7241fb87446eff28bafb284 Mon Sep 17 00:00:00 2001 From: tarumi Date: Mon, 4 Dec 2023 13:12:20 +0100 Subject: [PATCH 5/5] revert defaultsubdomainconfig return type --- x/registry/keeper/query_domain_registration_fee.go | 2 +- x/registry/keeper/top_level_domain.go | 2 +- x/registry/types/genesis.go | 2 +- x/registry/types/subdomain_config.go | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/x/registry/keeper/query_domain_registration_fee.go b/x/registry/keeper/query_domain_registration_fee.go index 10d00c3e..93667304 100644 --- a/x/registry/keeper/query_domain_registration_fee.go +++ b/x/registry/keeper/query_domain_registration_fee.go @@ -31,7 +31,7 @@ func (k Keeper) DomainRegistrationFee(goCtx context.Context, req *types.QueryDom config := types.GetDefaultSubdomainConfig(1) domain := types.TopLevelDomain{ Name: req.Name, - SubdomainConfig: config, + SubdomainConfig: &config, } err := k.ValidateTopLevelDomainIsRegistrable(ctx, domain) if err != nil { diff --git a/x/registry/keeper/top_level_domain.go b/x/registry/keeper/top_level_domain.go index 6b61f2f7..3fb07034 100644 --- a/x/registry/keeper/top_level_domain.go +++ b/x/registry/keeper/top_level_domain.go @@ -169,7 +169,7 @@ func (k Keeper) RegisterTopLevelDomain(ctx sdk.Context, creator string, domainNa Name: domainName, ExpirationDate: expirationDate, Metadata: nil, - SubdomainConfig: defaultRegistrationConfig, + SubdomainConfig: &defaultRegistrationConfig, AccessControl: accessControl, TotalWithdrawalAmount: sdk.NewCoins(), } diff --git a/x/registry/types/genesis.go b/x/registry/types/genesis.go index b9c57025..d1ea2234 100644 --- a/x/registry/types/genesis.go +++ b/x/registry/types/genesis.go @@ -21,7 +21,7 @@ func GetDefaultTLDs() (defaultTLDs []TopLevelDomain) { for _, v := range GetDefaultTLDNames() { defaultTLDs = append(defaultTLDs, TopLevelDomain{ Name: v, - SubdomainConfig: defaultRegistrationConfig, + SubdomainConfig: &defaultRegistrationConfig, }) } return defaultTLDs diff --git a/x/registry/types/subdomain_config.go b/x/registry/types/subdomain_config.go index 98d256b9..e3e94d01 100644 --- a/x/registry/types/subdomain_config.go +++ b/x/registry/types/subdomain_config.go @@ -11,10 +11,9 @@ import ( "github.com/mycel-domain/mycel/app/params" ) -func GetDefaultSubdomainConfig(baseFee int64) *SubdomainConfig { +func GetDefaultSubdomainConfig(baseFee int64) SubdomainConfig { defaultFee := sdk.NewCoin(params.DefaultBondDenom, sdk.NewInt(baseFee)) - - return &SubdomainConfig{ + return SubdomainConfig{ MaxSubdomainRegistrations: 100_000, SubdomainRegistrationFees: &SubdomainRegistrationFees{ DefaultFee: &defaultFee,