Skip to content
Draft
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
29 changes: 0 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
# name: Release

# on:
# release:
# types:
# - published

# jobs:
# dispatch:
# runs-on: ubuntu-latest
# steps:
# - name: Get the tag
# id: release_tag
# run: echo ::set-output name=name::${GITHUB_REF/refs\/tags\//}

# - uses: convictional/[email protected]
# with:
# owner: sifchain
# repo: sifchain-chainops
# github_token: ${{ secrets.GIT_PAT }}
# workflow_file_name: sifnode-release.yml
# client_payload: '{ "release_tag": "${{ steps.release_tag.outputs.name }}" }'
# propagate_failure: false
# trigger_workflow: true
# wait_workflow: true

# This workflow creates a release using goreleaser
# via the 'make release' command.

name: Create release
on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ linters:
- nakedret
- prealloc
# - scopelint
- exportloopref
- copyloopvar
- staticcheck
# WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
# - structcheck
Expand Down
2 changes: 0 additions & 2 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func TestAdjustGasPriceDecorator_AnteHandle(t *testing.T) {
{"other messages without dispensation", ctx, []sdk.Msg{otherMsg, otherMsg}, highGasPrice, true},
}
for _, tc := range tt {
tc := tc
t.Run(tc.name, func(t *testing.T) {
tx := legacytx.StdTx{
Msgs: tc.msgs,
Expand Down Expand Up @@ -108,7 +107,6 @@ func TestAdjustGasPriceDecorator_AnteHandle_MinFee(t *testing.T) {
{"low fee - transfer", ctx, lowFee, []sdk.Msg{transferMsg}, false},
}
for _, tc := range tt {
tc := tc
t.Run(tc.name, func(t *testing.T) {
tx := legacytx.StdTx{
Msgs: tc.msgs,
Expand Down
6 changes: 2 additions & 4 deletions app/ante/commission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ func TestAnte_CalculateDelegateProjectedVotingPower(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
app := sifapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

Expand Down Expand Up @@ -106,8 +105,7 @@ func TestAnte_CalculateRedelegateProjectedVotingPower(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
app := sifapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

Expand Down
3 changes: 2 additions & 1 deletion cmd/ebrelayer/txs/relayToEthereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ func InitRelayConfig(
sugaredLogger.Infow("final gas price after adjustment.",
"finalGasPrice", gasPrice)

transactOptsAuth.Nonce = big.NewInt(int64(nonce))
// Using SetUint64 to avoid potential integer overflow when converting uint64 to int64
transactOptsAuth.Nonce = new(big.Int).SetUint64(nonce)
transactOptsAuth.Value = big.NewInt(0) // in wei
transactOptsAuth.GasLimit = GasLimit
transactOptsAuth.GasPrice = gasPrice
Expand Down
2 changes: 1 addition & 1 deletion cmd/siftest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func GetVerifyOpen() *cobra.Command {

err = VerifyOpenLong(clientCtx,
viper.GetString("from"),
int64(viper.GetUint64("height")),
int64(viper.GetUint64("height")), // nolint:gosec
collateralAmount,
viper.GetString("collateral-asset"),
viper.GetString("borrow-asset"),
Expand Down
20 changes: 10 additions & 10 deletions cmd/siftest/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func GetVerifyAdd() *cobra.Command {
func VerifyAdd(clientCtx client.Context, from string, height uint64, nativeAmount, externalAmount sdk.Uint, externalAsset string) error {
// Lookup wallet balances before remove
// Lookup wallet balances after remove
bankQueryClient := banktypes.NewQueryClient(clientCtx.WithHeight(int64(height - 1)))
bankQueryClient := banktypes.NewQueryClient(clientCtx.WithHeight(int64(height - 1))) // nolint: gosec
extBefore, err := bankQueryClient.Balance(context.Background(), &banktypes.QueryBalanceRequest{
Address: from,
Denom: externalAsset,
Expand All @@ -80,7 +80,7 @@ func VerifyAdd(clientCtx client.Context, from string, height uint64, nativeAmoun

// Lookup LP units before remove
// Lookup LP units after remove
clpQueryClient := clptypes.NewQueryClient(clientCtx.WithHeight(int64(height - 1)))
clpQueryClient := clptypes.NewQueryClient(clientCtx.WithHeight(int64(height - 1))) // nolint: gosec
lpBefore, err := clpQueryClient.GetLiquidityProvider(context.Background(), &clptypes.LiquidityProviderReq{
Symbol: externalAsset,
LpAddress: from,
Expand Down Expand Up @@ -145,7 +145,7 @@ func VerifyAdd(clientCtx client.Context, from string, height uint64, nativeAmoun
}

// Lookup wallet balances after
bankQueryClient = banktypes.NewQueryClient(clientCtx.WithHeight(int64(height)))
bankQueryClient = banktypes.NewQueryClient(clientCtx.WithHeight(int64(height))) // nolint: gosec
extAfter, err := bankQueryClient.Balance(context.Background(), &banktypes.QueryBalanceRequest{
Address: from,
Denom: externalAsset,
Expand All @@ -162,7 +162,7 @@ func VerifyAdd(clientCtx client.Context, from string, height uint64, nativeAmoun
}

// Lookup LP after
clpQueryClient = clptypes.NewQueryClient(clientCtx.WithHeight(int64(height)))
clpQueryClient = clptypes.NewQueryClient(clientCtx.WithHeight(int64(height))) // nolint: gosec
lpAfter, err := clpQueryClient.GetLiquidityProvider(context.Background(), &clptypes.LiquidityProviderReq{
Symbol: externalAsset,
LpAddress: from,
Expand Down Expand Up @@ -203,7 +203,7 @@ func VerifyAdd(clientCtx client.Context, from string, height uint64, nativeAmoun
fmt.Printf("LP units after %s \n", lpAfter.LiquidityProvider.LiquidityProviderUnits.String())
fmt.Printf("LP units diff %s (expected: %s unexpected: %s)\n", lpUnitsDiff.String(), lpUnits.String(), lpUnitsDiff.Sub(sdk.NewIntFromBigInt(lpUnits.BigInt())))

clpQueryClient = clptypes.NewQueryClient(clientCtx.WithHeight(int64(height)))
clpQueryClient = clptypes.NewQueryClient(clientCtx.WithHeight(int64(height))) // nolint: gosec
poolAfter, err := clpQueryClient.GetPool(context.Background(), &clptypes.PoolReq{Symbol: externalAsset})
if err != nil {
return err
Expand Down Expand Up @@ -284,7 +284,7 @@ func GetVerifyRemove() *cobra.Command {
func VerifyRemove(clientCtx client.Context, from string, height uint64, units sdk.Uint, externalAsset string) error {
// Lookup wallet balances before remove
// Lookup wallet balances after remove
bankQueryClient := banktypes.NewQueryClient(clientCtx.WithHeight(int64(height - 1)))
bankQueryClient := banktypes.NewQueryClient(clientCtx.WithHeight(int64(height - 1))) // nolint: gosec
extBefore, err := bankQueryClient.Balance(context.Background(), &banktypes.QueryBalanceRequest{
Address: from,
Denom: externalAsset,
Expand All @@ -302,7 +302,7 @@ func VerifyRemove(clientCtx client.Context, from string, height uint64, units sd

// Lookup LP units before remove
// Lookup LP units after remove
clpQueryClient := clptypes.NewQueryClient(clientCtx.WithHeight(int64(height - 1)))
clpQueryClient := clptypes.NewQueryClient(clientCtx.WithHeight(int64(height - 1))) // nolint: gosec
lpBefore, err := clpQueryClient.GetLiquidityProvider(context.Background(), &clptypes.LiquidityProviderReq{
Symbol: externalAsset,
LpAddress: from,
Expand All @@ -325,7 +325,7 @@ func VerifyRemove(clientCtx client.Context, from string, height uint64, units sd
units)

// Lookup wallet balances after
bankQueryClient = banktypes.NewQueryClient(clientCtx.WithHeight(int64(height)))
bankQueryClient = banktypes.NewQueryClient(clientCtx.WithHeight(int64(height))) // nolint: gosec
extAfter, err := bankQueryClient.Balance(context.Background(), &banktypes.QueryBalanceRequest{
Address: from,
Denom: externalAsset,
Expand All @@ -342,7 +342,7 @@ func VerifyRemove(clientCtx client.Context, from string, height uint64, units sd
}

// Lookup LP after
clpQueryClient = clptypes.NewQueryClient(clientCtx.WithHeight(int64(height)))
clpQueryClient = clptypes.NewQueryClient(clientCtx.WithHeight(int64(height))) // nolint: gosec
lpAfter, err := clpQueryClient.GetLiquidityProvider(context.Background(), &clptypes.LiquidityProviderReq{
Symbol: externalAsset,
LpAddress: from,
Expand Down Expand Up @@ -415,7 +415,7 @@ func GetVerifyClose() *cobra.Command {

err = VerifyClose(clientCtx,
viper.GetString("from"),
int64(viper.GetUint64("height")),
int64(viper.GetUint64("height")), // nolint:gosec
viper.GetUint64("id"))
if err != nil {
panic(err)
Expand Down
115 changes: 4 additions & 111 deletions test/load/margin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ package main
import (
"log"
"os"
"strconv"

"github.com/Sifchain/sifnode/app"
"github.com/Sifchain/sifnode/x/margin/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -75,6 +72,9 @@ func run(cmd *cobra.Command, args []string) error {

txf := tx.NewFactoryCLI(clientCtx, cmd.Flags())
key, err := txf.Keybase().Key(clientCtx.GetFromName())
if err != nil {
panic(err)
}

accountNumber, seq, err := txf.AccountRetriever().GetAccountNumberSequence(clientCtx, key.GetAddress())
if err != nil {
Expand All @@ -84,7 +84,7 @@ func run(cmd *cobra.Command, args []string) error {
txf.WithAccountNumber(accountNumber)

for a := 0; a < positions; a++ {
txf = txf.WithSequence(seq + uint64(a))
txf = txf.WithSequence(seq + uint64(a)) // nolint:gosec
err := broadcastTrade(clientCtx, txf, key)
if err != nil {
panic(err)
Expand All @@ -94,113 +94,6 @@ func run(cmd *cobra.Command, args []string) error {
return nil
}

func generateAddresses(addresses chan keyring.Info, keys keyring.Keyring, num int) {
for a := 0; a < num; a++ {
info, _, err := keys.NewMnemonic("funded_"+strconv.Itoa(a), keyring.English, hd.CreateHDPath(118, 0, 0).String(), keyring.DefaultBIP39Passphrase, hd.Secp256k1)
if err != nil {
log.Printf("%s", err)
}

addresses <- info
}
}

func newAccountFunder(funded chan keyring.Info, clientCtx client.Context, txf tx.Factory, fromAddress sdk.AccAddress, coins sdk.Coins) func(keyring.Info) {
accountNumber, seq, err := txf.AccountRetriever().GetAccountNumberSequence(clientCtx, fromAddress)
if err != nil {
panic(err)
}

log.Printf("Got account num(%d)/seq(%d) for address %s", accountNumber, seq, fromAddress.String())

return func(key keyring.Info) {
msg := banktypes.NewMsgSend(fromAddress, key.GetAddress(), coins)

txf = txf.WithAccountNumber(accountNumber).WithSequence(seq)

txb, err := tx.BuildUnsignedTx(txf, msg)
if err != nil {
panic(err)
}

err = tx.Sign(txf, "faucet", txb, true)
if err != nil {
panic(err)
}

txBytes, err := clientCtx.TxConfig.TxEncoder()(txb.GetTx())
if err != nil {
panic(err)
}

res, err := clientCtx.WithSimulation(true).WithBroadcastMode("block").BroadcastTx(txBytes)
if err != nil {
log.Printf("ERR %s", err)
} else {
log.Printf("Funded address %s", key.GetAddress().String())
}

log.Print(res)

seq++
funded <- key
}
}

func newFaucet(keys keyring.Keyring, from, mnemonic string) (keyring.Info, error) {
return keys.NewAccount(from, mnemonic, keyring.DefaultBIP39Passphrase, hd.CreateHDPath(118, 0, 0).String(), hd.Secp256k1)
}

func buildMsgs(traders []sdk.AccAddress) []*types.MsgOpen {
collateralAsset := "rowan"
collateralAmount := uint64(100)
borrowAsset := "ceth"

var msgs []*types.MsgOpen
for i := range traders {
log.Printf("%s", traders[i].String())
msgs = append(msgs, &types.MsgOpen{
Signer: traders[i].String(),
CollateralAsset: collateralAsset,
CollateralAmount: sdk.NewUint(collateralAmount),
BorrowAsset: borrowAsset,
Position: types.Position_LONG,
})
}

return msgs
}

func buildTxs(txf tx.Factory, msgs []*types.MsgOpen) []client.TxBuilder {
var txs []client.TxBuilder
for i := range msgs {
txb, err := tx.BuildUnsignedTx(txf, msgs[i])
if err != nil {
panic(err)
}
err = tx.Sign(txf, msgs[i].Signer, txb, true)
if err != nil {
panic(err)
}
txs = append(txs, txb)
}
return txs
}

func sendTxs(clientCtx client.Context, txs []client.TxBuilder) {
for t := range txs {
txBytes, err := clientCtx.TxConfig.TxEncoder()(txs[t].GetTx())
if err != nil {
panic(err)
}

_, err = clientCtx.WithSimulation(true).WithBroadcastMode("block").BroadcastTx(txBytes)
if err != nil {
log.Printf("ERR %s", err)
}
}
}

func broadcastTrade(clientCtx client.Context, txf tx.Factory, key keyring.Info) error {
collateralAsset := "rowan"
collateralAmount := uint64(100)
Expand Down
2 changes: 0 additions & 2 deletions x/clp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ func TestBeginBlocker(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
ctx, app := test.CreateTestAppClpFromGenesis(false, func(app *sifapp.SifchainApp, genesisState sifapp.GenesisState) sifapp.GenesisState {
trGs := &tokenregistrytypes.GenesisState{
Expand Down Expand Up @@ -521,7 +520,6 @@ func TestBeginBlocker_Incremental(t *testing.T) {
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
ctx, app := test.CreateTestAppClpFromGenesis(false, func(app *sifapp.SifchainApp, genesisState sifapp.GenesisState) sifapp.GenesisState {
trGs := &tokenregistrytypes.GenesisState{
Expand Down
6 changes: 3 additions & 3 deletions x/clp/client/cli/query_rewards_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestListRewardsBucket(t *testing.T) {
t.Run("ByOffset", func(t *testing.T) {
step := 2
for i := 0; i < len(objs); i += step {
args := request(nil, uint64(i), uint64(step), false)
args := request(nil, uint64(i), uint64(step), false) // nolint: gosec
// print args
fmt.Println(args)
out, err := clitestutil.ExecTestCLICmd(ctx, cli.GetCmdListRewardsBucket(), args)
Expand All @@ -136,7 +136,7 @@ func TestListRewardsBucket(t *testing.T) {
step := 2
var next []byte
for i := 0; i < len(objs); i += step {
args := request(next, 0, uint64(step), false)
args := request(next, 0, uint64(step), false) // nolint: gosec
// print args
fmt.Println(args)
out, err := clitestutil.ExecTestCLICmd(ctx, cli.GetCmdListRewardsBucket(), args)
Expand All @@ -158,7 +158,7 @@ func TestListRewardsBucket(t *testing.T) {
var resp types.AllRewardsBucketRes
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
require.NoError(t, err)
require.Equal(t, len(objs), int(resp.Pagination.Total))
require.Equal(t, len(objs), int(resp.Pagination.Total)) // nolint:gosec
require.ElementsMatch(t,
nullify.Fill(objs),
nullify.Fill(resp.RewardsBucket),
Expand Down
1 change: 0 additions & 1 deletion x/clp/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func CreateState(ctx sdk.Context, keeper keeper.Keeper, t *testing.T) (int, int)
// Setting Liquidity providers
lpList := test.GenerateRandomLP(10)
for _, lp := range lpList {
lp := lp
keeper.SetLiquidityProvider(ctx, lp)
}
v1 := test.GenerateWhitelistAddress("")
Expand Down
Loading
Loading