Merge PR #2219: Update to Tendermint 0.24 (except NextValSet offsets)
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
)
|
||||
|
||||
var invalidStrs = []string{
|
||||
"",
|
||||
|
||||
+2
-2
@@ -443,7 +443,7 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
benchmarkSizes := [][]int{[]int{1, 1}, []int{5, 5}, []int{5, 20}, []int{1, 1000}, []int{2, 1000}}
|
||||
benchmarkSizes := [][]int{{1, 1}, {5, 5}, {5, 20}, {1, 1000}, {2, 1000}}
|
||||
for i := 0; i < len(benchmarkSizes); i++ {
|
||||
sizeA := benchmarkSizes[i][0]
|
||||
sizeB := benchmarkSizes[i][1]
|
||||
@@ -469,7 +469,7 @@ func BenchmarkCoinsAdditionNoIntersect(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
benchmarkSizes := [][]int{[]int{1, 1}, []int{5, 5}, []int{5, 20}, []int{1, 1000}, []int{2, 1000}, []int{1000, 2}}
|
||||
benchmarkSizes := [][]int{{1, 1}, {5, 5}, {5, 20}, {1, 1000}, {2, 1000}, {1000, 2}}
|
||||
for i := 0; i < len(benchmarkSizes); i++ {
|
||||
sizeA := benchmarkSizes[i][0]
|
||||
sizeB := benchmarkSizes[i][1]
|
||||
|
||||
+6
-6
@@ -45,7 +45,7 @@ func NewContext(ms MultiStore, header abci.Header, isCheckTx bool, logger log.Lo
|
||||
c = c.WithIsCheckTx(isCheckTx)
|
||||
c = c.WithTxBytes(nil)
|
||||
c = c.WithLogger(logger)
|
||||
c = c.WithSigningValidators(nil)
|
||||
c = c.WithVoteInfos(nil)
|
||||
c = c.WithGasMeter(NewInfiniteGasMeter())
|
||||
c = c.WithMinimumFees(Coins{})
|
||||
return c
|
||||
@@ -138,7 +138,7 @@ const (
|
||||
contextKeyIsCheckTx
|
||||
contextKeyTxBytes
|
||||
contextKeyLogger
|
||||
contextKeySigningValidators
|
||||
contextKeyVoteInfos
|
||||
contextKeyGasMeter
|
||||
contextKeyMinimumFees
|
||||
)
|
||||
@@ -164,8 +164,8 @@ func (c Context) TxBytes() []byte { return c.Value(contextKeyTxBytes).([]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) }
|
||||
@@ -199,8 +199,8 @@ func (c Context) WithTxBytes(txBytes []byte) Context { return c.withValue(contex
|
||||
|
||||
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) }
|
||||
|
||||
@@ -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,7 +160,7 @@ func TestContextWithCustom(t *testing.T) {
|
||||
ischeck := true
|
||||
txbytes := []byte("txbytes")
|
||||
logger := NewMockLogger()
|
||||
signvals := []abci.SigningValidator{{}}
|
||||
voteinfos := []abci.VoteInfo{{}}
|
||||
meter := types.NewGasMeter(10000)
|
||||
minFees := types.Coins{types.NewInt64Coin("feeCoin", 1)}
|
||||
|
||||
@@ -168,7 +168,7 @@ func TestContextWithCustom(t *testing.T) {
|
||||
WithBlockHeight(height).
|
||||
WithChainID(chainid).
|
||||
WithTxBytes(txbytes).
|
||||
WithSigningValidators(signvals).
|
||||
WithVoteInfos(voteinfos).
|
||||
WithGasMeter(meter).
|
||||
WithMinimumFees(minFees)
|
||||
|
||||
@@ -178,7 +178,7 @@ func TestContextWithCustom(t *testing.T) {
|
||||
require.Equal(t, ischeck, ctx.IsCheckTx())
|
||||
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())
|
||||
require.Equal(t, minFees, types.Coins{types.NewInt64Coin("feeCoin", 1)})
|
||||
}
|
||||
|
||||
+3
-12
@@ -2,7 +2,6 @@ package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
@@ -231,13 +230,12 @@ func (err *sdkError) TraceSDK(format string, args ...interface{}) Error {
|
||||
}
|
||||
|
||||
// Implements ABCIError.
|
||||
// Overrides err.Error.Error().
|
||||
func (err *sdkError) Error() string {
|
||||
return fmt.Sprintf(`ERROR:
|
||||
Codespace: %d
|
||||
Code: %d
|
||||
Message: %#v
|
||||
`, err.codespace, err.code, parseCmnError(err.cmnError.Error()))
|
||||
`, err.codespace, err.code, err.cmnError.Error())
|
||||
}
|
||||
|
||||
// Implements ABCIError.
|
||||
@@ -258,12 +256,12 @@ func (err *sdkError) Code() CodeType {
|
||||
// Implements ABCIError.
|
||||
func (err *sdkError) ABCILog() string {
|
||||
cdc := codec.New()
|
||||
parsedErrMsg := parseCmnError(err.cmnError.Error())
|
||||
errMsg := err.cmnError.Error()
|
||||
jsonErr := humanReadableError{
|
||||
Codespace: err.codespace,
|
||||
Code: err.code,
|
||||
ABCICode: err.ABCICode(),
|
||||
Message: parsedErrMsg,
|
||||
Message: errMsg,
|
||||
}
|
||||
bz, er := cdc.MarshalJSON(jsonErr)
|
||||
if er != nil {
|
||||
@@ -288,13 +286,6 @@ func (err *sdkError) QueryResult() abci.ResponseQuery {
|
||||
}
|
||||
}
|
||||
|
||||
func parseCmnError(err string) string {
|
||||
if idx := strings.Index(err, "{"); idx != -1 {
|
||||
err = err[idx+1 : len(err)-1]
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// nolint
|
||||
type humanReadableError struct {
|
||||
Codespace CodespaceType `json:"codespace"`
|
||||
|
||||
@@ -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
|
||||
@@ -52,7 +51,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.GetConsPubKey()),
|
||||
Address: v.GetConsPubKey().Address(),
|
||||
Power: v.GetPower().RoundInt64(),
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,4 +51,4 @@ func DefaultChainID() (string, error) {
|
||||
}
|
||||
|
||||
return doc.ChainID, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user