-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add height in exported genesis #7089
Changes from 57 commits
7b56ee3
167cc8b
e17275c
ef1e6f0
64e828b
a04a42c
a619220
2c7ef98
1749ca8
2b1cec3
facab0e
a4ac0fc
6a9e6bc
a04b438
bf549ec
86162b3
fb99bb3
bf9d606
405c921
270c323
5df1626
9d16e9e
af9e5dc
9274552
5dfa955
4aa9bcc
bcbb243
7fdab5d
6839081
0b82fec
ca6b7c1
7f0b573
4c858a5
76c7a12
b80e01b
eb65bd1
10bc9e6
314f0a3
255aaa7
f6216f6
1f1b602
789842a
fac4d5e
b532d0d
6ab3cf9
54b0a97
e62a650
c95c075
dbc92b7
e238ebe
b8ba3e2
57485ee
7c6ba4d
ecd6d7a
66a0dc8
f7cd6d2
af26c5b
5c5b3eb
31d2986
57c1f9f
2b28235
aeec99f
c2d41b5
d7f4353
5940b66
95365dc
788fb8b
6bf735c
8712d04
abdfb85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,9 @@ type BaseApp struct { // nolint: maligned | |
// transaction. This is mainly used for DoS and spam prevention. | ||
minGasPrices sdk.DecCoins | ||
|
||
// initialHeight is the initial height at which we start the baseapp | ||
initialHeight int64 | ||
|
||
// flag for sealing options and parameters to a BaseApp | ||
sealed bool | ||
|
||
|
@@ -206,12 +209,6 @@ func (app *BaseApp) MountMemoryStores(keys map[string]*sdk.MemoryStoreKey) { | |
} | ||
} | ||
|
||
// MountStoreWithDB mounts a store to the provided key in the BaseApp | ||
// multistore, using a specified DB. | ||
func (app *BaseApp) MountStoreWithDB(key sdk.StoreKey, typ sdk.StoreType, db dbm.DB) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this dead code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a shortcut for |
||
app.cms.MountStoreWithDB(key, typ, db) | ||
} | ||
|
||
// MountStore mounts a store to the provided key in the BaseApp multistore, | ||
// using the default DB. | ||
func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType) { | ||
|
@@ -422,9 +419,23 @@ func (app *BaseApp) validateHeight(req abci.RequestBeginBlock) error { | |
return fmt.Errorf("invalid height: %d", req.Header.Height) | ||
} | ||
|
||
prevHeight := app.LastBlockHeight() | ||
if req.Header.Height != prevHeight+1 { | ||
return fmt.Errorf("invalid height: %d; expected: %d", req.Header.Height, prevHeight+1) | ||
// expectedHeight holds the expected height to validate. | ||
var expectedHeight int64 | ||
if app.LastBlockHeight() == 0 && app.initialHeight > 1 { | ||
// In this case, we're validating the first block of the chain (no | ||
// previous commit). The height we're expecting is the initial height. | ||
expectedHeight = app.initialHeight | ||
} else { | ||
// This case can means two things: | ||
// - either there was already a previous commit in the store, in which | ||
// case we increment the version from there, | ||
// - or there was no previous commit, and initial version was not set, | ||
// in which case we start at version 1. | ||
expectedHeight = app.LastBlockHeight() + 1 | ||
} | ||
|
||
if req.Header.Height != expectedHeight { | ||
return fmt.Errorf("invalid height: %d; expected: %d", req.Header.Height, expectedHeight) | ||
} | ||
|
||
return nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this not correctly implemented before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah seems so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol wow.....