Start of changes for TM 0.24

This commit is contained in:
Christopher Goes 2018-09-03 17:01:49 +02:00
parent 7f1b06a724
commit 73292e08b4
10 changed files with 59 additions and 54 deletions

46
Gopkg.lock generated
View File

@ -38,7 +38,7 @@
name = "github.com/btcsuite/btcd"
packages = ["btcec"]
pruneopts = "UT"
revision = "d81d8877b8f327112e94e814937143a71d1692a7"
revision = "79e00513b1011888b1e675157ab89f527f901cae"
[[projects]]
digest = "1:386de157f7d19259a7f9c81f26ce011223ce0f090353c1152ffdf730d7d10ac2"
@ -95,12 +95,12 @@
version = "v0.3.0"
[[projects]]
digest = "1:c4a2528ccbcabf90f9f3c464a5fc9e302d592861bbfd0b7135a7de8a943d0406"
digest = "1:586ea76dbd0374d6fb649a91d70d652b7fe0ccffb8910a77468e7702e7901f3d"
name = "github.com/go-stack/stack"
packages = ["."]
pruneopts = "UT"
revision = "259ab82a6cad3992b4e21ff5cac294ccb06474bc"
version = "v1.7.0"
revision = "2fee6af1a9795aafbe0253a0cfbdf668e1fb8a9a"
version = "v1.8.0"
[[projects]]
digest = "1:35621fe20f140f05a0c4ef662c26c0ab4ee50bca78aa30fe87d33120bd28165e"
@ -164,13 +164,13 @@
version = "v1.2.0"
[[projects]]
branch = "master"
digest = "1:12247a2e99a060cc692f6680e5272c8adf0b8f572e6bce0d7095e624c958a240"
digest = "1:c0d19ab64b32ce9fe5cf4ddceba78d5bc9807f0016db6b1183599da3dcc24d10"
name = "github.com/hashicorp/hcl"
packages = [
".",
"hcl/ast",
"hcl/parser",
"hcl/printer",
"hcl/scanner",
"hcl/strconv",
"hcl/token",
@ -179,7 +179,8 @@
"json/token",
]
pruneopts = "UT"
revision = "ef8a98b0bbce4a65b5aa4c368430a80ddc533168"
revision = "8cb6e5b959231cc1119e43259c4a608f9c51a241"
version = "v1.0.0"
[[projects]]
digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be"
@ -214,12 +215,12 @@
version = "v1.8.0"
[[projects]]
digest = "1:d4d17353dbd05cb52a2a52b7fe1771883b682806f68db442b436294926bbfafb"
digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5"
name = "github.com/mattn/go-isatty"
packages = ["."]
pruneopts = "UT"
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
version = "v0.0.3"
revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
version = "v0.0.4"
[[projects]]
digest = "1:ff5ebae34cfbf047d505ee150de27e60570e8c394b3b8fdbb720ff6ac71985fc"
@ -394,6 +395,13 @@
pruneopts = "UT"
revision = "ae2bd5eed72d46b28834ec3f60db3a3ebedd8dbd"
[[projects]]
digest = "1:605b6546f3f43745695298ec2d342d3e952b6d91cdf9f349bea9315f677d759f"
name = "github.com/tendermint/btcd"
packages = ["btcec"]
pruneopts = "UT"
revision = "e5840949ff4fff0c56f9b6a541e22b63581ea9df"
[[projects]]
branch = "master"
digest = "1:087aaa7920e5d0bf79586feb57ce01c35c830396ab4392798112e8aae8c47722"
@ -423,7 +431,8 @@
version = "v0.9.2"
[[projects]]
digest = "1:4f15e95fe3888cc75dd34f407d6394cbc7fd3ff24920851b92b295f6a8b556e6"
branch = "develop"
digest = "1:010630eb6059fa5dd143b9cddb8c9e7c740a9267aca553455de7839515b2fee0"
name = "github.com/tendermint/tendermint"
packages = [
"abci/client",
@ -441,6 +450,8 @@
"crypto/ed25519",
"crypto/encoding/amino",
"crypto/merkle",
"crypto/multisig",
"crypto/multisig/bitarray",
"crypto/secp256k1",
"crypto/tmhash",
"crypto/xsalsa20symmetric",
@ -460,7 +471,6 @@
"lite",
"lite/client",
"lite/errors",
"lite/files",
"lite/proxy",
"mempool",
"node",
@ -483,11 +493,11 @@
"state/txindex/kv",
"state/txindex/null",
"types",
"types/time",
"version",
]
pruneopts = "UT"
revision = "81df19e68ab1519399fccf0cab81cb75bf9d782e"
version = "v0.23.1-rc0"
revision = "1de32fba17a392b656c73a917843724b92b8989d"
[[projects]]
digest = "1:bf6d9a827ea3cad964c2f863302e4f6823170d0b5ed16f72cf1184a7c615067e"
@ -525,7 +535,7 @@
"salsa20/salsa",
]
pruneopts = "UT"
revision = "614d502a4dac94afa3a6ce146bd1736da82514c6"
revision = "182538f80094b6a8efaade63a8fd8e0d9d5843dd"
[[projects]]
digest = "1:d36f55a999540d29b6ea3c2ea29d71c76b1d9853fdcd3e5c5cb4836f2ba118f1"
@ -545,14 +555,14 @@
[[projects]]
branch = "master"
digest = "1:86171d21d59449dcf7cee0b7d2da83dff989dab9b9b69bfe0a3d59c3c1ca6081"
digest = "1:0cd3b4a6aec2641ff2bf7e35d93427787c60e5d94998460aab8f54921a1bc2db"
name = "golang.org/x/sys"
packages = [
"cpu",
"unix",
]
pruneopts = "UT"
revision = "11551d06cbcc94edc80a0facaccbda56473c19c1"
revision = "fa5fdf94c78965f1aa8423f0cc50b8b8d728b05a"
[[projects]]
digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18"
@ -583,7 +593,7 @@
name = "google.golang.org/genproto"
packages = ["googleapis/rpc/status"]
pruneopts = "UT"
revision = "c66870c02cf823ceb633bcd05be3c7cda29976f4"
revision = "11092d34479b07829b72e10713b159248caf5dad"
[[projects]]
digest = "1:2dab32a43451e320e49608ff4542fdfc653c95dcc35d0065ec9c6c3dd540ed74"

View File

@ -57,7 +57,7 @@
[[override]]
name = "github.com/tendermint/tendermint"
version = "=v0.23.1-rc0"
branch = "develop"
[[constraint]]
name = "github.com/bartekn/go-bip39"

View File

@ -64,9 +64,9 @@ type BaseApp struct {
// checkState is set on initialization and reset on Commit.
// deliverState is set in InitChain and BeginBlock and cleared on Commit.
// See methods setCheckState and setDeliverState.
checkState *state // for CheckTx
deliverState *state // for DeliverTx
signedValidators []abci.SigningValidator // absent validators from begin block
checkState *state // for CheckTx
deliverState *state // for DeliverTx
voteInfos []abci.VoteInfo // absent validators from begin block
// flag for sealing
sealed bool
@ -494,12 +494,12 @@ func validateBasicTxMsgs(msgs []sdk.Msg) sdk.Error {
}
// retrieve the context for the ante handler and store the tx bytes; store
// the signing validators if the tx runs within the deliverTx() state.
// the vote infos if the tx runs within the deliverTx() state.
func (app *BaseApp) getContextForAnte(mode runTxMode, txBytes []byte) (ctx sdk.Context) {
// Get the context
ctx = getState(app, mode).ctx.WithTxBytes(txBytes)
if mode == runTxModeDeliver {
ctx = ctx.WithSigningValidators(app.signedValidators)
ctx = ctx.WithVoteInfos(app.voteInfos)
}
return
}

View File

@ -42,7 +42,7 @@ func NewContext(ms MultiStore, header abci.Header, isCheckTx bool, logger log.Lo
c = c.WithChainID(header.ChainID)
c = c.WithTxBytes(nil)
c = c.WithLogger(logger)
c = c.WithSigningValidators(nil)
c = c.WithVoteInfos(nil)
c = c.WithGasMeter(NewInfiniteGasMeter())
return c
}
@ -133,7 +133,7 @@ const (
contextKeyChainID
contextKeyTxBytes
contextKeyLogger
contextKeySigningValidators
contextKeyVoteInfos
contextKeyGasMeter
)
@ -163,8 +163,8 @@ func (c Context) TxBytes() []byte {
func (c Context) Logger() log.Logger {
return c.Value(contextKeyLogger).(log.Logger)
}
func (c Context) SigningValidators() []abci.SigningValidator {
return c.Value(contextKeySigningValidators).([]abci.SigningValidator)
func (c Context) VoteInfos() []abci.VoteInfo {
return c.Value(contextKeyVoteInfos).([]abci.VoteInfo)
}
func (c Context) GasMeter() GasMeter {
return c.Value(contextKeyGasMeter).(GasMeter)
@ -195,8 +195,8 @@ func (c Context) WithTxBytes(txBytes []byte) Context {
func (c Context) WithLogger(logger log.Logger) Context {
return c.withValue(contextKeyLogger, logger)
}
func (c Context) WithSigningValidators(SigningValidators []abci.SigningValidator) Context {
return c.withValue(contextKeySigningValidators, SigningValidators)
func (c Context) WithVoteInfos(VoteInfos []abci.VoteInfo) Context {
return c.withValue(contextKeyVoteInfos, VoteInfos)
}
func (c Context) WithGasMeter(meter GasMeter) Context {
return c.withValue(contextKeyGasMeter, meter)

View File

@ -151,7 +151,7 @@ func TestContextWithCustom(t *testing.T) {
require.Panics(t, func() { ctx.ChainID() })
require.Panics(t, func() { ctx.TxBytes() })
require.Panics(t, func() { ctx.Logger() })
require.Panics(t, func() { ctx.SigningValidators() })
require.Panics(t, func() { ctx.VoteInfos() })
require.Panics(t, func() { ctx.GasMeter() })
header := abci.Header{}
@ -160,14 +160,14 @@ func TestContextWithCustom(t *testing.T) {
ischeck := true
txbytes := []byte("txbytes")
logger := NewMockLogger()
signvals := []abci.SigningValidator{{}}
voteinfos := []abci.VoteInfo{{}}
meter := types.NewGasMeter(10000)
ctx = types.NewContext(nil, header, ischeck, logger).
WithBlockHeight(height).
WithChainID(chainid).
WithTxBytes(txbytes).
WithSigningValidators(signvals).
WithVoteInfos(voteinfos).
WithGasMeter(meter)
require.Equal(t, header, ctx.BlockHeader())
@ -175,7 +175,7 @@ func TestContextWithCustom(t *testing.T) {
require.Equal(t, chainid, ctx.ChainID())
require.Equal(t, txbytes, ctx.TxBytes())
require.Equal(t, logger, ctx.Logger())
require.Equal(t, signvals, ctx.SigningValidators())
require.Equal(t, voteinfos, ctx.VoteInfos())
require.Equal(t, meter, ctx.GasMeter())
}

View File

@ -3,7 +3,6 @@ package types
import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
tmtypes "github.com/tendermint/tendermint/types"
)
// status of a validator
@ -51,7 +50,6 @@ type Validator interface {
// validator which fulfills abci validator interface for use in Tendermint
func ABCIValidator(v Validator) abci.Validator {
return abci.Validator{
PubKey: tmtypes.TM2PB.PubKey(v.GetPubKey()),
Address: v.GetPubKey().Address(),
Power: v.GetPower().RoundInt64(),
}

View File

@ -77,9 +77,9 @@ func SimulateFromSeed(
opCount := 0
var pastTimes []time.Time
var pastSigningValidators [][]abci.SigningValidator
var pastVoteInfos [][]abci.VoteInfo
request := RandomRequestBeginBlock(r, validators, livenessTransitionMatrix, evidenceFraction, pastTimes, pastSigningValidators, event, header, log)
request := RandomRequestBeginBlock(r, validators, livenessTransitionMatrix, evidenceFraction, pastTimes, pastVoteInfos, event, header, log)
// These are operations which have been queued by previous operations
operationQueue := make(map[int][]Operation)
@ -91,7 +91,7 @@ func SimulateFromSeed(
for i := 0; i < numBlocks; i++ {
// Log the header time for future lookup
pastTimes = append(pastTimes, header.Time)
pastSigningValidators = append(pastSigningValidators, request.LastCommitInfo.Validators)
pastVoteInfos = append(pastVoteInfos, request.LastCommitInfo.Validators)
// Run the BeginBlock handler
app.BeginBlock(request)
@ -126,7 +126,7 @@ func SimulateFromSeed(
}
// Generate a random RequestBeginBlock with the current validator set for the next block
request = RandomRequestBeginBlock(r, validators, livenessTransitionMatrix, evidenceFraction, pastTimes, pastSigningValidators, event, header, log)
request = RandomRequestBeginBlock(r, validators, livenessTransitionMatrix, evidenceFraction, pastTimes, pastVoteInfos, event, header, log)
// Update the validator set
validators = updateValidators(tb, r, validators, res.ValidatorUpdates, event)
@ -244,11 +244,11 @@ func getKeys(validators map[string]mockValidator) []string {
// RandomRequestBeginBlock generates a list of signing validators according to the provided list of validators, signing fraction, and evidence fraction
func RandomRequestBeginBlock(r *rand.Rand, validators map[string]mockValidator, livenessTransitions TransitionMatrix, evidenceFraction float64,
pastTimes []time.Time, pastSigningValidators [][]abci.SigningValidator, event func(string), header abci.Header, log string) abci.RequestBeginBlock {
pastTimes []time.Time, pastVoteInfos [][]abci.VoteInfo, event func(string), header abci.Header, log string) abci.RequestBeginBlock {
if len(validators) == 0 {
return abci.RequestBeginBlock{Header: header}
}
signingValidators := make([]abci.SigningValidator, len(validators))
voteInfos := make([]abci.VoteInfo, len(validators))
i := 0
for _, key := range getKeys(validators) {
mVal := validators[key]
@ -269,7 +269,7 @@ func RandomRequestBeginBlock(r *rand.Rand, validators map[string]mockValidator,
} else {
event("beginblock/signing/missed")
}
signingValidators[i] = abci.SigningValidator{
voteInfos[i] = abci.VoteInfo{
Validator: mVal.val,
SignedLastBlock: signed,
}
@ -282,11 +282,11 @@ func RandomRequestBeginBlock(r *rand.Rand, validators map[string]mockValidator,
for r.Float64() < evidenceFraction {
height := header.Height
time := header.Time
vals := signingValidators
vals := voteInfos
if r.Float64() < pastEvidenceFraction {
height = int64(r.Intn(int(header.Height)))
time = pastTimes[height]
vals = pastSigningValidators[height]
vals = pastVoteInfos[height]
}
validator := vals[r.Intn(len(vals))].Validator
var totalVotingPower int64
@ -306,7 +306,7 @@ func RandomRequestBeginBlock(r *rand.Rand, validators map[string]mockValidator,
return abci.RequestBeginBlock{
Header: header,
LastCommitInfo: abci.LastCommitInfo{
Validators: signingValidators,
Validators: voteInfos,
},
ByzantineValidators: evidence,
}

View File

@ -20,9 +20,8 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, sk Keeper) (tags
// Iterate over all the validators which *should* have signed this block
// Store whether or not they have actually signed it and slash/unbond any
// which have missed too many blocks in a row (downtime slashing)
for _, signingValidator := range req.LastCommitInfo.GetValidators() {
present := signingValidator.SignedLastBlock
sk.handleValidatorSignature(ctx, signingValidator.Validator.Address, signingValidator.Validator.Power, present)
for _, voteInfo := range req.LastCommitInfo.GetVoteInfos() {
sk.handleValidatorSignature(ctx, voteInfo.Validator.Address, voteInfo.Validator.Power, voteInfo.SignedLastBlock)
}
// Iterate through any newly discovered evidence of infraction

View File

@ -32,7 +32,7 @@ func TestBeginBlocker(t *testing.T) {
// mark the validator as having signed
req := abci.RequestBeginBlock{
LastCommitInfo: abci.LastCommitInfo{
Validators: []abci.SigningValidator{{
Validators: []abci.VoteInfo{{
Validator: val,
SignedLastBlock: true,
}},
@ -54,7 +54,7 @@ func TestBeginBlocker(t *testing.T) {
ctx = ctx.WithBlockHeight(height)
req = abci.RequestBeginBlock{
LastCommitInfo: abci.LastCommitInfo{
Validators: []abci.SigningValidator{{
Validators: []abci.VoteInfo{{
Validator: val,
SignedLastBlock: true,
}},
@ -68,7 +68,7 @@ func TestBeginBlocker(t *testing.T) {
ctx = ctx.WithBlockHeight(height)
req = abci.RequestBeginBlock{
LastCommitInfo: abci.LastCommitInfo{
Validators: []abci.SigningValidator{{
Validators: []abci.VoteInfo{{
Validator: val,
SignedLastBlock: false,
}},

View File

@ -312,7 +312,6 @@ func (d Description) EnsureLength() (Description, sdk.Error) {
// ABCIValidator returns an abci.Validator from a staked validator type.
func (v Validator) ABCIValidator() abci.Validator {
return abci.Validator{
PubKey: tmtypes.TM2PB.PubKey(v.PubKey),
Address: v.PubKey.Address(),
Power: v.BondedTokens().RoundInt64(),
}
@ -322,7 +321,6 @@ func (v Validator) ABCIValidator() abci.Validator {
// with with zero power used for validator updates.
func (v Validator) ABCIValidatorZero() abci.Validator {
return abci.Validator{
PubKey: tmtypes.TM2PB.PubKey(v.PubKey),
Address: v.PubKey.Address(),
Power: 0,
}