Skip to content

Commit 1352319

Browse files
committed
fix all lint errors
1 parent 3c54660 commit 1352319

23 files changed

Lines changed: 130 additions & 136 deletions

File tree

.github/workflows/proto-gen.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ name: Generate Protobuf
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
target_branch:
7-
description: 'Branch to generate proto for'
8-
required: true
9-
default: 'enter target branch here'
10-
type: string
115

126
permissions:
137
contents: write
@@ -19,7 +13,7 @@ jobs:
1913
- name: Checkout repository
2014
uses: actions/checkout@v4
2115
with:
22-
ref: ${{ github.event.inputs.target_branch }}
16+
ref: ${{ github.ref_name }}
2317
fetch-depth: 0
2418

2519
- name: Generate Protobuf files
@@ -44,7 +38,7 @@ jobs:
4438
git config user.email "github-actions[bot]@users.noreply.github.com"
4539
git add .
4640
git commit -m "chore: regenerate protobuf files"
47-
git push origin ${{ github.event.inputs.target_branch }}
41+
git push origin ${{ github.ref_name }}
4842
4943
- name: No changes summary
5044
if: steps.check_changes.outputs.changes == 'false'

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717

1818
### FEATURES
1919

20+
- Added x/liquidstake module for liquid staking functionality
21+
- Added liquidstake precompile for EVM integration
22+
- Added x/epochs module for epoch-based operations
23+
- Added ed25519 signature verification precompile
24+
2025
### STATE BREAKING
2126

2227
- Refactored evmos/os into cosmos/evm

precompiles/authorization/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ func validateMsgTypes(arg interface{}) ([]string, error) {
225225
}
226226

227227
urls := make(map[string]struct{})
228-
for _, url := range typeURLs {
228+
for _, url := range typeURLs {
229229
_, exists := urls[url]
230-
if(exists) {
230+
if exists {
231231
return nil, fmt.Errorf(ErrAuthzDublicationOfMethods, url)
232232
}
233233
urls[url] = struct{}{}

precompiles/ed25519/ed25519.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ import (
1818
//go:embed abi.json
1919
var f embed.FS
2020

21-
const ED25519_VERIFY_BASE_GAS = 2000
22-
const SHA512_BASE_GAS = 60
23-
const SHA512_PER_WORD_GAS = 12
21+
const (
22+
ED25519_VERIFY_BASE_GAS = 2000
23+
SHA512_BASE_GAS = 60
24+
SHA512_PER_WORD_GAS = 12
25+
)
2426

2527
const ED25519VerifyMethod = "ed25519Verify"
2628

precompiles/liquidstake/approve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (p Precompile) grantOrDeleteLiquidStakeAuthz(
135135
coin *sdk.Coin,
136136
msgURL string,
137137
) error {
138-
//if coin is negative or zero delete grant (nil is valid and means unlimited)
138+
// if coin is negative or zero delete grant (nil is valid and means unlimited)
139139
if coin != nil && !coin.Amount.IsPositive() {
140140
return p.AuthzKeeper.DeleteGrant(ctx, grantee.Bytes(), granter.Bytes(), msgURL)
141141
}

precompiles/liquidstake/approve_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package liquidstake_test
22

33
import (
44
"fmt"
5-
liquidstaketypes "github.com/cosmos/evm/x/liquidstake/types"
65
"math/big"
76
"time"
87

8+
liquidstaketypes "github.com/cosmos/evm/x/liquidstake/types"
9+
910
"cosmossdk.io/math"
1011

1112
"github.com/cosmos/evm/precompiles/authorization"
@@ -526,7 +527,7 @@ func (s *LiquidStakePrecompileTestSuite) TestApprove() {
526527
return []interface{}{
527528
grantee.Addr,
528529
abi.MaxUint256,
529-
[]string{liquidstake.LiquidStakeMsg, },
530+
[]string{liquidstake.LiquidStakeMsg},
530531
}
531532
},
532533
func(granter, grantee testkeyring.Key, data []byte, _ []interface{}) {

precompiles/liquidstake/events_test.go

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package liquidstake_test
22

33
import (
4-
sdkmath "cosmossdk.io/math"
54
"math/big"
65
"time"
76

7+
sdkmath "cosmossdk.io/math"
8+
89
"github.com/ethereum/go-ethereum/accounts/abi"
910
"github.com/ethereum/go-ethereum/common"
1011
ethtypes "github.com/ethereum/go-ethereum/core/types"
@@ -339,74 +340,74 @@ func (s *LiquidStakePrecompileTestSuite) TestSetModulePausedEvent() {
339340
}
340341
}
341342

342-
//func (s *LiquidStakePrecompileTestSuite) TestStakeToLPEvent() {
343-
// var (
344-
// stDB *statedb.StateDB
345-
// ctx sdk.Context
346-
// )
347-
// method := s.precompile.Methods[liquidstake.StakeToLPMethod]
348-
// testCases := []struct {
349-
// name string
350-
// malleate func(delegator common.Address) []interface{}
351-
// expErr bool
352-
// errContains string
353-
// postCheck func(delegator common.Address)
354-
// }{
355-
// {
356-
// "success - StakeToLP event emitted correctly",
357-
// func(delegator common.Address) []interface{} {
358-
// validator := s.validatorAdr
359-
// return []interface{}{
360-
// delegator,
361-
// validator,
362-
// big.NewInt(1000000000000000000),
363-
// big.NewInt(1000000000000000000),
364-
// }
365-
// },
366-
// false,
367-
// "",
368-
// func(delegator common.Address) {
369-
// s.SetupTest()
370-
// log := stDB.Logs()[0]
371-
// s.Require().Equal(log.Address, s.precompile.Address())
343+
// func (s *LiquidStakePrecompileTestSuite) TestStakeToLPEvent() {
344+
// var (
345+
// stDB *statedb.StateDB
346+
// ctx sdk.Context
347+
// )
348+
// method := s.precompile.Methods[liquidstake.StakeToLPMethod]
349+
// testCases := []struct {
350+
// name string
351+
// malleate func(delegator common.Address) []interface{}
352+
// expErr bool
353+
// errContains string
354+
// postCheck func(delegator common.Address)
355+
// }{
356+
// {
357+
// "success - StakeToLP event emitted correctly",
358+
// func(delegator common.Address) []interface{} {
359+
// validator := s.validatorAdr
360+
// return []interface{}{
361+
// delegator,
362+
// validator,
363+
// big.NewInt(1000000000000000000),
364+
// big.NewInt(1000000000000000000),
365+
// }
366+
// },
367+
// false,
368+
// "",
369+
// func(delegator common.Address) {
370+
// s.SetupTest()
371+
// log := stDB.Logs()[0]
372+
// s.Require().Equal(log.Address, s.precompile.Address())
372373
//
373-
// // Check event signature matches the one emitted
374-
// event := s.precompile.ABI.Events[liquidstake.EventTypeStakeToLP]
375-
// s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex()))
376-
// s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec
374+
// // Check event signature matches the one emitted
375+
// event := s.precompile.ABI.Events[liquidstake.EventTypeStakeToLP]
376+
// s.Require().Equal(crypto.Keccak256Hash([]byte(event.Sig)), common.HexToHash(log.Topics[0].Hex()))
377+
// s.Require().Equal(log.BlockNumber, uint64(ctx.BlockHeight())) //nolint:gosec
377378
//
378-
// var stakeToLPEvent liquidstake.EventStakeToLP
379-
// err := cmn.UnpackLog(s.precompile.ABI, &stakeToLPEvent, liquidstake.EventTypeStakeToLP, *log)
380-
// s.Require().NoError(err)
381-
// s.Require().Equal(delegator, stakeToLPEvent.DelegatorAddress)
382-
// s.Require().Equal(big.NewInt(1000000000000000000), stakeToLPEvent.StakedAmount)
383-
// s.Require().Equal(big.NewInt(500000000000000000), stakeToLPEvent.LiquidAmount)
384-
// },
385-
// },
386-
// }
379+
// var stakeToLPEvent liquidstake.EventStakeToLP
380+
// err := cmn.UnpackLog(s.precompile.ABI, &stakeToLPEvent, liquidstake.EventTypeStakeToLP, *log)
381+
// s.Require().NoError(err)
382+
// s.Require().Equal(delegator, stakeToLPEvent.DelegatorAddress)
383+
// s.Require().Equal(big.NewInt(1000000000000000000), stakeToLPEvent.StakedAmount)
384+
// s.Require().Equal(big.NewInt(500000000000000000), stakeToLPEvent.LiquidAmount)
385+
// },
386+
// },
387+
// }
387388
//
388-
// for _, tc := range testCases {
389-
// s.Run(tc.name, func() {
390-
// s.SetupTest() // reset
391-
// ctx = s.nw.GetContext()
392-
// stDB = s.nw.GetStateDB()
389+
// for _, tc := range testCases {
390+
// s.Run(tc.name, func() {
391+
// s.SetupTest() // reset
392+
// ctx = s.nw.GetContext()
393+
// stDB = s.nw.GetStateDB()
393394
//
394-
// delegator := s.keyring.GetKey(0)
395+
// delegator := s.keyring.GetKey(0)
395396
//
396-
// contract := vm.NewContract(vm.AccountRef(delegator.Addr), s.precompile, common.U2560, 200000)
397+
// contract := vm.NewContract(vm.AccountRef(delegator.Addr), s.precompile, common.U2560, 200000)
397398
//
398-
// _, err := s.precompile.StakeToLP(ctx, delegator.Addr, contract, stDB, &method, tc.malleate(delegator.Addr))
399+
// _, err := s.precompile.StakeToLP(ctx, delegator.Addr, contract, stDB, &method, tc.malleate(delegator.Addr))
399400
//
400-
// if tc.expErr {
401-
// s.Require().Error(err)
402-
// s.Require().Contains(err.Error(), tc.errContains)
403-
// } else {
404-
// s.Require().NoError(err)
405-
// tc.postCheck(delegator.Addr)
406-
// }
407-
// })
408-
// }
409-
//}
401+
// if tc.expErr {
402+
// s.Require().Error(err)
403+
// s.Require().Contains(err.Error(), tc.errContains)
404+
// } else {
405+
// s.Require().NoError(err)
406+
// tc.postCheck(delegator.Addr)
407+
// }
408+
// })
409+
// }
410+
// }
410411

411412
func (s *LiquidStakePrecompileTestSuite) TestLiquidUnstakeEvent() {
412413
var (

precompiles/liquidstake/liquidstake_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
package liquidstake_test
22

33
import (
4+
"math/big"
5+
"testing"
46
"time"
57

68
sdkmath "cosmossdk.io/math"
79
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
810
"github.com/cosmos/evm/precompiles/authorization"
911
liquidstake "github.com/cosmos/evm/precompiles/liquidstake"
10-
"github.com/cosmos/evm/x/liquidstake/types"
1112
liquidstaketypes "github.com/cosmos/evm/x/liquidstake/types"
1213

13-
"math/big"
14-
1514
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
1615

1716
sdk "github.com/cosmos/cosmos-sdk/types"
1817

1918
testkeyring "github.com/cosmos/evm/testutil/integration/os/keyring"
2019

21-
"testing"
22-
2320
chainutil "github.com/cosmos/evm/evmd/testutil"
2421
"github.com/cosmos/evm/testutil/integration/os/factory"
2522
"github.com/cosmos/evm/testutil/integration/os/grpc"
@@ -607,7 +604,7 @@ func (s *LiquidStakePrecompileTestSuite) TestAdminMethods() {
607604
"UpdateParams_Basic_Positive",
608605
func() ([]byte, testkeyring.Key) {
609606
params := s.nw.App.LiquidStakeKeeper.GetParams(ctx)
610-
updatableParams := types.UpdatableParams{
607+
updatableParams := liquidstaketypes.UpdatableParams{
611608
UnstakeFeeRate: params.UnstakeFeeRate,
612609
LsmDisabled: true,
613610
MinLiquidStakeAmount: params.MinLiquidStakeAmount,
@@ -676,7 +673,7 @@ func (s *LiquidStakePrecompileTestSuite) TestAdminMethods() {
676673
"UpdateParams_Unauthorized_Caller",
677674
func() ([]byte, testkeyring.Key) {
678675
params := s.nw.App.LiquidStakeKeeper.GetParams(ctx)
679-
updatableParams := types.UpdatableParams{
676+
updatableParams := liquidstaketypes.UpdatableParams{
680677
UnstakeFeeRate: params.UnstakeFeeRate,
681678
LsmDisabled: true,
682679
MinLiquidStakeAmount: params.MinLiquidStakeAmount,
@@ -764,7 +761,7 @@ func (s *LiquidStakePrecompileTestSuite) TestAdminMethods() {
764761
"UpdateParams_Out_Of_Gas",
765762
func() ([]byte, testkeyring.Key) {
766763
params := s.nw.App.LiquidStakeKeeper.GetParams(ctx)
767-
updatableParams := types.UpdatableParams{
764+
updatableParams := liquidstaketypes.UpdatableParams{
768765
UnstakeFeeRate: params.UnstakeFeeRate,
769766
LsmDisabled: true,
770767
MinLiquidStakeAmount: params.MinLiquidStakeAmount,

precompiles/liquidstake/tx.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func (p Precompile) LiquidStake(
5555
args []interface{},
5656
) ([]byte, error) {
5757
bondDenom, err := p.liquidStakeKeeper.BondDenom(ctx)
58-
5958
if err != nil {
6059
return nil, err
6160
}
@@ -162,7 +161,7 @@ func (p Precompile) StakeToLP(
162161
// 2. Delegator is SC and submits tx to stake its own funds -> no auth needed (should be handled at SC level)
163162

164163
if !isCallerOrigin && !isSCDelegator {
165-
return nil, fmt.Errorf("Delegator is not Origin nor caller, Delegation through precompile for StakeToLp is not possible")
164+
return nil, fmt.Errorf("delegator is not origin nor caller, delegation through precompile for StakeToLp is not possible")
166165
}
167166

168167
msgSrv := keeper.NewMsgServerImpl(p.liquidStakeKeeper)
@@ -226,7 +225,7 @@ func (p Precompile) LiquidUnstake(
226225
msgSrv := keeper.NewMsgServerImpl(p.liquidStakeKeeper)
227226

228227
// Execute the transaction using the message server
229-
responce, err := msgSrv.LiquidUnstake(ctx, msg)
228+
response, err := msgSrv.LiquidUnstake(ctx, msg)
230229
if err != nil {
231230
return nil, err
232231
}
@@ -259,7 +258,7 @@ func (p Precompile) LiquidUnstake(
259258
return nil, err
260259
}
261260

262-
return method.Outputs.Pack(responce.CompletionTime.Unix())
261+
return method.Outputs.Pack(response.CompletionTime.Unix())
263262
}
264263

265264
func (p Precompile) UpdateParams(

precompiles/liquidstake/types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package liquidstake
22

33
import (
4-
"cosmossdk.io/math"
54
"fmt"
65
"math/big"
76

7+
"cosmossdk.io/math"
8+
89
cmn "github.com/cosmos/evm/precompiles/common"
910

1011
"github.com/cosmos/evm/x/liquidstake/types"
@@ -17,7 +18,7 @@ import (
1718

1819
// !!WARNING!!, from PixelPlex dev Team:
1920
// Adding new precompiled contract introduces few implicit conflicts with dependency to cosmos/evm module
20-
// Particulary here: adding new binded address that potentially can conflict with already exzisted
21+
// Particularly here: adding new binded address that potentially can conflict with already existed
2122
const LiquidStakingPrecompileAddress = "0x00000000000000000000000000000000000001600"
2223

2324
type WhitelistedValidator = struct {

0 commit comments

Comments
 (0)