Skip to content

Commit

Permalink
Merge branch 'master-tunnel' into tunnel-ibc
Browse files Browse the repository at this point in the history
  • Loading branch information
satawatnack committed Nov 14, 2024
2 parents b968911 + 610be90 commit 28e4766
Show file tree
Hide file tree
Showing 80 changed files with 1,486 additions and 1,443 deletions.
770 changes: 383 additions & 387 deletions api/band/oracle/v1/oracle.pulsar.go

Large diffs are not rendered by default.

479 changes: 239 additions & 240 deletions api/band/oracle/v1/tx.pulsar.go

Large diffs are not rendered by default.

78 changes: 41 additions & 37 deletions api/band/tss/v1beta1/originator.pulsar.go

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

1 change: 0 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ func NewAppKeeper(
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.DistrKeeper,
appKeepers.StakingKeeper,
appKeepers.TSSKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
authtypes.FeeCollectorName,
Expand Down
28 changes: 15 additions & 13 deletions cmd/cylinder/run.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"time"

"github.com/spf13/cobra"
"github.com/spf13/viper"

Expand All @@ -15,17 +17,17 @@ import (
)

const (
flagGranter = "granter"
flagLogLevel = "log-level"
flagMaxMessages = "max-messages"
flagBroadcastTimeout = "broadcast-timeout"
flagRPCPollInterval = "rpc-poll-interval"
flagMaxTry = "max-try"
flagMinDE = "min-de"
flagGasAdjustStart = "gas-adjust-start"
flagGasAdjustStep = "gas-adjust-step"
flagRandomSecret = "random-secret"
flagActivePeriod = "active-period"
flagGranter = "granter"
flagLogLevel = "log-level"
flagMaxMessages = "max-messages"
flagBroadcastTimeout = "broadcast-timeout"
flagRPCPollInterval = "rpc-poll-interval"
flagMaxTry = "max-try"
flagMinDE = "min-de"
flagGasAdjustStart = "gas-adjust-start"
flagGasAdjustStep = "gas-adjust-step"
flagRandomSecret = "random-secret"
flagCheckingDEInterval = "checking-de-interval"
)

// runCmd returns a Cobra command to run the cylinder process.
Expand Down Expand Up @@ -75,12 +77,12 @@ func runCmd(ctx *context.Context) *cobra.Command {
cmd.Flags().Float64(flagGasAdjustStart, 1.6, "The start value of gas adjustment")
cmd.Flags().Float64(flagGasAdjustStep, 0.2, "The increment step of gad adjustment")
cmd.Flags().BytesHex(flagRandomSecret, nil, "The secret value that is used for random D,E")
cmd.Flags().String(flagActivePeriod, "12h", "The time period that cylinder will send active status to chain")
cmd.Flags().Duration(flagCheckingDEInterval, 5*time.Minute, "The interval of checking DE")

flagNames := []string{
flags.FlagChainID, flags.FlagNode, flagGranter, flags.FlagGasPrices, flagLogLevel,
flagMaxMessages, flagBroadcastTimeout, flagRPCPollInterval, flagMaxTry, flagMinDE,
flagGasAdjustStart, flagGasAdjustStep, flagRandomSecret, flagActivePeriod,
flagGasAdjustStart, flagGasAdjustStep, flagRandomSecret, flagCheckingDEInterval,
}

for _, flagName := range flagNames {
Expand Down
33 changes: 15 additions & 18 deletions cylinder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Key features of cylinder include:

- Nonce Submission: Allows users to submit nonces that are used during the signing process, ensuring proper coordination for message signing.
- Message Signing: Enables users to sign newly requested messages as part of the TSS protocol.
- Heartbeat Functionality: Keeps users active in the system by sending periodic heartbeat message, ensuring their readiness for future signing tasks.

This tool is essential for members who need to maintain constant engagement and coordination during TSS message signing operations.

Expand Down Expand Up @@ -118,7 +117,7 @@ cylinder config min-de 20 --home $CYLINDER_HOME_PATH
cylinder config gas-adjust-start 1.6 --home $CYLINDER_HOME_PATH
cylinder config gas-adjust-step 0.2 --home $CYLINDER_HOME_PATH
cylinder config random-secret "$(openssl rand -hex 32)" --home $CYLINDER_HOME_PATH
cylinder config active-period "12h" --home $CYLINDER_HOME_PATH
cylinder config checking-de-interval "5m" --home $CYLINDER_HOME_PATH

cylinder keys add signer1 --home $CYLINDER_HOME_PATH
cylinder keys add signer2 --home $CYLINDER_HOME_PATH
Expand All @@ -128,20 +127,20 @@ below is the meaning of the configuration of the system

```go
type Config struct {
ChainID string // ChainID of the target chain
NodeURI string // Remote RPC URI of BandChain node to connect to
Granter string // The granter address
GasPrices string // Gas prices of the transaction
LogLevel string // Log level of the logger
MaxMessages uint64 // The maximum number of messages in a transaction
BroadcastTimeout time.Duration // The time that cylinder will wait for tx commit
RPCPollInterval time.Duration // The duration of rpc poll interval
MaxTry uint64 // The maximum number of tries to submit a report transaction
MinDE uint64 // The minimum number of DE
GasAdjustStart float64 // The start value of gas adjustment
GasAdjustStep float64 // The increment step of gad adjustment
RandomSecret tss.Scalar // The secret value that is used for random D,E
ActivePeriod time.Duration // The time period that cylinder will send active status to chain
ChainID string // ChainID of the target chain
NodeURI string // Remote RPC URI of BandChain node to connect to
Granter string // The granter address
GasPrices string // Gas prices of the transaction
LogLevel string // Log level of the logger
MaxMessages uint64 // The maximum number of messages in a transaction
BroadcastTimeout time.Duration // The time that cylinder will wait for tx commit
RPCPollInterval time.Duration // The duration of rpc poll interval
MaxTry uint64 // The maximum number of tries to submit a report transaction
MinDE uint64 // The minimum number of DE
GasAdjustStart float64 // The start value of gas adjustment
GasAdjustStep float64 // The increment step of gad adjustment
RandomSecret tss.Scalar // The secret value that is used for random D,E
CheckingDEInterval time.Duration // The interval for updating DE
}
```

Expand All @@ -156,8 +155,6 @@ Run the following commands to send 1 BAND to the predefined signer accounts and
bandd tx multi-send 1000000uband $(cylinder keys list -a --home $CYLINDER_HOME_PATH) --gas-prices 0.0025uband --keyring-backend test --chain-id $CHAIN_ID --from $WALLET_NAME -b sync -y --node $RPC_URL

bandd tx tss add-grantees $(cylinder keys list -a --home $CYLINDER_HOME_PATH) --gas-prices 0.0025uband --keyring-backend test --chain-id $CHAIN_ID --gas 350000 --from $WALLET_NAME -b sync -y --node $RPC_URL

bandd tx bandtss add-grantees $(cylinder keys list -a --home $CYLINDER_HOME_PATH) --gas-prices 0.0025uband --keyring-backend test --chain-id $CHAIN_ID --gas 350000 --from $WALLET_NAME -b sync -y --node $RPC_URL
```

## Run the cylinder program
Expand Down
28 changes: 14 additions & 14 deletions cylinder/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ import (

// Config data structure for Cylinder process.
type Config struct {
ChainID string `mapstructure:"chain-id"` // ChainID of the target chain
NodeURI string `mapstructure:"node"` // Remote RPC URI of BandChain node to connect to
Granter string `mapstructure:"granter"` // The granter address
GasPrices string `mapstructure:"gas-prices"` // Gas prices of the transaction
LogLevel string `mapstructure:"log-level"` // Log level of the logger
MaxMessages uint64 `mapstructure:"max-messages"` // The maximum number of messages in a transaction
BroadcastTimeout time.Duration `mapstructure:"broadcast-timeout"` // The time that cylinder will wait for tx commit
RPCPollInterval time.Duration `mapstructure:"rpc-poll-interval"` // The duration of rpc poll interval
MaxTry uint64 `mapstructure:"max-try"` // The maximum number of tries to submit a report transaction
MinDE uint64 `mapstructure:"min-de"` // The minimum number of DE
GasAdjustStart float64 `mapstructure:"gas-adjust-start"` // The start value of gas adjustment
GasAdjustStep float64 `mapstructure:"gas-adjust-step"` // The increment step of gad adjustment
RandomSecret tss.Scalar `mapstructure:"random-secret"` // The secret value that is used for random D,E
ActivePeriod time.Duration `mapstructure:"active-period"` // The time period that cylinder will send active status to chain
ChainID string `mapstructure:"chain-id"` // ChainID of the target chain
NodeURI string `mapstructure:"node"` // Remote RPC URI of BandChain node to connect to
Granter string `mapstructure:"granter"` // The granter address
GasPrices string `mapstructure:"gas-prices"` // Gas prices of the transaction
LogLevel string `mapstructure:"log-level"` // Log level of the logger
MaxMessages uint64 `mapstructure:"max-messages"` // The maximum number of messages in a transaction
BroadcastTimeout time.Duration `mapstructure:"broadcast-timeout"` // The time that cylinder will wait for tx commit
RPCPollInterval time.Duration `mapstructure:"rpc-poll-interval"` // The duration of rpc poll interval
MaxTry uint64 `mapstructure:"max-try"` // The maximum number of tries to submit a report transaction
MinDE uint64 `mapstructure:"min-de"` // The minimum number of DE
GasAdjustStart float64 `mapstructure:"gas-adjust-start"` // The start value of gas adjustment
GasAdjustStep float64 `mapstructure:"gas-adjust-step"` // The increment step of gad adjustment
RandomSecret tss.Scalar `mapstructure:"random-secret"` // The secret value that is used for random D,E
CheckingDEInterval time.Duration `mapstructure:"checking-de-interval"` // The interval for updating DE
}

// Context holds the context information for the Cylinder process.
Expand Down
17 changes: 12 additions & 5 deletions cylinder/workers/de/de.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de
import (
"encoding/hex"
"fmt"
"time"

abci "github.com/cometbft/cometbft/abci/types"
ctypes "github.com/cometbft/cometbft/rpc/core/types"
Expand All @@ -17,6 +18,8 @@ import (
"github.com/bandprotocol/chain/v3/x/tss/types"
)

var _ cylinder.Worker = &DE{}

// DE is a worker responsible for generating own nonce (DE) of signing process
type DE struct {
context *context.Context
Expand All @@ -26,8 +29,6 @@ type DE struct {
useEventCh <-chan ctypes.ResultEvent
}

var _ cylinder.Worker = &DE{}

// New creates a new instance of the DE worker.
// It initializes the necessary components and returns the created DE instance or an error if initialization fails.
func New(ctx *context.Context) (*DE, error) {
Expand Down Expand Up @@ -165,9 +166,15 @@ func (de *DE) Start() {
}
}()

// Update if there is assigned DE event.
for range de.assignEventCh {
go de.updateDE()
// Update DE if there is assigned DE event or DE is used.
ticker := time.NewTicker(de.context.Config.CheckingDEInterval)
for {
select {
case <-ticker.C:
de.updateDE()
case <-de.assignEventCh:
de.updateDE()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/ibc-go/modules/capability v1.0.1
github.com/cosmos/ibc-go/v8 v8.5.1
github.com/cosmos/ibc-go/v8 v8.5.2
github.com/cosmos/ics23/go v0.11.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
github.com/ethereum/go-ethereum v1.14.8
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM=
github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI=
github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI=
github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E=
github.com/cosmos/ibc-go/v8 v8.5.1 h1:3JleEMKBjRKa3FeTKt4fjg22za/qygLBo7mDkoYTNBs=
github.com/cosmos/ibc-go/v8 v8.5.1/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo=
github.com/cosmos/ibc-go/v8 v8.5.2 h1:27s9oeD2AxLQF3e9BQsYt9doONyZ7FwZi/qkBv6Sdks=
github.com/cosmos/ibc-go/v8 v8.5.2/go.mod h1:P5hkAvq0Qbg0h18uLxDVA9q1kOJ0l36htMsskiNwXbo=
github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU=
github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0=
github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo=
Expand Down
Loading

0 comments on commit 28e4766

Please sign in to comment.