Skip to content

Commit

Permalink
Merge branch 'main' into alpo/sudo-gas-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpinYukseloglu committed Mar 21, 2024
2 parents 114ca62 + d28ed22 commit 84abef6
Show file tree
Hide file tree
Showing 35 changed files with 1,365 additions and 256 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#7689](https://github.com/osmosis-labs/osmosis/pull/7689) Make CL price estimations not cause state writes (speed and gas improvements)
* [#7745](https://github.com/osmosis-labs/osmosis/pull/7745) Add gauge id query to stargate whitelist
* [#7747](https://github.com/osmosis-labs/osmosis/pull/7747) Remove redundant call to incentive collection in CL position withdrawal logic
* [#7746](https://github.com/osmosis-labs/osmosis/pull/7746) Make forfeited incentives redeposit into the pool instead of sending to community pool
* [#7785](https://github.com/osmosis-labs/osmosis/pull/7785) Remove reward claiming during position transfers
* [#7527](https://github.com/osmosis-labs/osmosis/pull/7527) Add 30M gas limit to CW pool contract calls

## v23.0.8-iavl-v1 & v23.0.8

* [#7769](https://github.com/osmosis-labs/osmosis/pull/7769) Set and default timeout commit to 3s. Add flag to prevent custom overrides if not desired.

## v23.0.7-iavl-v1

* [#7750](https://github.com/osmosis-labs/osmosis/pull/7750) IAVL bump to improve pruning
Expand Down
7 changes: 5 additions & 2 deletions cmd/osmosisd/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const (

// FlagSetEnv defines a flag to create environment file & save current home directory into it.
FlagSetEnv = "set-env"

// FlagRejectConfigDefaults defines a flag to reject some select defaults that override what is in the config file.
FlagRejectConfigDefaults = "reject-config-defaults"
)

type printInfo struct {
Expand Down Expand Up @@ -109,8 +112,8 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
config.StateSync.TrustPeriod = 112 * time.Hour

// The original default is 5s and is set in Cosmos SDK.
// We lower it to 4s for faster block times.
config.Consensus.TimeoutCommit = 4 * time.Second
// We lower it to 3s for faster block times.
config.Consensus.TimeoutCommit = 3 * time.Second

config.SetRoot(clientCtx.HomeDir)

Expand Down
41 changes: 23 additions & 18 deletions cmd/osmosisd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ const (

var (
//go:embed "osmosis-1-assetlist.json" "osmo-test-5-assetlist.json"
assetFS embed.FS
mainnetId = "osmosis-1"
testnetId = "osmo-test-5"
fiveSecondsString = (5 * time.Second).String()
assetFS embed.FS
mainnetId = "osmosis-1"
testnetId = "osmo-test-5"
)

func loadAssetList(initClientCtx client.Context, cmd *cobra.Command, basedenomToIBC, IBCtoBasedenom bool) (map[string]DenomUnitMap, map[string]string) {
Expand Down Expand Up @@ -440,7 +439,7 @@ func overwriteConfigTomlValues(serverCtx *server.Context) error {
// It does not exist, so we update the default config.toml to update
// We modify the default config.toml to have faster block times
// It will be written by server.InterceptConfigsPreRunHandler
tmcConfig.Consensus.TimeoutCommit = 4 * time.Second
tmcConfig.Consensus.TimeoutCommit = 3 * time.Second
} else {
// config.toml exists

Expand All @@ -466,10 +465,8 @@ func overwriteConfigTomlValues(serverCtx *server.Context) error {
}

// The original default is 5s and is set in Cosmos SDK.
// We lower it to 4s for faster block times.
if timeoutCommitValue == fiveSecondsString {
serverCtx.Config.Consensus.TimeoutCommit = 4 * time.Second
}
// We lower it to 3s for faster block times.
serverCtx.Config.Consensus.TimeoutCommit = 3 * time.Second

defer func() {
if err := recover(); err != nil {
Expand Down Expand Up @@ -700,16 +697,23 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
cmd.RunE = func(cmd *cobra.Command, args []string) error {
serverCtx := server.GetServerContextFromCmd(cmd)

// overwrite config.toml values
err := overwriteConfigTomlValues(serverCtx)
if err != nil {
return err
}
// Get flag value for rejecting config defaults
rejectConfigDefaults := serverCtx.Viper.GetBool(FlagRejectConfigDefaults)

// overwrite app.toml values
err = overwriteAppTomlValues(serverCtx)
if err != nil {
return err
// overwrite config.toml and app.toml values, if rejectConfigDefaults is false
if !rejectConfigDefaults {
// Add ctx logger line to indicate that config.toml and app.toml values are being overwritten
serverCtx.Logger.Info("Overwriting config.toml and app.toml values with some recommended defaults. To prevent this, set the --reject-config-defaults flag to true.")

err := overwriteConfigTomlValues(serverCtx)
if err != nil {
return err
}

err = overwriteAppTomlValues(serverCtx)
if err != nil {
return err
}
}

return startRunE(cmd, args)
Expand All @@ -734,6 +738,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
wasm.AddModuleInitFlags(startCmd)
startCmd.Flags().Bool(FlagRejectConfigDefaults, false, "Reject some select recommended default values from being automatically set in the config.toml and app.toml")
}

// queryCommand adds transaction and account querying commands.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gorilla/websocket v1.5.0
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
github.com/gostaticanalysis/comment v1.4.2 // indirect
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
Expand Down
28 changes: 28 additions & 0 deletions proto/osmosis/bridge/v1beta1/bridge.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,32 @@ enum AssetStatus {
ASSET_STATUS_BLOCKED_INBOUND = 2;
ASSET_STATUS_BLOCKED_OUTBOUND = 3;
ASSET_STATUS_BLOCKED_BOTH = 4;
}

// InboundTransfer is a representation of the inbound transfer.
message InboundTransfer {
// ExternalId is a unique ID of the transfer coming from outside.
// Serves the purpose of uniquely identifying the transfer in another chain
// (e.g., this might be the BTC tx hash).
string external_id = 1 [ (gogoproto.moretags) = "yaml:\"external_id\"" ];
// DestAddr is a destination Osmosis address
string dest_addr = 2 [ (gogoproto.moretags) = "yaml:\"dest_addr\"" ];
// AssetID is the ID of the asset being transferred
AssetID asset_id = 3 [
(gogoproto.moretags) = "yaml:\"asset_id\"",
(gogoproto.nullable) = false
];
// Amount of coins to transfer
string amount = 4 [
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
// Voters is a list of validators signed this transfer
repeated string voters = 5 [ (gogoproto.moretags) = "yaml:\"voters\"" ];
// Finalized indicates whether the transfer needs more votes or has
// already accumulated a sufficient number. The finalised flag is set
// to true as soon as length(voters) is greater than or equal to
// the module's param votes_needed.
bool finalized = 6 [ (gogoproto.moretags) = "yaml:\"finalized\"" ];
}
12 changes: 8 additions & 4 deletions proto/osmosis/bridge/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ service Msg {
message MsgInboundTransfer {
option (amino.name) = "osmosis/bridge/inbound-transfer";

// ExternalId is a unique ID of the transfer coming from outside.
// Serves the purpose of uniquely identifying the transfer in another chain
// (e.g., this might be the BTC tx hash)
string external_id = 1 [ (gogoproto.moretags) = "yaml:\"external_id\"" ];
// Sender is a sender's address
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
string sender = 2 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
// DestAddr is a destination Osmosis address
string dest_addr = 2 [ (gogoproto.moretags) = "yaml:\"dest_addr\"" ];
string dest_addr = 3 [ (gogoproto.moretags) = "yaml:\"dest_addr\"" ];
// AssetID is the ID of the asset being transferred
AssetID asset_id = 3 [
AssetID asset_id = 4 [
(gogoproto.moretags) = "yaml:\"asset_id\"",
(gogoproto.nullable) = false
];
// Amount of coins to transfer
string amount = 4 [
string amount = 5 [
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
Expand Down
6 changes: 4 additions & 2 deletions tests/e2e/configurer/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ func (bc *baseConfigurer) runValidators(chainConfig *chain.Config) error {
// Iterate over each node
for _, node := range chainConfig.NodeConfigs {
go func(n *chain.NodeConfig) {
defer wg.Done() // Decrement the WaitGroup counter when the goroutine is done
errCh <- n.Run() // Run the node and send any error to the channel
defer wg.Done() // Decrement the WaitGroup counter when the goroutine is done
// TODO: After v24, either set this to true or remove the entire logic added in https://github.com/osmosis-labs/osmosis/pull/7784
// and just set --reject-config-defaults=true directly here https://github.com/osmosis-labs/osmosis/blob/b106139bcfe5605fb2fedd6237d9467497cf3ded/tests/e2e/containers/containers.go#L492-L493
errCh <- n.Run(false) // Run the node and send any error to the channel
}(node)
}

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/configurer/chain/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ func NewNodeConfig(t *testing.T, initNode *initialization.Node, initConfig *init
// Run runs a node container for the given nodeIndex.
// The node configuration must be already added to the chain config prior to calling this
// method.
func (n *NodeConfig) Run() error {
func (n *NodeConfig) Run(rejectConfigDefaults bool) error {
maxRetries := 3
currentRetry := 0

for currentRetry < maxRetries {
n.t.Logf("starting node container: %s", n.Name)
resource, err := n.containerManager.RunNodeResource(n.chainId, n.Name, n.ConfigDir)
resource, err := n.containerManager.RunNodeResource(n.chainId, n.Name, n.ConfigDir, rejectConfigDefaults)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/configurer/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func (uc *UpgradeConfigurer) upgradeContainers(chainConfig *chain.Config, propHe
uc.containerManager.OsmosisTag = containers.CurrentBranchOsmoTag

for _, node := range chainConfig.NodeConfigs {
if err := node.Run(); err != nil {
if err := node.Run(true); err != nil {
return err
}
}
Expand Down
9 changes: 7 additions & 2 deletions tests/e2e/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,19 +472,24 @@ func (m *Manager) RunHermesResource(chainAID, osmoARelayerNodeName, osmoAValMnem

// RunNodeResource runs a node container. Assigns containerName to the container.
// Mounts the container on valConfigDir volume on the running host. Returns the container resource and error if any.
func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir string) (*dockertest.Resource, error) {
func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir string, rejectConfigDefaults bool) (*dockertest.Resource, error) {
pwd, err := os.Getwd()
if err != nil {
return nil, err
}

cmd := []string{"start"}
if rejectConfigDefaults {
cmd = append(cmd, "--reject-config-defaults=true")
}

runOpts := &dockertest.RunOptions{
Name: containerName,
Repository: m.OsmosisRepository,
Tag: m.OsmosisTag,
NetworkID: m.network.Network.ID,
User: "root:root",
Cmd: []string{"start"},
Cmd: cmd,
Mounts: []string{
fmt.Sprintf("%s/:/osmosis/.osmosisd", valCondifDir),
fmt.Sprintf("%s/scripts:/osmosis", pwd),
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *IntegrationTestSuite) StateSync() {
chainANode.WaitUntil(hasSnapshotsAvailable)

// start the state synchin node.
err = stateSynchingNode.Run()
err = stateSynchingNode.Run(true)
s.Require().NoError(err)

// ensure that the state syncing node cathes up to the running node.
Expand Down
Binary file added x/bridge/images/inbound_transfer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 98 additions & 0 deletions x/bridge/images/inbound_transfer.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@startuml

actor "Client" as client
node "BTC vault" as vault

client --> vault : send BTC

folder "Valset" as valset1 {
cloud "Validator 1" as val1 #lightgreen
cloud "Validator 2" as val2
cloud "Validator 3" as val3 #lightgreen
cloud "Validator 4" as val4
cloud "Validator 5" as val5 #lightgreen
}

note bottom of valset1
Green validators are
running x/bridge observers.

Let's say that we need **three**
votes to process the transfer.
end note

folder "Valset" as valset2 {
cloud "Validator 1" as val1_2 #lightgreen
cloud "Validator 2" as val2_2
cloud "Validator 3" as val3_2 #lightgreen
cloud "Validator 4" as val4_2
cloud "Validator 5" as val5_2 #lightgreen
}

vault <-- val1 : observe
vault <-- val3 : observe
vault <-- val5 : observe

node "Chain proposer" as proposer

val1 --> proposer : MsgInboundTransfer
val3 --> proposer : MsgInboundTransfer
val5 --> proposer : MsgInboundTransfer

json Block {
"1":"MsgInboundTransfer",
"2":"MsgInboundTransfer",
"3":"MsgInboundTransfer"
}

proposer --> Block : forms a block to process

Block <-- val1_2 : process
Block <-- val2_2 : process
Block <-- val3_2 : process
Block <-- val4_2 : process
Block <-- val5_2 : process

action "Process each\nMsgInboundTransfer" as val1_act_1
action "Process each\nMsgInboundTransfer" as val2_act_1
action "Process each\nMsgInboundTransfer" as val3_act_1
action "Process each\nMsgInboundTransfer" as val4_act_1
action "Process each\nMsgInboundTransfer" as val5_act_1

val1_2 --> val1_act_1
val2_2 --> val2_act_1
val3_2 --> val3_act_1
val4_2 --> val4_act_1
val5_2 --> val5_act_1

action "Accumulate votes x3" as val1_act_2
action "Is not a part\nof the signers set" as val2_act_2 #red
action "Accumulate votes x3" as val3_act_2
action "Is not a part\nof the signers set" as val4_act_2 #red
action "Accumulate votes x3" as val5_act_2

val1_act_1 --> val1_act_2
val2_act_1 --> val2_act_2
val3_act_1 --> val3_act_2
val4_act_1 --> val4_act_2
val5_act_1 --> val5_act_2

action "Call tokenfactory mint" as val1_act_3
action "Call tokenfactory mint" as val3_act_3
action "Call tokenfactory mint" as val5_act_3

val1_act_2 --> val1_act_3
val3_act_2 --> val3_act_3
val5_act_2 --> val5_act_3

node "Submit the block" as consensus

val1_act_3 --> consensus
val3_act_3 --> consensus
val5_act_3 --> consensus

note left of consensus
The transfer is done!
end note

@enduml
9 changes: 9 additions & 0 deletions x/bridge/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import (

"github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

"github.com/osmosis-labs/osmosis/v23/x/bridge/types"
)

type Keeper struct {
storeKey storetypes.StoreKey
cdc codec.BinaryCodec

// paramSpace stores module's params
paramSpace paramtypes.Subspace
// router is used to access tokenfactory methods
Expand All @@ -25,6 +30,8 @@ type Keeper struct {

// NewKeeper returns a new instance of the x/bridge keeper.
func NewKeeper(
storeKey storetypes.StoreKey,
cdc codec.BinaryCodec,
paramSpace paramtypes.Subspace,
router *baseapp.MsgServiceRouter,
accountKeeper types.AccountKeeper,
Expand All @@ -40,6 +47,8 @@ func NewKeeper(
}

return Keeper{
storeKey: storeKey,
cdc: cdc,
paramSpace: paramSpace,
router: router,
accountKeeper: accountKeeper,
Expand Down
Loading

0 comments on commit 84abef6

Please sign in to comment.