Skip to content

Commit

Permalink
Merge branch 'main' into fix/audit
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Jul 17, 2024
2 parents 263a1f1 + c95783c commit 401e399
Show file tree
Hide file tree
Showing 35 changed files with 929 additions and 1,017 deletions.
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ignore:
- "**/cli"
- "**/rest"
- "**/*.pb.go"
- "**/*.pulsar.go"
- "**/*.pb.gw.go"
- "**/test_utils.go"
- "**/module.go"
Expand Down
34 changes: 27 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ jobs:
# for private repo access
GOPRIVATE: github.com/initia-labs,github.com/skip-mev/slinky
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }}
GOLANGCI_LINT_VERSION: v1.59.1
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2.1.4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: technote-space/get-diff-action@v5
check-latest: true
- uses: technote-space/get-diff-action@v6.1.2
id: git_diff
with:
PATTERNS: |
Expand All @@ -41,11 +44,27 @@ jobs:
go.sum
# for private repo access
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:x-oauth-basic@github.com/.insteadOf https://github.com/
- name: run go linters
# install golangci-lint
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
- name: run go linters (long)
if: env.GIT_DIFF
id: lint_long
run: |
make tools
make lint
if: env.GIT_DIFF
- uses: technote-space/get-diff-action@v6.1.2
if: steps.lint_long.outcome == 'skipped'
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: run go linters (short)
if: steps.lint_long.outcome == 'skipped' && env.GIT_DIFF
run: |
make lint
env:
GIT_DIFF: ${{ env.GIT_DIFF }}
LINT_DIFF: 1
# Use --check or --exit-code when available (Go 1.19?)
# https://github.com/golang/go/issues/27005
tidy:
Expand All @@ -56,11 +75,12 @@ jobs:
runs-on: ubuntu-latest
name: tidy
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.22
check-latest: true
# for private repo access
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:x-oauth-basic@github.com/.insteadOf https://github.com/
- run: |
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ proto-format:
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(protoImage) buf lint --error-format=json
@$(protoImage) buf lint --error-format=json ./proto

proto-check-breaking:
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main
Expand Down Expand Up @@ -235,10 +235,10 @@ benchmark:
###############################################################################

lint:
golangci-lint run --out-format=tab
golangci-lint run --out-format=tab --timeout=15m

lint-fix:
golangci-lint run --fix --out-format=tab --issues-exit-code=0
golangci-lint run --fix --out-format=tab --timeout=15m
.PHONY: lint lint-fix

format:
Expand Down
2 changes: 1 addition & 1 deletion app/ante/sigverify/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func internalSignModeToAPI(mode signing.SignMode) (signingv1beta1.SignMode, erro
case signing.SignMode_SIGN_MODE_DIRECT_AUX:
return signingv1beta1.SignMode_SIGN_MODE_DIRECT_AUX, nil
case signing.SignMode_SIGN_MODE_EIP_191:
return signingv1beta1.SignMode_SIGN_MODE_EIP_191, nil
return signingv1beta1.SignMode_SIGN_MODE_EIP_191, nil //nolint
default:
return signingv1beta1.SignMode_SIGN_MODE_UNSPECIFIED, fmt.Errorf("unsupported sign mode %s", mode)
}
Expand Down
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,9 @@ func (app *InitiaApp) Close() error {

// close the oracle service
if app.OracleClient != nil {
app.OracleClient.Stop()
if err := app.OracleClient.Stop(); err != nil {
return err
}
}

return nil
Expand Down
32 changes: 24 additions & 8 deletions cmd/initiad/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,30 @@ func initAppConfig() (string, interface{}) {
func initTendermintConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()

// set block time to 3s
cfg.Consensus.TimeoutPropose = 1800 * time.Millisecond
cfg.Consensus.TimeoutProposeDelta = 300 * time.Millisecond
cfg.Consensus.TimeoutPrevote = 600 * time.Millisecond
cfg.Consensus.TimeoutPrevoteDelta = 300 * time.Millisecond
cfg.Consensus.TimeoutPrecommit = 600 * time.Millisecond
cfg.Consensus.TimeoutPrecommitDelta = 300 * time.Millisecond
cfg.Consensus.TimeoutCommit = 3000 * time.Millisecond
// performance turning configs
cfg.P2P.SendRate = 20480000
cfg.P2P.RecvRate = 20480000
cfg.P2P.MaxPacketMsgPayloadSize = 1000000 // 1MB
cfg.P2P.FlushThrottleTimeout = 10 * time.Millisecond
cfg.Consensus.PeerGossipSleepDuration = 30 * time.Millisecond

// mempool configs
cfg.Mempool.Size = 1000
cfg.Mempool.MaxTxsBytes = 10737418240
cfg.Mempool.MaxTxBytes = 2048576

// set propose timeout to 3s and increase timeout by 500ms each round
cfg.Consensus.TimeoutPropose = 3 * time.Second
cfg.Consensus.TimeoutProposeDelta = 500 * time.Millisecond

// no need to increase wait timeout(delta) for prevote and precommit
cfg.Consensus.TimeoutPrevote = 500 * time.Millisecond
cfg.Consensus.TimeoutPrevoteDelta = 0 * time.Millisecond
cfg.Consensus.TimeoutPrecommit = 500 * time.Millisecond
cfg.Consensus.TimeoutPrecommitDelta = 0 * time.Millisecond

// set commit timeout to 2s
cfg.Consensus.TimeoutCommit = 2 * time.Second

return cfg
}
2 changes: 2 additions & 0 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ lint:
- SERVICE_SUFFIX
- PACKAGE_VERSION_SUFFIX
- RPC_REQUEST_STANDARD_NAME
- ENUM_VALUE_PREFIX
- ENUM_ZERO_VALUE_SUFFIX
1 change: 0 additions & 1 deletion proto/ibc/applications/nft_transfer/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ syntax = "proto3";
package ibc.applications.nft_transfer.v1;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
Expand Down
1 change: 0 additions & 1 deletion proto/ibc/applications/nft_transfer/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ option go_package = "github.com/initia-labs/initia/x/ibc/nft-transfer/types";

import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "cosmos_proto/cosmos.proto";

// ClassTrace contains the base class id for ICS721 non fungible tokens and the
// source tracing information path.
Expand Down
3 changes: 2 additions & 1 deletion proto/ibc/applications/perm/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ option go_package = "github.com/initia-labs/initia/x/ibc/perm/types";
// Query provides defines the gRPC querier service.
service Query {
// PermissionedRelayersByChannel queries a set of permissioned ibc relayers for the specific channel.
rpc PermissionedRelayersByChannel(QueryPermissionedRelayersByChannelRequest) returns (QueryPermissionedRelayersByChannelResponse) {
rpc PermissionedRelayersByChannel(QueryPermissionedRelayersByChannelRequest)
returns (QueryPermissionedRelayersByChannelResponse) {
option (google.api.http).get = "/ibc/apps/perm/v1/relayers/{port_id}/{channel_id}";
}

Expand Down
8 changes: 1 addition & 7 deletions proto/ibc/applications/perm/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "amino/amino.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "ibc/applications/perm/v1/types.proto";
option go_package = "github.com/initia-labs/initia/x/ibc/perm/types";

// Msg defines the ibc/perm Msg service
Expand All @@ -14,7 +13,6 @@ service Msg {

// SetPermissionedRelayers defines a rpc handler method for MsgSetPermissionedRelayers.
rpc SetPermissionedRelayers(MsgSetPermissionedRelayers) returns (MsgSetPermissionedRelayersResponse);

}

// MsgSetPermissionedRelayers defines msg to set permissioned relyer for
Expand All @@ -31,12 +29,8 @@ message MsgSetPermissionedRelayers {
string authority = 1 [(gogoproto.moretags) = "yaml:\"authority\"", (cosmos_proto.scalar) = "cosmos.AddressString"];
string port_id = 2 [(gogoproto.moretags) = "yaml:\"port_id\""];
string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""];
repeated string relayers = 4 [(gogoproto.moretags) = "yaml:\"relayers\""];
repeated string relayers = 4 [(gogoproto.moretags) = "yaml:\"relayers\""];
}

// MsgSetPermissionedRelayersResponse defines the Msg/SetPermissionedRelayer response type.
message MsgSetPermissionedRelayersResponse {}




8 changes: 5 additions & 3 deletions proto/ibc/applications/perm/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ option go_package = "github.com/initia-labs/initia/x/ibc/perm/types";
// PermissionedRelayer is used to specifiy the permissioned relayer for
// the specific port-id:channel-id pair.
message PermissionedRelayers {
string port_id = 1;
string channel_id = 2;
repeated string relayers = 3;
string port_id = 1;
string channel_id = 2;
repeated string relayers = 3;
}

// PermissionedRelayersList is used to specify the list of permissioned relayers
// for the specific port-id:channel-id pair.
message PermissionedRelayersList {
repeated string relayers = 1;
}
1 change: 0 additions & 1 deletion proto/initia/distribution/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ option go_package = "github.com/initia-labs/initia/x/distribution/typ
option (gogoproto.equal_all) = true;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/distribution/v1beta1/distribution.proto";
import "cosmos/distribution/v1beta1/genesis.proto";
import "initia/distribution/v1/distribution.proto";
Expand Down
1 change: 0 additions & 1 deletion proto/initia/distribution/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package initia.distribution.v1;
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";

import "cosmos/base/v1beta1/coin.proto";
import "cosmos/base/query/v1beta1/pagination.proto";

import "initia/distribution/v1/distribution.proto";
Expand Down
3 changes: 0 additions & 3 deletions proto/initia/gov/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ syntax = "proto3";

package initia.gov.v1;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/gov/v1/gov.proto";
import "initia/gov/v1/gov.proto";
import "amino/amino.proto";

option go_package = "github.com/initia-labs/initia/x/gov/types";

Expand Down
2 changes: 0 additions & 2 deletions proto/initia/gov/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package initia.gov.v1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/gov/v1/gov.proto";
import "amino/amino.proto";
import "initia/gov/v1/gov.proto";

option go_package = "github.com/initia-labs/initia/x/gov/types";
Expand Down
15 changes: 7 additions & 8 deletions proto/initia/move/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,15 @@ message TableEntry {
bytes value_bytes = 5;
}

// UpgradePolicy
// * `compatible`
// Whether a compatibility check should be performed for upgrades. The check only passes if
// a new module has (a) the same public functions (b) for existing resources, no layout change.
// * `immutable`
// Whether the modules in the package are immutable and cannot be upgraded.
// UpgradePolicy is the policy for upgrading a move module.
enum UpgradePolicy {
// UNSPECIFIED: a placeholder for an unspecified upgrade policy.
UNSPECIFIED = 0;
COMPATIBLE = 1;
IMMUTABLE = 2;
// COMPATBILE: Whether a compatibility check should be performed for upgrades. The check only passes if
// a new module has (a) the same public functions (b) for existing resources, no layout change.
COMPATIBLE = 1;
// IMMUTABLE: Whether the modules in the package are immutable and cannot be upgraded.
IMMUTABLE = 2;
}

// proto wrapper to store the value
Expand Down
1 change: 0 additions & 1 deletion proto/initia/mstaking/v1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "tendermint/types/types.proto";

option go_package = "github.com/initia-labs/initia/x/mstaking/types";

Expand Down
1 change: 1 addition & 0 deletions proto/initia/reward/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ option go_package = "github.com/initia-labs/initia/x/reward/types";
service Msg {
option (cosmos.msg.v1.service) = true;

// UpdateParams defines a rpc handler method for MsgUpdateParams.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

Expand Down
2 changes: 1 addition & 1 deletion tx/eip191.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var _ signing.SignModeHandler = SignModeEIP191Handler{}

// Mode implements signing.SignModeHandler.Mode.
func (SignModeEIP191Handler) Mode() signingv1beta1.SignMode {
return signingv1beta1.SignMode_SIGN_MODE_EIP_191
return signingv1beta1.SignMode_SIGN_MODE_EIP_191 //nolint
}

// GetSignBytes implements SignModeHandler.GetSignBytes
Expand Down
Loading

0 comments on commit 401e399

Please sign in to comment.