Skip to content

Commit

Permalink
review fixes + format
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Nov 24, 2024
1 parent 3ecc8ee commit fcfffd6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"

dynamicfeestypes "github.com/neutron-org/neutron/v5/x/dynamicfees/types"
state_verifier "github.com/neutron-org/neutron/v5/x/state-verifier"
stateverifier "github.com/neutron-org/neutron/v5/x/state-verifier"
svkeeper "github.com/neutron-org/neutron/v5/x/state-verifier/keeper"
stateverifiertypes "github.com/neutron-org/neutron/v5/x/state-verifier/types"

Expand Down Expand Up @@ -936,7 +936,7 @@ func New(
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
// always be last to make sure that it checks for all invariants and not only part of them
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)),
state_verifier.NewAppModule(appCodec, app.StateVerifierKeeper),
stateverifier.NewAppModule(appCodec, app.StateVerifierKeeper),
)

app.mm.SetOrderPreBlockers(
Expand Down
10 changes: 5 additions & 5 deletions x/state-verifier/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ func (k *Keeper) Verify(ctx sdk.Context, blockHeight int64, values []*icqtypes.S
return errors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
}

for _, result := range values {
proof, err := ibccommitmenttypes.ConvertProofs(result.Proof)
for _, value := range values {
proof, err := ibccommitmenttypes.ConvertProofs(value.Proof)
if err != nil {
return errors.Wrapf(sdkerrors.ErrInvalidType, "failed to convert crypto.ProofOps to MerkleProof: %v", err)
}

path := ibccommitmenttypes.NewMerklePath(result.StoragePrefix, string(result.Key))
path := ibccommitmenttypes.NewMerklePath(value.StoragePrefix, string(value.Key))
// identify what kind proofs (non-existence proof always has *ics23.CommitmentProof_Nonexist as the first item) we got
// and call corresponding method to verify it
switch proof.GetProofs()[0].GetProof().(type) {
Expand All @@ -116,9 +116,9 @@ func (k *Keeper) Verify(ctx sdk.Context, blockHeight int64, values []*icqtypes.S
if err := proof.VerifyNonMembership(ibccommitmenttypes.GetSDKSpecs(), cs.Root, path); err != nil {
return errors.Wrapf(icqtypes.ErrInvalidProof, "failed to verify proof: %v", err)
}
result.Value = nil
value.Value = nil
case *ics23.CommitmentProof_Exist:
if err := proof.VerifyMembership(ibccommitmenttypes.GetSDKSpecs(), cs.Root, path, result.Value); err != nil {
if err := proof.VerifyMembership(ibccommitmenttypes.GetSDKSpecs(), cs.Root, path, value.Value); err != nil {
return errors.Wrapf(icqtypes.ErrInvalidProof, "failed to verify proof: %v", err)
}
default:
Expand Down
4 changes: 2 additions & 2 deletions x/state-verifier/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (suite *KeeperTestSuite) TestVerifyValue() {
Proof: resp.ProofOps,
Value: resp.Value,
StoragePrefix: ibchost.StoreKey,
}}, resp.Height - 2, fmt.Errorf("Please ensure proof was submitted with correct proofHeight and to the correct chain.")
}}, resp.Height - 2, fmt.Errorf("Please ensure proof was submitted with correct proofHeight and to the correct chain.") //nolint:revive
},
},
{
Expand All @@ -132,7 +132,7 @@ func (suite *KeeperTestSuite) TestVerifyValue() {
Proof: resp.ProofOps,
Value: resp.Value,
StoragePrefix: "kekekek",
}}, resp.Height, fmt.Errorf("Please ensure the path and value are both correct.")
}}, resp.Height, fmt.Errorf("Please ensure the path and value are both correct.") //nolint:revive
},
},
}
Expand Down
1 change: 1 addition & 0 deletions x/state-verifier/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
return &cobra.Command{}
}

func (a AppModuleBasic) GetQueryCmd() *cobra.Command {
return &cobra.Command{}
}
Expand Down
4 changes: 0 additions & 4 deletions x/state-verifier/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ var ConsensusStateKey = []byte{prefixConsensusStateKey}
func GetConsensusStateKey(height int64) []byte {
return append(ConsensusStateKey, []byte(strconv.FormatInt(height, 10))...)
}

func ExtractHeightFromConsensusStateKey(key []byte) (int64, error) {
return strconv.ParseInt(string(key[len(ConsensusStateKey):]), 10, 64)
}

0 comments on commit fcfffd6

Please sign in to comment.