Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Fix Consensus #112

Merged
merged 5 commits into from
Dec 7, 2023
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
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/.../
Expand Down
27 changes: 27 additions & 0 deletions compose-arm.yml
Original file line number Diff line number Diff line change
@@ -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:

4 changes: 2 additions & 2 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

22 changes: 22 additions & 0 deletions dockerfile-arm
Original file line number Diff line number Diff line change
@@ -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/[email protected]'! | 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"]

6 changes: 6 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50270,6 +50270,9 @@ paths:
description: A successful response.
schema:
type: object
properties:
role:
type: string
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions x/registry/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"math"
)

// DefaultIndex is the default global index
Expand All @@ -16,6 +17,7 @@ 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,
Expand Down
28 changes: 18 additions & 10 deletions x/registry/types/subdomain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,40 @@ package types

import (
"errors"
math "math"
"fmt"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/mycel-domain/mycel/app/params"
)

func GetDefaultSubdomainConfig(baseFee int64) SubdomainConfig {
defaultFee := sdk.NewCoin(params.DefaultBondDenom, sdk.NewInt(baseFee))
fees := GetFeeByNameLength(10, int(baseFee))

return SubdomainConfig{
MaxSubdomainRegistrations: 100_000,
SubdomainRegistrationFees: &SubdomainRegistrationFees{
FeeByLength: fees,
DefaultFee: &defaultFee,
DefaultFee: &defaultFee,
},
}
}

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)))
// 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))
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,
Expand Down
Loading