mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-30 14:41:20 +00:00
fix TxID to use ripemd160 in events and rpc return
This commit is contained in:
parent
69a9dc932a
commit
72b681a1bc
@ -16,7 +16,7 @@ func BroadcastTx(tx types.Tx) (*ctypes.Receipt, error) {
|
|||||||
return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
|
return nil, fmt.Errorf("Error broadcasting transaction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
txHash := types.TxId(mempoolReactor.Mempool.GetState().ChainID, tx)
|
txHash := types.TxID(mempoolReactor.Mempool.GetState().ChainID, tx)
|
||||||
var createsContract uint8
|
var createsContract uint8
|
||||||
var contractAddr []byte
|
var contractAddr []byte
|
||||||
// check if creates new contract
|
// check if creates new contract
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/account"
|
|
||||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
@ -208,6 +207,6 @@ func TestWSCallCall(t *testing.T) {
|
|||||||
waitForEvent(t, con, eid1, true, func() {
|
waitForEvent(t, con, eid1, true, func() {
|
||||||
tx := makeDefaultCallTx(t, wsTyp, contractAddr2, nil, amt, gasLim, fee)
|
tx := makeDefaultCallTx(t, wsTyp, contractAddr2, nil, amt, gasLim, fee)
|
||||||
broadcastTx(t, wsTyp, tx)
|
broadcastTx(t, wsTyp, tx)
|
||||||
*txid = account.HashSignBytes(chainID, tx)
|
*txid = types.TxID(chainID, tx)
|
||||||
}, unmarshalValidateCallCall(user[0].Address, returnVal, txid))
|
}, unmarshalValidateCallCall(user[0].Address, returnVal, txid))
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package rpctest
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/tendermint/tendermint/account"
|
|
||||||
. "github.com/tendermint/tendermint/common"
|
. "github.com/tendermint/tendermint/common"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
"testing"
|
"testing"
|
||||||
@ -59,9 +58,9 @@ func testSignedTx(t *testing.T, typ string) {
|
|||||||
func testOneSignTx(t *testing.T, typ string, addr []byte, amt int64) {
|
func testOneSignTx(t *testing.T, typ string, addr []byte, amt int64) {
|
||||||
tx := makeDefaultSendTx(t, typ, addr, amt)
|
tx := makeDefaultSendTx(t, typ, addr, amt)
|
||||||
tx2 := signTx(t, typ, tx, user[0])
|
tx2 := signTx(t, typ, tx, user[0])
|
||||||
tx2hash := account.HashSignBytes(chainID, tx2)
|
tx2hash := types.TxID(chainID, tx2)
|
||||||
tx.SignInput(chainID, 0, user[0])
|
tx.SignInput(chainID, 0, user[0])
|
||||||
txhash := account.HashSignBytes(chainID, tx)
|
txhash := types.TxID(chainID, tx)
|
||||||
if bytes.Compare(txhash, tx2hash) != 0 {
|
if bytes.Compare(txhash, tx2hash) != 0 {
|
||||||
t.Fatal("Got different signatures for signing via rpc vs tx_utils")
|
t.Fatal("Got different signatures for signing via rpc vs tx_utils")
|
||||||
}
|
}
|
||||||
|
@ -250,8 +250,8 @@ func unmarshalValidateCallCall(origin, returnCode []byte, txid *[]byte) func(str
|
|||||||
if bytes.Compare(ret, returnCode) != 0 {
|
if bytes.Compare(ret, returnCode) != 0 {
|
||||||
return fmt.Errorf("Call did not return correctly. Got %x, expected %x", ret, returnCode)
|
return fmt.Errorf("Call did not return correctly. Got %x, expected %x", ret, returnCode)
|
||||||
}
|
}
|
||||||
if bytes.Compare(response.Data.TxId, *txid) != 0 {
|
if bytes.Compare(response.Data.TxID, *txid) != 0 {
|
||||||
return fmt.Errorf("TxIds do not match up! Got %x, expected %x", response.Data.TxId, *txid)
|
return fmt.Errorf("TxIDs do not match up! Got %x, expected %x", response.Data.TxID, *txid)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall bool, evc events.Firea
|
|||||||
txCache.UpdateAccount(caller) // because we bumped nonce
|
txCache.UpdateAccount(caller) // because we bumped nonce
|
||||||
txCache.UpdateAccount(callee) // so the txCache knows about the callee and the create and/or transfer takes effect
|
txCache.UpdateAccount(callee) // so the txCache knows about the callee and the create and/or transfer takes effect
|
||||||
|
|
||||||
vmach := vm.NewVM(txCache, params, caller.Address, account.HashSignBytes(_s.ChainID, tx))
|
vmach := vm.NewVM(txCache, params, caller.Address, types.TxID(_s.ChainID, tx))
|
||||||
vmach.SetFireable(evc)
|
vmach.SetFireable(evc)
|
||||||
|
|
||||||
// NOTE: Call() transfers the value from caller to callee iff call succeeds.
|
// NOTE: Call() transfers the value from caller to callee iff call succeeds.
|
||||||
|
@ -62,7 +62,7 @@ type CallData struct {
|
|||||||
type EventMsgCall struct {
|
type EventMsgCall struct {
|
||||||
CallData *CallData `json:"call_data"`
|
CallData *CallData `json:"call_data"`
|
||||||
Origin []byte `json:"origin"`
|
Origin []byte `json:"origin"`
|
||||||
TxId []byte `json:"tx_id"`
|
TxID []byte `json:"tx_id"`
|
||||||
Return []byte `json:"return"`
|
Return []byte `json:"return"`
|
||||||
Exception string `json:"exception"`
|
Exception string `json:"exception"`
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,9 @@ func (tx *DupeoutTx) String() string {
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
func TxId(chainID string, tx Tx) []byte {
|
// NOTE: the tx merkle tree uses sha256, so this TxID is really just for
|
||||||
|
// reference when using the rpc and catching events
|
||||||
|
func TxID(chainID string, tx Tx) []byte {
|
||||||
signBytes := account.SignBytes(chainID, tx)
|
signBytes := account.SignBytes(chainID, tx)
|
||||||
return binary.BinaryRipemd160(signBytes)
|
return binary.BinaryRipemd160(signBytes)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user