Skip to content

Commit

Permalink
Merge branch 'main' into justin/ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jtieri authored Sep 26, 2024
2 parents bdc19a3 + 84fb92b commit 1c28759
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 6 deletions.
47 changes: 43 additions & 4 deletions chain/thorchain/thornode.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func (tn *ChainNode) SetTestConfig(ctx context.Context) error {

// Enable public REST API
api["enable"] = true
api["swagger"] = false
api["swagger"] = true
api["address"] = "tcp://0.0.0.0:1317"
api["enabled-unsafe-cors"] = true

Expand Down Expand Up @@ -720,13 +720,13 @@ EOF

stdout, _, err := tn.Exec(ctx, command, tn.Chain.Config().Env)
if err != nil {
return err
return fmt.Errorf("create key sdtout:\n%s\n, error: %w", string(stdout), err)
}

if tn.Validator && tn.ValidatorMnemonic == "" {
var createKeyOutput map[string]string
if err := json.Unmarshal(stdout, &createKeyOutput); err != nil {
return err
return fmt.Errorf("unmarshal create key sdtout:\n%s\n, error: %w", string(stdout), err)
}

tn.ValidatorMnemonic = createKeyOutput["mnemonic"]
Expand Down Expand Up @@ -1072,7 +1072,7 @@ func (tn *ChainNode) AddBondModule(ctx context.Context) error {
Coins: []CoinBalance{
{
Denom: "rune",
Amount: fmt.Sprintf("%d0000000000000", tn.Chain.(*Thorchain).NumValidators),
Amount: fmt.Sprintf("%d00000000", tn.Chain.(*Thorchain).NumValidators),
},
},
}
Expand All @@ -1096,6 +1096,45 @@ func (tn *ChainNode) AddBondModule(ctx context.Context) error {
}
}

// Now update bank's supply with new balance if on v50
if tn.IsAboveSDK47(ctx) {
bankSupplyPath := "app_state.bank.supply"
splitPath = strings.Split(bankSupplyPath, ".")
path = make([]interface{}, len(splitPath))
for i, component := range splitPath {
if v, err := strconv.Atoi(component); err == nil {
path[i] = v
} else {
path[i] = component
}
}
supplyI, err := dyno.GetSlice(g, path...)
if err != nil {
return fmt.Errorf("failed to get key %s in genesis json", bankSupplyPath)
}

for i, coinI := range supplyI {
coin := coinI.(map[string]interface{})
if coin["denom"].(string) == "rune" {
originalAmount, ok := sdkmath.NewIntFromString(coin["amount"].(string))

Check failure on line 1119 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / test-conformance

undefined: sdkmath

Check failure on line 1119 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: sdkmath

Check failure on line 1119 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: sdkmath

Check failure on line 1119 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: sdkmath

Check failure on line 1119 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / test-cosmos-examples

undefined: sdkmath

Check failure on line 1119 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / test-ibc-examples

undefined: sdkmath
if !ok {
return fmt.Errorf("failed to convert bank's supply of rune to sdk Int from string")
}
addAmount, ok := sdkmath.NewIntFromString(bondBalance.Coins[0].Amount)

Check failure on line 1123 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / test-conformance

undefined: sdkmath

Check failure on line 1123 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: sdkmath

Check failure on line 1123 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: sdkmath

Check failure on line 1123 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / unit-tests

undefined: sdkmath

Check failure on line 1123 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / test-cosmos-examples

undefined: sdkmath

Check failure on line 1123 in chain/thorchain/thornode.go

View workflow job for this annotation

GitHub Actions / test-ibc-examples

undefined: sdkmath
if !ok {
return fmt.Errorf("failed to convert bond amount of rune to sdk Int from string")
}
coin["amount"] = originalAmount.Add(addAmount).String()
supplyI[i] = coin
break
}
}

if err := dyno.Set(g, supplyI, path...); err != nil {
return fmt.Errorf("failed to set bank's new supply")
}
}

genbz, err = json.Marshal(g)
if err != nil {
return fmt.Errorf("failed to marshal genesis bytes to json: %w", err)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func ThorchainDefaultChainSpec(testName string, numVals int, numFn int, ethRoute
name := common.THORChain.String() // Must use this name for test
chainImage := ibc.NewDockerImage("thorchain", "local", "1025:1025")
genesisKVMods := []thorchain.GenesisKV{
thorchain.NewGenesisKV("app_state.bank.params.default_send_enabled", false), // disable bank module transfers
thorchain.NewGenesisKV("app_state.bank.params.default_send_enabled", true), // disable bank module transfers
thorchain.NewGenesisKV("app_state.thorchain.reserve", "22000000000000000"), // mint to reserve for mocknet (220M)
thorchain.NewGenesisKV("app_state.thorchain.chain_contracts", []ChainContract{
{
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions ibc/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ type CreateChannelOptions struct {
Order Order

Version string

Override bool // only implemented on Go Relayer
}

// DefaultChannelOpts returns the default settings for creating an ics20 fungible token transfer channel.
Expand Down
6 changes: 5 additions & 1 deletion relayer/rly/cosmos_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (commander) AddKey(chainID, keyName, coinType, signingAlgorithm, homeDir st
}

func (commander) CreateChannel(pathName string, opts ibc.CreateChannelOptions, homeDir string) []string {
return []string{
cmd := []string{
"rly", "tx", "channel", pathName,
"--src-port", opts.SourcePortName,
"--dst-port", opts.DestPortName,
Expand All @@ -140,6 +140,10 @@ func (commander) CreateChannel(pathName string, opts ibc.CreateChannelOptions, h

"--home", homeDir,
}
if opts.Override {
cmd = append(cmd, "--override")
}
return cmd
}

func createClientOptsHelper(opts ibc.CreateClientOptions) []string {
Expand Down

0 comments on commit 1c28759

Please sign in to comment.