-
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
Upgrade to tm version 23.0. #1927
Conversation
There are the hanging issues, which I have no idea whats causing them. Then theres also these two issues:
Those two are probably caused by the time change. |
Hanging has now been fixed, its just halting now. Found the cause of the halting. In slashing/tick.go we have a |
0f11891
to
56d8eac
Compare
56d8eac
to
2f85fff
Compare
Figuring out why the LCD tests were failing is quite difficult from our logs. We really need to reduce the log output there, I have no idea what the error is after looking at all of those messages. (I don't even know which of the tests is failing) I had to find this out via manually testing each test individually. (It was a rather simple fix, just finding the error was the hardest part) Currently this doesn't delete from the address to pubkey map. I'm not sure what the best way to delete from this map is, since it has to be deleted when a "CompleteUnbonding" transaction goes through. (As we can still receive slashing evidence until that point) For purposes of getting the next gaia release, I think we can punt on figuring this part out. (We may deem that its unnecessary after tendermint/tendermint#2177) |
Codecov Report
@@ Coverage Diff @@
## develop #1927 +/- ##
===========================================
- Coverage 64.86% 64.86% -0.01%
===========================================
Files 114 115 +1
Lines 6837 6862 +25
===========================================
+ Hits 4435 4451 +16
- Misses 2120 2127 +7
- Partials 282 284 +2 |
I don't think we should maintain such a map unless absolutely necessary, I think we should only use the validator address and treat it as an opaque key. |
@@ -412,11 +413,7 @@ func (app *BaseApp) CheckTx(txBytes []byte) (res abci.ResponseCheckTx) { | |||
Log: result.Log, | |||
GasWanted: result.GasWanted, | |||
GasUsed: result.GasUsed, | |||
Fee: cmn.KI64Pair{ |
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.
Why are we getting rid of this? Presumably Tendermint needs to know about the fee?
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.
Fees were removed.
from the changelog:
[abci] Removed Fee from ResponseDeliverTx and ResponseCheckTx
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.
Oh, should we add priority then?
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.
@ValarDragon thoughts on the above?
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.
No reason to add priority right now. We're not ready to support that at the mempool level, and we won't be for awhile. We discussed that priority is something we want to add as a way to test protobuf upgradability on a test net, not right now.
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.
Gotcha.
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.
OK, I think it's not necessary to delay ABCI updates because Tendermint won't use the value yet, but nbd.
crypto/encode_test.go
Outdated
// Make sure we have the expected length. | ||
if size != -1 { | ||
require.Equal(t, size, len(bz), "Amino binary size mismatch") | ||
assert.Equal(t, size, len(bz), "Amino binary size mismatch") |
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.
Why assert instead of require? Wouldn't we want this to fail immediately?
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.
I was changing this to match whats in tendermint/crypto right now. I don't really have a preference here.
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.
I think it's most important to be consistent -- it seems in SDK-land, the defacto call is require
.
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.
Its to use require unless there is any reason not to. There is good reason to not use it here if we had more pubkey types, but I guess we can change it when that happens.
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.
Looks great @ValarDragon. Left a few minor remarks 👍
^--- PENDING wasn't purged on sdk v0.23.0 release. | ||
|
||
BREAKING CHANGES | ||
* Update to tendermint v0.23.0. This involves removing crypto.Pubkey, |
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.
Can we add the PR reference here (preferably with a link por favor)?
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.
I'm not sure why the PR is helpful. The tendermint changelog is what is helpful, I can link that?
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.
But the SDK changed and that's important to note where/how it happened.
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.
I guess this is a downside of our pending system, the commit with all the changes can't be obtained from the file. I'll link the PR then.
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, I'd just would like to see a CHANGELOG
and be able to go to the issue and/or PR that made the relevant changes.
x/slashing/genesis.go
Outdated
"github.com/cosmos/cosmos-sdk/x/stake/types" | ||
) | ||
|
||
// InitGenesis initializes the keeper's address to pubkey map |
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.
Let's add punctuation here.
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.
If we want to enforce this stuff, we should have it as output from a linter. I'll change this, but #postlaunch we should make the linter say this.
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.
I agree 👍 .
x/slashing/keeper.go
Outdated
} | ||
} | ||
|
||
// TODO: Make a method to remove the pubkey from the map when a validator is unbonded. |
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.
I think this is pretty trivial, no? Why not just add the call to Keeper#unbondValidator
?
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.
The actual method on the slashing keeper is trivial. Making this work when a validator is unbonded is non-trivial. We need to have a way for the staking keeper to talk to the slashing keeper. The method here isn't added, since we should hold off until we figure that out.
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.
Given the discussion in tendermint/tendermint#2177, we may just want to not do this at all, so no point figuring it out. (We can live with one hashmap entry per every validator on the next testnet)
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.
I see I see.
x/slashing/keeper.go
Outdated
} | ||
|
||
func (k Keeper) getPubkey(address crypto.Address) (crypto.PubKey, error) { | ||
addr := new([tmhash.Size]byte) |
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.
Is there a reason we allocate a pointer instead of just:
var addr [tmhash.Size]byte
copy(addr[:], address)
// ...
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.
var addr [tmhash.Size]byte
is equivalent to what new does. It just has more indirection. I don't know what you mean by "allocating a pointer", since that is used for var
as well.
EDIT: Nevermind, your right. Var seems like the right way to go :), (forgot that var didn't make a pointer)
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.
new
returns a memory address -- that way you don't have to do *addr
but just addr
. No big deal though.
Lets continue discussion of that in tendermint/tendermint#2177. Bucky was suggesting that its important to maintain referrence to the pubkey, and I think we should only use the pubkey. |
Currently the addr-> pubkey map isn't persisted in state. (Thanks for pointing that out chris), that needs to be finished before this can be merged. |
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.
LGTM @ValarDragon 👍
…le maps, we have to change from what this commit is doing.
This should be good to merge now :) (pending final review) |
for i := 0; i < len(vals); i++ { | ||
val := vals[i] | ||
pubkey, err := tmtypes.PB2TM.PubKey(val.PubKey) | ||
if err != 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.
Should we panic here?
x/slashing/keeper.go
Outdated
} | ||
|
||
// TODO: Make a method to remove the pubkey from the map when a validator is unbonded. | ||
func (k Keeper) addPubkey(ctx sdk.Context, pubkey crypto.PubKey, del bool) { |
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.
Having a function called addPubkey
which takes a delete boolean is a bit confusing, why not just have addPubkey
and deletePubkey
?
At minimum change the function name, maybe to addOrRemovePubkey
func (k Keeper) getPubkey(ctx sdk.Context, address crypto.Address) (crypto.PubKey, error) { | ||
store := ctx.KVStore(k.storeKey) | ||
var pubkey crypto.PubKey | ||
err := k.cdc.UnmarshalBinary(store.Get(getAddrPubkeyRelationKey(address)), &pubkey) |
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.
MustUnmarshalBinary
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.
(unless you wanted the custom error, in which case disregard)
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.
I do think a custom error message is preferrable
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.
LGTM mostly, a few minor nits.
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.
utACK, we should definitely test any Tendermint-23 relevant changes on an internal testnet.
That basically means testing liveness slashing, and unbonding /rebonding due to time changes. (I'm not worried about the crypto.Signature change breaking stuff) Also yeah, was in a hurry when writing that last commit, forgot to test |
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.
Thanks Dev.
Note gaiadebug binary got accidentally checked in
We might also want our own Time
function that returns the .UTC for us automatically and so we don't have to pass in nanoseconds.
Also I wonder when is it better to use a new type for []byte
, eg. type Signature []byte
?
} | ||
|
||
func getAddrPubkeyRelationKey(address []byte) []byte { | ||
return append([]byte{0x03}, address...) |
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.
magic number
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.
@@ -15,15 +16,15 @@ func TestGetSetValidatorSigningInfo(t *testing.T) { | |||
newInfo := ValidatorSigningInfo{ | |||
StartHeight: int64(4), | |||
IndexOffset: int64(3), | |||
JailedUntil: int64(2), | |||
JailedUntil: time.Unix(2, 0), |
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.
.UTC() ?
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.
The utc was in some places due to time defaulting to the 0 value. (and not everywhere else)
It is kind of sub ideal though, but i thought just using utc was preferable to going through a separate initializer for those tests when initializing validators.
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// defaultUnbondingTime reflects three weeks in seconds as the default | ||
// unbonding time. | ||
const defaultUnbondingTime int64 = 60 * 60 * 24 * 3 | ||
const defaultUnbondingTime time.Duration = 60 * 60 * 24 * 3 * time.Second |
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.
note it's currently 3 days not 3 weeks
We also need to update the spec about the addr->pubkey map since it's being persisted. Though looks like we might revert the need for this depending on what happens with tendermint/tendermint#2177 |
This is Ready for review! This upgrade meant we had to maintain a map from addr to pubkey. This also removes crypto.Signature, and changes abci time from int64 to time.Time.
docs/
)PENDING.md
that include links to the relevant issue or PR that most accurately describes the change.For Admin Use: