Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(v2.10): carry changes up from 2.9 #247

Merged
merged 7 commits into from
Jan 26, 2024
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
6 changes: 6 additions & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/cosmos/cosmos-sdk/std"

"github.com/terra-money/core/v2/app/params"
pobtypes "github.com/terra-money/core/v2/x/builder/types"
)

var legacyCodecRegistered = false
Expand All @@ -17,6 +18,11 @@ func MakeEncodingConfig() params.EncodingConfig {
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)

// Register POB interfaces and concrete types
// for the POB module that was used back in the day.
pobtypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
pobtypes.RegisterLegacyAminoCodec(encodingConfig.Amino)

if !legacyCodecRegistered {
// authz module use this codec to get signbytes.
// authz MsgExec can execute all message types,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
cosmossdk.io/math v1.2.0
cosmossdk.io/tools/rosetta v0.2.1
github.com/CosmWasm/wasmd v0.45.0
github.com/CosmWasm/wasmvm v1.5.0
github.com/CosmWasm/wasmvm v1.5.2
github.com/cometbft/cometbft v0.37.2
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-proto v1.0.0-beta.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQ
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/CosmWasm/wasmd v0.45.0 h1:9zBqrturKJwC2kVsfHvbrA++EN0PS7UTXCffCGbg6JI=
github.com/CosmWasm/wasmd v0.45.0/go.mod h1:RnSAiqbNIZu4QhO+0pd7qGZgnYAMBPGmXpzTADag944=
github.com/CosmWasm/wasmvm v1.5.0 h1:3hKeT9SfwfLhxTGKH3vXaKFzBz1yuvP8SlfwfQXbQfw=
github.com/CosmWasm/wasmvm v1.5.0/go.mod h1:fXB+m2gyh4v9839zlIXdMZGeLAxqUdYdFQqYsTha2hc=
github.com/CosmWasm/wasmvm v1.5.2 h1:+pKB1Mz9GZVt1vadxB+EDdD1FOz3dMNjIKq/58/lrag=
github.com/CosmWasm/wasmvm v1.5.2/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/modules/gov/gov.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/rele
// Query the alliance and check if it exists
const res = await LCD.chain2.gov.tally("test-2", proposalId);
expect(res).toBeDefined();
expect(res.yes_count.gte(27000000000)).toBeTruthy();
expect(res.yes_count.gte(7000000000)).toBeTruthy();
expect(res.abstain_count).toStrictEqual(new Int(0));
expect(res.no_count).toStrictEqual(new Int(0));
expect(res.no_with_veto_count).toStrictEqual(new Int(0));
Expand Down
44 changes: 44 additions & 0 deletions proto/pob/builder/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";
package pob.builder.v1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "amino/amino.proto";

option go_package = "github.com/skip-mev/pob/x/builder/types";

// GenesisState defines the genesis state of the x/builder module.
message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; }

// Params defines the parameters of the x/builder module.
message Params {
option (amino.name) = "cosmos-sdk/x/builder/Params";

// max_bundle_size is the maximum number of transactions that can be bundled
// in a single bundle.
uint32 max_bundle_size = 1;

// escrow_account_address is the address of the account that will receive a
// portion of the bid proceeds.
bytes escrow_account_address = 2;

// reserve_fee specifies the bid floor for the auction.
cosmos.base.v1beta1.Coin reserve_fee = 3
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// min_bid_increment specifies the minimum amount that the next bid must be
// greater than the previous bid.
cosmos.base.v1beta1.Coin min_bid_increment = 4
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];

// front_running_protection specifies whether front running and sandwich
// attack protection is enabled.
bool front_running_protection = 5;

// proposer_fee defines the portion of the winning bid that goes to the block
// proposer that proposed the block.
string proposer_fee = 6 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec"
];
}
67 changes: 67 additions & 0 deletions proto/pob/builder/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
syntax = "proto3";
package pob.builder.v1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/v1beta1/coin.proto";
import "pob/builder/v1/genesis.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "amino/amino.proto";

option go_package = "github.com/skip-mev/pob/x/builder/types";

// Msg defines the x/builder Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;

// AuctionBid defines a method for sending bids to the x/builder module.
rpc AuctionBid(MsgAuctionBid) returns (MsgAuctionBidResponse) {
option (google.api.http).post = "/pob/builder/v1/bid";
};

// UpdateParams defines a governance operation for updating the x/builder
// module parameters. The authority is hard-coded to the x/gov module account.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgAuctionBid defines a request type for sending bids to the x/builder
// module.
message MsgAuctionBid {
option (cosmos.msg.v1.signer) = "bidder";
option (amino.name) = "pob/x/builder/MsgAuctionBid";

option (gogoproto.equal) = false;

// bidder is the address of the account that is submitting a bid to the
// auction.
string bidder = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// bid is the amount of coins that the bidder is bidding to participate in the
// auction.
cosmos.base.v1beta1.Coin bid = 2
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
// transactions are the bytes of the transactions that the bidder wants to
// bundle together.
repeated bytes transactions = 3;
}

// MsgAuctionBidResponse defines the Msg/AuctionBid response type.
message MsgAuctionBidResponse {}

// MsgUpdateParams defines a request type for updating the x/builder module
// parameters.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "pob/x/builder/MsgUpdateParams";

option (gogoproto.equal) = false;

// authority is the address of the account that is authorized to update the
// x/builder module parameters.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// params is the new parameters for the x/builder module.
Params params = 2 [ (gogoproto.nullable) = false ];
}

// MsgUpdateParamsResponse defines the Msg/UpdateParams response type.
message MsgUpdateParamsResponse {}
3 changes: 2 additions & 1 deletion scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
echo "Generating gogo proto code"
cd proto

proto_dirs=$(find ./osmosis ./juno ./terra -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
proto_dirs=$(find ./osmosis ./juno ./terra ./pob -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
for dir in $proto_dirs; do
for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do
# this regex checks if a proto file has its go_package set to cosmossdk.io/api/...
Expand All @@ -22,5 +22,6 @@ cd ..
# move proto files to the right places
cp -r github.com/osmosis-labs/osmosis/v17/* ./
cp -r github.com/CosmosContracts/juno/* ./
cp -r github.com/skip-mev/pob/* ./
cp -r github.com/terra-money/core/v2/* ./
rm -rf github.com
53 changes: 53 additions & 0 deletions x/builder/types/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package types

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec"
groupcodec "github.com/cosmos/cosmos-sdk/x/group/codec"
)

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)

// Register all Amino interfaces and concrete types on the authz and gov
// Amino codec so that this can later be used to properly serialize MsgGrant,
// MsgExec and MsgSubmitProposal instances.
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(groupcodec.Amino)
}

// RegisterLegacyAminoCodec registers the necessary x/builder interfaces and
// concrete types on the provided LegacyAmino codec. These types are used for
// Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
legacy.RegisterAminoMsg(cdc, &MsgAuctionBid{}, "pob/x/builder/MsgAuctionBid")
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "pob/x/builder/MsgUpdateParams")

cdc.RegisterConcrete(Params{}, "pob/builder/Params", nil)
}

// RegisterInterfaces registers the x/builder interfaces types with the
// interface registry.
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgAuctionBid{},
&MsgUpdateParams{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
Loading
Loading