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

QGB Feedback on PR #742 #746

Merged
merged 27 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6dea524
feat: remove unnecessary keyring dependency
rach-id Sep 20, 2022
a044dbf
fix: use app Module Basics instead of separately defining them
rach-id Sep 20, 2022
ccbea1a
fix: remove ADR unnecessary changelogs
rach-id Sep 20, 2022
b71401b
fix: valsets -> valset in ADR
rach-id Sep 20, 2022
9c12e52
fix: proto Queries -> queries
rach-id Sep 20, 2022
953deee
fix: add LastUnbondingHeight proto docs
rach-id Sep 20, 2022
2458e72
fix: remove unnecessary QGB proto comments
rach-id Sep 20, 2022
7fdb18c
fix: remove unnecessary QGB proto comments
rach-id Sep 20, 2022
ba92fef
fix: remove unnecessary TODO
rach-id Sep 20, 2022
7abd03c
fix: update common.go comment
rach-id Sep 20, 2022
ae8d3ac
fix: add Hooks struct docs
rach-id Sep 20, 2022
648e992
fix: remove nolint from abci_test
rach-id Sep 20, 2022
dc3660c
fix: decapitalize first word of hooks panic
rach-id Sep 20, 2022
8b9fb3a
fix: decapitalize docs
rach-id Sep 20, 2022
bd95387
fix: remove exclamation mark from panic in keeper_attestation.go
rach-id Sep 20, 2022
9884669
fix: cosmetics keeper_attestation.go panic
rach-id Sep 20, 2022
a22b147
fix: cosmetics panic
rach-id Sep 20, 2022
5e48415
fix: remove unnecessary docs space
rach-id Sep 20, 2022
0582f48
fix: docs cosmetics
rach-id Sep 20, 2022
714a716
fix: docs cosmetics
rach-id Sep 20, 2022
16179f8
fix: docs cosmetics
rach-id Sep 20, 2022
3ca53ff
fix: docs cosmetics
rach-id Sep 20, 2022
8a59aa8
fix: docs cosmetics
rach-id Sep 20, 2022
bfc84e0
Revert "fix: remove unnecessary QGB proto comments"
rach-id Sep 20, 2022
6c39ed6
Revert "fix: remove unnecessary QGB proto comments"
rach-id Sep 20, 2022
19c8c55
fix: add no linter for common.go input.BankKeeper.SendCoinsFromModule…
rach-id Sep 20, 2022
9250299
Update x/qgb/keeper/hooks.go
rach-id Sep 21, 2022
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: 1 addition & 5 deletions docs/architecture/ADR-002-QGB-ValSet.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# ADR 002: QGB Valsets

## Changelog

- {date}: {changelog}
# ADR 002: QGB ValSet

## Context

Expand Down
4 changes: 0 additions & 4 deletions docs/architecture/ADR-003-QGB-DataCommitment.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# ADR 003: QGB Data Commitments

## Changelog

- {date}: {changelog}

## Context

To accommodate the requirements of the [Quantum Gravity Bridge](https://github.com/celestiaorg/quantum-gravity-bridge/blob/master/ethereum/solidity/src/QuantumGravityBridge.sol), We will need to add support for `DataCommitment`s messages, i.e. commitments generated over a set of blocks to attest their existence.
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ require (
cloud.google.com/go/iam v0.3.0 // indirect
cloud.google.com/go/storage v1.14.0 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
Expand Down Expand Up @@ -112,7 +113,6 @@ require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.15.6 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
Expand Down Expand Up @@ -176,8 +176,8 @@ require (
)

replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.3.0-sdk-v0.46.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.5.0-tm-v0.34.20
)

12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmG
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw=
git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o=
github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I=
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo=
Expand Down Expand Up @@ -256,8 +260,6 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.0 h1:sgyrjqOkycXiN7Tuupuo4QAldKFg7Sipyfeg/IL7cps=
github.com/cosmos/iavl v0.19.0/go.mod h1:l5h9pAB3m5fihB3pXVgwYqdY8aBsMagqz7T0MUjxZeA=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY=
github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=
Expand All @@ -271,7 +273,6 @@ github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U=
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
Expand Down Expand Up @@ -314,7 +315,6 @@ github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:Htrtb
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac h1:opbrjaN/L8gg6Xh5D04Tem+8xVcz6ajZlGCs49mQgyg=
github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM=
github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM=
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
Expand Down Expand Up @@ -659,8 +659,6 @@ github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM=
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
Expand Down Expand Up @@ -967,7 +965,6 @@ github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
Expand Down Expand Up @@ -1253,7 +1250,6 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
12 changes: 6 additions & 6 deletions proto/qgb/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ option go_package = "github.com/celestiaorg/celestia-app/x/qgb/types";

// Query defines the gRPC querier service.
service Query {
// Params Queries the current parameters for the qgb module
// Params queries the current parameters for the qgb module
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/qgb/params";
}

// attestations' requests queries

// AttestationRequestByNonce Queries attestation request by nonce.
// AttestationRequestByNonce queries attestation request by nonce.
// Returns nil if not found.
rpc AttestationRequestByNonce(QueryAttestationRequestByNonceRequest)
returns (QueryAttestationRequestByNonceResponse) {
option (google.api.http).get = "/qgb/attestations/requests/{nonce}";
}
// LatestAttestationNonce Queries latest attestation nonce.
// LatestAttestationNonce queries latest attestation nonce.
rpc LatestAttestationNonce(QueryLatestAttestationNonceRequest)
returns (QueryLatestAttestationNonceResponse) {
option (google.api.http).get = "/qgb/attestations/nonce/latest";
}

// misc

// LastUnbondingHeight
// LastUnbondingHeight returns the last unbonding height
rpc LastUnbondingHeight(QueryLastUnbondingHeightRequest)
returns (QueryLastUnbondingHeightResponse) {
option (google.api.http).get = "/qgb/unbonding";
Expand All @@ -61,9 +61,9 @@ message QueryAttestationRequestByNonceResponse {
[ (cosmos_proto.accepts_interface) = "AttestationRequestI" ];
}

// QueryLatestAttestationNonceRequest Latest attestation nonce request
// QueryLatestAttestationNonceRequest latest attestation nonce request
message QueryLatestAttestationNonceRequest {}
// QueryLatestAttestationNonceResponse Latest attestation nonce response
// QueryLatestAttestationNonceResponse latest attestation nonce response
message QueryLatestAttestationNonceResponse { uint64 nonce = 1; }

// QueryLastValsetRequestBeforeNonceRequest last Valset request before universal
Expand Down
32 changes: 3 additions & 29 deletions testutil/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,34 @@ import (
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/capability"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/cosmos-sdk/x/distribution"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/evidence"
"github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/params"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/cosmos-sdk/x/upgrade"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"

// TODO add payment module

dbm "github.com/tendermint/tm-db"
)

var (
// ModuleBasics is a mock module basic manager for testing
ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
genutil.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distribution.AppModuleBasic{},
params.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
vesting.AppModuleBasic{},
)
ModuleBasics = app.ModuleBasics
// TestingStakeParams is a set of staking params for testing
TestingStakeParams = stakingtypes.Params{
UnbondingTime: 100,
Expand Down Expand Up @@ -137,7 +111,7 @@ var (
sdk.ValAddress(AccPubKeys[4].Address()),
}

// OrchPubKeys AccPubKeys holds the pub keys for the account keys
// OrchPubKeys holds the pub keys for the orchestrator
OrchPubKeys = []ccrypto.PubKey{
OrchPrivKeys[0].PubKey(),
OrchPrivKeys[1].PubKey(),
Expand Down Expand Up @@ -511,7 +485,7 @@ func SetupTestChain(t *testing.T, weights []uint64) (TestInput, sdk.Context) {
staking.EndBlocker(input.Context, input.StakingKeeper)
}

// some inputs can cause the validator creation ot not work, this checks that
// some inputs can cause the validator creation not to work, this checks that
// everything was successful
validators := input.StakingKeeper.GetBondedValidatorsByPower(input.Context)
require.Equal(t, len(weights), len(validators))
Expand Down
1 change: 0 additions & 1 deletion x/qgb/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestValsetCreationUponUnbonding(t *testing.T) {
// begin unbonding
msgServer := stakingkeeper.NewMsgServerImpl(input.StakingKeeper)
undelegateMsg := testutil.NewTestMsgUnDelegateValidator(testutil.ValAddrs[0], testutil.StakingAmount)
// nolint
_, err = msgServer.Undelegate(input.Context, undelegateMsg)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions x/qgb/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// Wrapper struct
// Hooks is a wrapper struct around Keeper.
type Hooks struct {
k Keeper
}
Expand All @@ -15,7 +15,7 @@ func (k Keeper) Hooks() Hooks {
// the chain when called. Keep this check to make such a mistake
// obvious
if k.storeKey == nil {
panic("Hooks initialized before GravityKeeper!")
panic("hooks initialized before GravityKeeper!")
rach-id marked this conversation as resolved.
Show resolved Hide resolved
}
return Hooks{k}
}
Expand Down
12 changes: 6 additions & 6 deletions x/qgb/keeper/keeper_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

// SetAttestationRequest Sets a new attestation request to the store to be signed
// SetAttestationRequest sets a new attestation request to the store to be signed
// by orchestrators afterwards.
func (k Keeper) SetAttestationRequest(ctx sdk.Context, at types.AttestationRequestI) error {
k.StoreAttestation(ctx, at)
Expand All @@ -23,15 +23,15 @@ func (k Keeper) SetAttestationRequest(ctx sdk.Context, at types.AttestationReque
return nil
}

// StoreAttestation Saves the attestation in store.
// StoreAttestation saves the attestation in store.
// Should panic if overwriting existing one.
func (k Keeper) StoreAttestation(ctx sdk.Context, at types.AttestationRequestI) {
nonce := at.GetNonce()
key := []byte(types.GetAttestationKey(nonce))
store := ctx.KVStore(k.storeKey)

if store.Has(key) {
panic("Trying to overwrite existing attestation request!")
panic("trying to overwrite existing attestation request")
}

b, err := k.cdc.MarshalInterface(at)
Expand All @@ -45,7 +45,7 @@ func (k Keeper) StoreAttestation(ctx sdk.Context, at types.AttestationRequestI)
// expected that this value will only increase by one and it panics otherwise.
func (k Keeper) SetLatestAttestationNonce(ctx sdk.Context, nonce uint64) {
if k.CheckLatestAttestationNonce(ctx) && k.GetLatestAttestationNonce(ctx)+1 != nonce {
panic("not incrementing latest attestation nonce correctly!")
panic("not incrementing latest attestation nonce correctly")
}

store := ctx.KVStore(k.storeKey)
Expand All @@ -69,13 +69,13 @@ func (k Keeper) GetLatestAttestationNonce(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
bytes := store.Get([]byte(types.LatestAttestationtNonce))
if bytes == nil {
panic("Nil LatestAttestationNonce")
panic("nil LatestAttestationNonce")
}
return UInt64FromBytes(bytes)
}

// GetAttestationByNonce returns an attestation request by nonce.
// Returns (nil, false, nil) if the attestation is not found .
// Returns (nil, false, nil) if the attestation is not found.
func (k Keeper) GetAttestationByNonce(ctx sdk.Context, nonce uint64) (types.AttestationRequestI, bool, error) {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.GetAttestationKey(nonce)))
Expand Down
2 changes: 1 addition & 1 deletion x/qgb/keeper/keeper_data_commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// TODO add unit tests for all the keepers

// GetCurrentDataCommitment Creates latest data commitment at current height according to
// GetCurrentDataCommitment creates latest data commitment at current height according to
// the data commitment window specified
func (k Keeper) GetCurrentDataCommitment(ctx sdk.Context) (types.DataCommitment, error) {
beginBlock := uint64(ctx.BlockHeight()) - k.GetDataCommitmentWindowParam(ctx)
Expand Down
17 changes: 11 additions & 6 deletions x/qgb/keeper/keeper_valset.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ func (k Keeper) GetLatestValset(ctx sdk.Context) (*types.Valset, error) {
panic(sdkerrors.Wrap(sdkerrors.ErrNotFound, "couldn't find latest valset"))
}

// SetLastUnBondingBlockHeight sets the last unbonding block height. Note this value is not saved and loaded in genesis
// and is reset to zero on chain upgrade.
// SetLastUnBondingBlockHeight sets the last unbonding block height. Note this
// value is not saved to state or loaded at genesis. This value is reset to zero
// on chain upgrade.
func (k Keeper) SetLastUnBondingBlockHeight(ctx sdk.Context, unbondingBlockHeight uint64) {
store := ctx.KVStore(k.storeKey)
store.Set([]byte(types.LastUnBondingBlockHeight), types.UInt64Bytes(unbondingBlockHeight))
}

// GetLastUnBondingBlockHeight returns the last unbonding block height, returns zero if not set, this is not
// saved or loaded in genesis and is reset to zero on chain upgrade.
// GetLastUnBondingBlockHeight returns the last unbonding block height or zero
// if not set. This value is not saved or loaded at genesis. This value is reset
// to zero on chain upgrade.
func (k Keeper) GetLastUnBondingBlockHeight(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)
bytes := store.Get([]byte(types.LastUnBondingBlockHeight))
Expand Down Expand Up @@ -108,9 +110,12 @@ func (k Keeper) GetCurrentValset(ctx sdk.Context) (types.Valset, error) {
// normalizeValidatorPower scales rawPower with respect to totalValidatorPower to take a value between 0 and 2^32
// Uses BigInt operations to avoid overflow errors
// Example: rawPower = max (2^63 - 1), totalValidatorPower = 1 validator: (2^63 - 1)
// result: (2^63 - 1) * 2^32 / (2^63 - 1) = 2^32 = 4294967296 [this is the multiplier value below, our max output]
//
// result: (2^63 - 1) * 2^32 / (2^63 - 1) = 2^32 = 4294967296 [this is the multiplier value below, our max output]
//
// Example: rawPower = max (2^63 - 1), totalValidatorPower = 1000 validators with the same power: 1000*(2^63 - 1)
// result: (2^63 - 1) * 2^32 / (1000(2^63 - 1)) = 2^32 / 1000 = 4294967
//
// result: (2^63 - 1) * 2^32 / (1000(2^63 - 1)) = 2^32 / 1000 = 4294967
func normalizeValidatorPower(rawPower uint64, totalValidatorPower cosmosmath.Int) uint64 {
// Compute rawPower * multiplier / quotient
// Set the upper limit to 2^32, which would happen if there is a single validator with all the power
Expand Down
2 changes: 1 addition & 1 deletion x/qgb/keeper/query_valset.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// TODO add unit tests for all of these requests

// LastValsetBeforeHeight queries the last valset request before height
// LastValsetRequestBeforeNonce queries the last valset request before nonce
func (k Keeper) LastValsetRequestBeforeNonce(
c context.Context,
req *types.QueryLastValsetRequestBeforeNonceRequest,
Expand Down
2 changes: 1 addition & 1 deletion x/qgb/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}

// ParamSetPairs implements the ParamSet interface and returns all the key/value pairs
// ParamSetPairs implements the ParamSet interface and returns all the key/value
// pairs of auth module's parameters.
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
Expand Down
Loading