commit
8a59315d59
18
app/app.go
18
app/app.go
|
@ -51,14 +51,15 @@ func (app *Basecoin) RegisterPlugin(plugin types.Plugin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ABCI::SetOption
|
// ABCI::SetOption
|
||||||
func (app *Basecoin) SetOption(key string, value string) (log string) {
|
func (app *Basecoin) SetOption(key string, value string) string {
|
||||||
PluginName, key := splitKey(key)
|
pluginName, key := splitKey(key)
|
||||||
if PluginName != PluginNameBase {
|
if pluginName != PluginNameBase {
|
||||||
// Set option on plugin
|
// Set option on plugin
|
||||||
plugin := app.plugins.GetByName(PluginName)
|
plugin := app.plugins.GetByName(pluginName)
|
||||||
if plugin == nil {
|
if plugin == nil {
|
||||||
return "Invalid plugin name: " + PluginName
|
return "Invalid plugin name: " + pluginName
|
||||||
}
|
}
|
||||||
|
log.Info("SetOption on plugin", "plugin", pluginName, "key", key, "value", value)
|
||||||
return plugin.SetOption(app.state, key, value)
|
return plugin.SetOption(app.state, key, value)
|
||||||
} else {
|
} else {
|
||||||
// Set option on basecoin
|
// Set option on basecoin
|
||||||
|
@ -74,6 +75,7 @@ func (app *Basecoin) SetOption(key string, value string) (log string) {
|
||||||
return "Error decoding acc message: " + err.Error()
|
return "Error decoding acc message: " + err.Error()
|
||||||
}
|
}
|
||||||
app.state.SetAccount(acc.PubKey.Address(), acc)
|
app.state.SetAccount(acc.PubKey.Address(), acc)
|
||||||
|
log.Info("SetAccount", "addr", acc.PubKey.Address(), "acc", acc)
|
||||||
return "Success"
|
return "Success"
|
||||||
}
|
}
|
||||||
return "Unrecognized option key " + key
|
return "Unrecognized option key " + key
|
||||||
|
@ -194,9 +196,3 @@ func splitKey(key string) (prefix string, suffix string) {
|
||||||
}
|
}
|
||||||
return key, ""
|
return key, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// (not meant to be called)
|
|
||||||
// assert that Basecoin implements `abci.Application` at compile-time
|
|
||||||
func _assertABCIApplication(basecoin *Basecoin) abci.Application {
|
|
||||||
return basecoin
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ func (app *Basecoin) LoadGenesis(path string) error {
|
||||||
for _, kv := range kvz {
|
for _, kv := range kvz {
|
||||||
log := app.SetOption(kv.Key, kv.Value)
|
log := app.SetOption(kv.Key, kv.Value)
|
||||||
// TODO: remove debug output
|
// TODO: remove debug output
|
||||||
fmt.Printf("Set %v=%v. Log: %v", kv.Key, kv.Value, log)
|
fmt.Printf("Set %v=%v. Log: %v\n", kv.Key, kv.Value, log)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/tendermint/go-logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
var log = logger.New("module", "app")
|
|
@ -17,8 +17,8 @@ func main() {
|
||||||
commands.TxCmd,
|
commands.TxCmd,
|
||||||
commands.QueryCmd,
|
commands.QueryCmd,
|
||||||
commands.KeyCmd,
|
commands.KeyCmd,
|
||||||
commands.VerifyCmd, // TODO: move to merkleeyes?
|
commands.VerifyCmd,
|
||||||
commands.BlockCmd, // TODO: move to adam?
|
commands.BlockCmd,
|
||||||
commands.AccountCmd,
|
commands.AccountCmd,
|
||||||
}
|
}
|
||||||
app.Run(os.Args)
|
app.Run(os.Args)
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
|
|
||||||
"github.com/tendermint/basecoin/plugins/ibc"
|
"github.com/tendermint/basecoin/plugins/ibc"
|
||||||
"github.com/tendermint/basecoin/types"
|
|
||||||
|
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/go-common"
|
||||||
"github.com/tendermint/go-merkle"
|
"github.com/tendermint/go-merkle"
|
||||||
|
@ -17,10 +16,9 @@ import (
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register the IBC plugin at start and for transactions
|
// returns a new IBC plugin to be registered with Basecoin
|
||||||
func RegisterIBC() {
|
func NewIBCPlugin() *ibc.IBCPlugin {
|
||||||
RegisterTxSubcommand(IbcCmd)
|
return ibc.New()
|
||||||
RegisterStartPlugin("ibc", func() types.Plugin { return ibc.New() })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
@ -104,9 +102,9 @@ var (
|
||||||
// ibc commands
|
// ibc commands
|
||||||
|
|
||||||
var (
|
var (
|
||||||
IbcCmd = cli.Command{
|
IbcTxCmd = cli.Command{
|
||||||
Name: "ibc",
|
Name: "ibc",
|
||||||
Usage: "Send a transaction to the interblockchain (ibc) plugin",
|
Usage: "an IBC transaction, for InterBlockchain Communication",
|
||||||
Flags: TxFlags,
|
Flags: TxFlags,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
IbcRegisterTxCmd,
|
IbcRegisterTxCmd,
|
||||||
|
|
|
@ -138,11 +138,7 @@ func cmdBlock(c *cli.Context) error {
|
||||||
return errors.New(cmn.Fmt("Height must be an int, got %v: %v", heightString, err))
|
return errors.New(cmn.Fmt("Height must be an int, got %v: %v", heightString, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*block, err := getBlock(c, height)
|
header, commit, err := getHeaderAndCommit(c, height)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}*/
|
|
||||||
nextBlock, err := getBlock(c, height+1)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -152,12 +148,12 @@ func cmdBlock(c *cli.Context) error {
|
||||||
JSON BlockJSON `json:"json"`
|
JSON BlockJSON `json:"json"`
|
||||||
}{
|
}{
|
||||||
BlockHex{
|
BlockHex{
|
||||||
Header: wire.BinaryBytes(nextBlock.Header),
|
Header: wire.BinaryBytes(header),
|
||||||
Commit: wire.BinaryBytes(nextBlock.LastCommit),
|
Commit: wire.BinaryBytes(commit),
|
||||||
},
|
},
|
||||||
BlockJSON{
|
BlockJSON{
|
||||||
Header: nextBlock.Header,
|
Header: header,
|
||||||
Commit: nextBlock.LastCommit,
|
Commit: commit,
|
||||||
},
|
},
|
||||||
})))
|
})))
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,10 @@ func cmdStart(c *cli.Context) error {
|
||||||
// Create Basecoin app
|
// Create Basecoin app
|
||||||
basecoinApp := app.NewBasecoin(eyesCli)
|
basecoinApp := app.NewBasecoin(eyesCli)
|
||||||
|
|
||||||
// register all plugins
|
// register IBC plugn
|
||||||
|
basecoinApp.RegisterPlugin(NewIBCPlugin())
|
||||||
|
|
||||||
|
// register all other plugins
|
||||||
for _, p := range plugins {
|
for _, p := range plugins {
|
||||||
basecoinApp.RegisterPlugin(p.newPlugin())
|
basecoinApp.RegisterPlugin(p.newPlugin())
|
||||||
}
|
}
|
||||||
|
@ -91,7 +94,9 @@ func cmdStart(c *cli.Context) error {
|
||||||
if c.Bool("in-proc") {
|
if c.Bool("in-proc") {
|
||||||
startTendermint(c, basecoinApp)
|
startTendermint(c, basecoinApp)
|
||||||
} else {
|
} else {
|
||||||
startBasecoinABCI(c, basecoinApp)
|
if err := startBasecoinABCI(c, basecoinApp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -36,12 +36,13 @@ var (
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
SendTxCmd,
|
SendTxCmd,
|
||||||
AppTxCmd,
|
AppTxCmd,
|
||||||
|
IbcTxCmd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
SendTxCmd = cli.Command{
|
SendTxCmd = cli.Command{
|
||||||
Name: "send",
|
Name: "send",
|
||||||
Usage: "Create, sign, and broadcast a SendTx transaction",
|
Usage: "a SendTx transaction, for sending tokens around",
|
||||||
ArgsUsage: "",
|
ArgsUsage: "",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return cmdSendTx(c)
|
return cmdSendTx(c)
|
||||||
|
@ -51,7 +52,7 @@ var (
|
||||||
|
|
||||||
AppTxCmd = cli.Command{
|
AppTxCmd = cli.Command{
|
||||||
Name: "app",
|
Name: "app",
|
||||||
Usage: "Create, sign, and broadcast a raw AppTx transaction",
|
Usage: "an AppTx transaction, for sending raw data to plugins",
|
||||||
ArgsUsage: "",
|
ArgsUsage: "",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
return cmdAppTx(c)
|
return cmdAppTx(c)
|
||||||
|
|
|
@ -122,15 +122,19 @@ func getAcc(tmAddr string, address []byte) (*types.Account, error) {
|
||||||
return acc, nil
|
return acc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBlock(c *cli.Context, height int) (*tmtypes.Block, error) {
|
func getHeaderAndCommit(c *cli.Context, height int) (*tmtypes.Header, *tmtypes.Commit, error) {
|
||||||
tmResult := new(ctypes.TMResult)
|
tmResult := new(ctypes.TMResult)
|
||||||
tmAddr := c.String("node")
|
tmAddr := c.String("node")
|
||||||
clientURI := client.NewClientURI(tmAddr)
|
clientURI := client.NewClientURI(tmAddr)
|
||||||
|
|
||||||
_, err := clientURI.Call("block", map[string]interface{}{"height": height}, tmResult)
|
method := "commit"
|
||||||
|
_, err := clientURI.Call(method, map[string]interface{}{"height": height}, tmResult)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(cmn.Fmt("Error on broadcast tx: %v", err))
|
return nil, nil, errors.New(cmn.Fmt("Error on %s: %v", method, err))
|
||||||
}
|
}
|
||||||
res := (*tmResult).(*ctypes.ResultBlock)
|
resCommit := (*tmResult).(*ctypes.ResultCommit)
|
||||||
return res.Block, nil
|
header := resCommit.Header
|
||||||
|
commit := resCommit.Commit
|
||||||
|
|
||||||
|
return header, commit, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,32 @@ function removeQuotes() {
|
||||||
echo "$temp"
|
echo "$temp"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function waitForNode() {
|
||||||
|
addr=$1
|
||||||
|
set +e
|
||||||
|
curl -s $addr/status > /dev/null
|
||||||
|
ERR=$?
|
||||||
|
while [ "$ERR" != 0 ]; do
|
||||||
|
sleep 1
|
||||||
|
curl -s $addr/status > /dev/null
|
||||||
|
ERR=$?
|
||||||
|
done
|
||||||
|
set -e
|
||||||
|
echo "... node $addr is up"
|
||||||
|
}
|
||||||
|
|
||||||
|
function waitForBlock() {
|
||||||
|
addr=$1
|
||||||
|
b1=`curl -s $addr/status | jq .result[1].latest_block_height`
|
||||||
|
b2=$b1
|
||||||
|
while [ "$b2" == "$b1" ]; do
|
||||||
|
echo "Waiting for node $addr to commit a block ..."
|
||||||
|
sleep 1
|
||||||
|
b2=`curl -s $addr/status | jq .result[1].latest_block_height`
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# grab the chain ids
|
# grab the chain ids
|
||||||
CHAIN_ID1=$(cat ./data/chain1/basecoin/genesis.json | jq .[1])
|
CHAIN_ID1=$(cat ./data/chain1/basecoin/genesis.json | jq .[1])
|
||||||
CHAIN_ID1=$(removeQuotes $CHAIN_ID1)
|
CHAIN_ID1=$(removeQuotes $CHAIN_ID1)
|
||||||
|
@ -35,7 +61,9 @@ basecoin start --address tcp://localhost:36658 --dir ./data/chain2/basecoin &> c
|
||||||
echo ""
|
echo ""
|
||||||
echo "... waiting for chains to start"
|
echo "... waiting for chains to start"
|
||||||
echo ""
|
echo ""
|
||||||
sleep 10
|
|
||||||
|
waitForNode localhost:46657
|
||||||
|
waitForNode localhost:36657
|
||||||
|
|
||||||
echo "... registering chain1 on chain2"
|
echo "... registering chain1 on chain2"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -66,10 +94,14 @@ echo "PACKET: $PACKET"
|
||||||
echo "PROOF: $PROOF"
|
echo "PROOF: $PROOF"
|
||||||
|
|
||||||
|
|
||||||
|
# the query returns the height of the next block, which contains the app hash
|
||||||
|
# but which may not be committed yet, so we have to wait for it to query the commit
|
||||||
echo ""
|
echo ""
|
||||||
echo "... waiting for some blocks to be mined"
|
echo "... waiting for a block to be committed"
|
||||||
echo ""
|
echo ""
|
||||||
sleep 5
|
|
||||||
|
waitForBlock localhost:46657
|
||||||
|
waitForBlock localhost:36657
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "... querying for block data"
|
echo "... querying for block data"
|
||||||
|
@ -95,12 +127,12 @@ echo ""
|
||||||
echo "... posting packet from chain1 on chain2"
|
echo "... posting packet from chain1 on chain2"
|
||||||
echo ""
|
echo ""
|
||||||
# post the packet from chain1 to chain2
|
# post the packet from chain1 to chain2
|
||||||
basecoin tx ibc --amount 10 $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height $((HEIGHT + 1)) --packet 0x$PACKET --proof 0x$PROOF
|
basecoin tx ibc --amount 10 $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height $HEIGHT --packet 0x$PACKET --proof 0x$PROOF
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "... checking if the packet is present on chain2"
|
echo "... checking if the packet is present on chain2"
|
||||||
echo ""
|
echo ""
|
||||||
# query for the packet on chain2 !
|
# query for the packet on chain2
|
||||||
basecoin query --node tcp://localhost:36657 ibc,ingress,test_chain_2,test_chain_1,1
|
basecoin query --node tcp://localhost:36657 ibc,ingress,test_chain_2,test_chain_1,1
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
hash: 3869944d14a8df914ffcad02c2ef3548173daba51c5ea697767f8af77c07b348
|
hash: 3869944d14a8df914ffcad02c2ef3548173daba51c5ea697767f8af77c07b348
|
||||||
updated: 2017-02-17T13:24:05.234809983+01:00
|
updated: 2017-02-17T09:41:20.209551862-05:00
|
||||||
imports:
|
imports:
|
||||||
- name: github.com/btcsuite/btcd
|
- name: github.com/btcsuite/btcd
|
||||||
version: afec1bd1245a4a19e6dfe1306974b733e7cbb9b8
|
version: d06c0bb181529331be8f8d9350288c420d9e60e4
|
||||||
subpackages:
|
subpackages:
|
||||||
- btcec
|
- btcec
|
||||||
- name: github.com/btcsuite/fastsha256
|
|
||||||
version: 637e656429416087660c84436a2a035d69d54e2e
|
|
||||||
- name: github.com/BurntSushi/toml
|
- name: github.com/BurntSushi/toml
|
||||||
version: 99064174e013895bbd9b025c31100bd1d9b590ca
|
version: 99064174e013895bbd9b025c31100bd1d9b590ca
|
||||||
- name: github.com/ebuchman/fail-test
|
- name: github.com/ebuchman/fail-test
|
||||||
|
@ -18,7 +16,7 @@ imports:
|
||||||
subpackages:
|
subpackages:
|
||||||
- proto
|
- proto
|
||||||
- name: github.com/golang/snappy
|
- name: github.com/golang/snappy
|
||||||
version: 7db9049039a047d955fe8c19b83c8ff5abd765c7
|
version: 553a641470496b2327abcac10b36396bd98e45c9
|
||||||
- name: github.com/gorilla/websocket
|
- name: github.com/gorilla/websocket
|
||||||
version: 3ab3a8b8831546bd18fd182c20687ca853b2bb13
|
version: 3ab3a8b8831546bd18fd182c20687ca853b2bb13
|
||||||
- name: github.com/jmhodges/levigo
|
- name: github.com/jmhodges/levigo
|
||||||
|
@ -26,7 +24,7 @@ imports:
|
||||||
- name: github.com/mattn/go-colorable
|
- name: github.com/mattn/go-colorable
|
||||||
version: 5411d3eea5978e6cdc258b30de592b60df6aba96
|
version: 5411d3eea5978e6cdc258b30de592b60df6aba96
|
||||||
- name: github.com/mattn/go-isatty
|
- name: github.com/mattn/go-isatty
|
||||||
version: 281032e84ae07510239465db46bf442aa44b953a
|
version: dda3de49cbfcec471bd7a70e6cc01fcc3ff90109
|
||||||
- name: github.com/pkg/errors
|
- name: github.com/pkg/errors
|
||||||
version: 248dadf4e9068a0b3e79f02ed0a610d935de5302
|
version: 248dadf4e9068a0b3e79f02ed0a610d935de5302
|
||||||
- name: github.com/syndtr/goleveldb
|
- name: github.com/syndtr/goleveldb
|
||||||
|
@ -115,7 +113,7 @@ imports:
|
||||||
- types
|
- types
|
||||||
- version
|
- version
|
||||||
- name: github.com/urfave/cli
|
- name: github.com/urfave/cli
|
||||||
version: 347a9884a87374d000eec7e6445a34487c1f4a2b
|
version: 2526b57c56f30b50466c96c4133b1a4ad0f0191f
|
||||||
- name: golang.org/x/crypto
|
- name: golang.org/x/crypto
|
||||||
version: 453249f01cfeb54c3d549ddb75ff152ca243f9d8
|
version: 453249f01cfeb54c3d549ddb75ff152ca243f9d8
|
||||||
subpackages:
|
subpackages:
|
||||||
|
@ -128,7 +126,7 @@ imports:
|
||||||
- ripemd160
|
- ripemd160
|
||||||
- salsa20/salsa
|
- salsa20/salsa
|
||||||
- name: golang.org/x/net
|
- name: golang.org/x/net
|
||||||
version: 61557ac0112b576429a0df080e1c2cef5dfbb642
|
version: b4690f45fa1cafc47b1c280c2e75116efe40cc13
|
||||||
subpackages:
|
subpackages:
|
||||||
- context
|
- context
|
||||||
- http2
|
- http2
|
||||||
|
@ -138,11 +136,11 @@ imports:
|
||||||
- lex/httplex
|
- lex/httplex
|
||||||
- trace
|
- trace
|
||||||
- name: golang.org/x/sys
|
- name: golang.org/x/sys
|
||||||
version: e24f485414aeafb646f6fca458b0bf869c0880a1
|
version: 075e574b89e4c2d22f2286a7e2b919519c6f3547
|
||||||
subpackages:
|
subpackages:
|
||||||
- unix
|
- unix
|
||||||
- name: google.golang.org/grpc
|
- name: google.golang.org/grpc
|
||||||
version: cbcceb2942a489498cf22b2f918536e819d33f0a
|
version: d0c32ee6a441117d49856d6120ca9552af413ee0
|
||||||
subpackages:
|
subpackages:
|
||||||
- codes
|
- codes
|
||||||
- credentials
|
- credentials
|
||||||
|
@ -156,14 +154,15 @@ imports:
|
||||||
- transport
|
- transport
|
||||||
testImports:
|
testImports:
|
||||||
- name: github.com/davecgh/go-spew
|
- name: github.com/davecgh/go-spew
|
||||||
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
|
version: 346938d642f2ec3594ed81d874461961cd0faa76
|
||||||
subpackages:
|
subpackages:
|
||||||
- spew
|
- spew
|
||||||
- name: github.com/pmezard/go-difflib
|
- name: github.com/pmezard/go-difflib
|
||||||
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
version: 792786c7400a136282c1664665ae0a8db921c6c2
|
||||||
subpackages:
|
subpackages:
|
||||||
- difflib
|
- difflib
|
||||||
- name: github.com/stretchr/testify
|
- name: github.com/stretchr/testify
|
||||||
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
|
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
|
||||||
subpackages:
|
subpackages:
|
||||||
- assert
|
- assert
|
||||||
|
- require
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ibc
|
package ibc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -329,6 +330,7 @@ func (sm *IBCStateMachine) runPacketPostTx(tx IBCPacketPostTx) {
|
||||||
save(sm.store, packetKeyIngress, packet)
|
save(sm.store, packetKeyIngress, packet)
|
||||||
|
|
||||||
// Load Header and make sure it exists
|
// Load Header and make sure it exists
|
||||||
|
// If it exists, we already checked a valid commit for it in UpdateChainTx
|
||||||
var header tm.Header
|
var header tm.Header
|
||||||
exists, err := load(sm.store, headerKey, &header)
|
exists, err := load(sm.store, headerKey, &header)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -341,16 +343,6 @@ func (sm *IBCStateMachine) runPacketPostTx(tx IBCPacketPostTx) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// Read Proof
|
|
||||||
var proof *merkle.IAVLProof
|
|
||||||
err = wire.ReadBinaryBytes(tx.Proof, &proof)
|
|
||||||
if err != nil {
|
|
||||||
sm.res.Code = IBCEncodingError
|
|
||||||
sm.res.Log = cmn.Fmt("Reading Proof: %v", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
proof := tx.Proof
|
proof := tx.Proof
|
||||||
if proof == nil {
|
if proof == nil {
|
||||||
sm.res.Code = IBCCodeInvalidProof
|
sm.res.Code = IBCCodeInvalidProof
|
||||||
|
@ -368,7 +360,6 @@ func (sm *IBCStateMachine) runPacketPostTx(tx IBCPacketPostTx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ibc *IBCPlugin) InitChain(store types.KVStore, vals []*abci.Validator) {
|
func (ibc *IBCPlugin) InitChain(store types.KVStore, vals []*abci.Validator) {
|
||||||
|
@ -432,6 +423,7 @@ func verifyCommit(chainState BlockchainState, header *tm.Header, commit *tm.Comm
|
||||||
if chainState.ChainID != header.ChainID {
|
if chainState.ChainID != header.ChainID {
|
||||||
return errors.New(cmn.Fmt("Expected header.ChainID %v, got %v", chainState.ChainID, header.ChainID))
|
return errors.New(cmn.Fmt("Expected header.ChainID %v, got %v", chainState.ChainID, header.ChainID))
|
||||||
}
|
}
|
||||||
|
// Ensure things aren't empty
|
||||||
if len(chainState.Validators) == 0 {
|
if len(chainState.Validators) == 0 {
|
||||||
return errors.New(cmn.Fmt("Blockchain has no validators")) // NOTE: Why would this happen?
|
return errors.New(cmn.Fmt("Blockchain has no validators")) // NOTE: Why would this happen?
|
||||||
}
|
}
|
||||||
|
@ -439,18 +431,23 @@ func verifyCommit(chainState BlockchainState, header *tm.Header, commit *tm.Comm
|
||||||
return errors.New(cmn.Fmt("Commit has no signatures"))
|
return errors.New(cmn.Fmt("Commit has no signatures"))
|
||||||
}
|
}
|
||||||
chainID := chainState.ChainID
|
chainID := chainState.ChainID
|
||||||
vote0 := commit.Precommits[0]
|
|
||||||
vals := chainState.Validators
|
vals := chainState.Validators
|
||||||
valSet := tm.NewValidatorSet(vals)
|
valSet := tm.NewValidatorSet(vals)
|
||||||
|
blockID := commit.Precommits[0].BlockID // XXX: incorrect
|
||||||
|
|
||||||
// NOTE: Currently this only works with the exact same validator set.
|
// NOTE: Currently this only works with the exact same validator set.
|
||||||
// Not this, but perhaps "ValidatorSet.VerifyCommitAny" should expose
|
// Not this, but perhaps "ValidatorSet.VerifyCommitAny" should expose
|
||||||
// the functionality to verify commits even after validator changes.
|
// the functionality to verify commits even after validator changes.
|
||||||
err := valSet.VerifyCommit(chainID, vote0.BlockID, vote0.Height, commit)
|
err := valSet.VerifyCommit(chainID, blockID, header.Height, commit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure the committed blockID matches the header
|
||||||
|
if !bytes.Equal(header.Hash(), blockID.Hash) {
|
||||||
|
return errors.New(cmn.Fmt("blockID.Hash (%X) does not match header.Hash (%X)", blockID.Hash, header.Hash()))
|
||||||
|
}
|
||||||
|
|
||||||
// All ok!
|
// All ok!
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ func ExecTx(state *State, pgz *types.Plugins, tx types.Tx, isCheckTx bool, evc e
|
||||||
}
|
}
|
||||||
if !tx.Input.Coins.IsGTE(types.Coins{tx.Fee}) {
|
if !tx.Input.Coins.IsGTE(types.Coins{tx.Fee}) {
|
||||||
log.Info(Fmt("Sender did not send enough to cover the fee %X", tx.Input.Address))
|
log.Info(Fmt("Sender did not send enough to cover the fee %X", tx.Input.Address))
|
||||||
return abci.ErrBaseInsufficientFunds
|
return abci.ErrBaseInsufficientFunds.AppendLog(Fmt("input coins is %d, but fee is %d", tx.Input.Coins, types.Coins{tx.Fee}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate call address
|
// Validate call address
|
||||||
|
@ -238,7 +238,7 @@ func validateInputAdvanced(acc *types.Account, signBytes []byte, in types.TxInpu
|
||||||
}
|
}
|
||||||
// Check amount
|
// Check amount
|
||||||
if !balance.IsGTE(in.Coins) {
|
if !balance.IsGTE(in.Coins) {
|
||||||
return abci.ErrBaseInsufficientFunds
|
return abci.ErrBaseInsufficientFunds.AppendLog(Fmt("balance is %d, tried to send %d", balance, in.Coins))
|
||||||
}
|
}
|
||||||
// Check signatures
|
// Check signatures
|
||||||
if !acc.PubKey.VerifyBytes(signBytes, in.Signature) {
|
if !acc.PubKey.VerifyBytes(signBytes, in.Signature) {
|
||||||
|
|
Loading…
Reference in New Issue