Browse Source

fix TxID to use ripemd160 in events and rpc return

pull/108/head
Ethan Buchman 10 years ago
parent
commit
72b681a1bc
7 changed files with 11 additions and 11 deletions
  1. +1
    -1
      rpc/core/mempool.go
  2. +1
    -2
      rpc/test/client_ws_test.go
  3. +2
    -3
      rpc/test/tests.go
  4. +2
    -2
      rpc/test/ws_helpers.go
  5. +1
    -1
      state/execution.go
  6. +1
    -1
      types/events.go
  7. +3
    -1
      types/tx.go

+ 1
- 1
rpc/core/mempool.go View File

@ -16,7 +16,7 @@ func BroadcastTx(tx types.Tx) (*ctypes.Receipt, error) {
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 contractAddr []byte
// check if creates new contract


+ 1
- 2
rpc/test/client_ws_test.go View File

@ -4,7 +4,6 @@ import (
"fmt"
"testing"
"github.com/tendermint/tendermint/account"
_ "github.com/tendermint/tendermint/config/tendermint_test"
"github.com/tendermint/tendermint/types"
)
@ -208,6 +207,6 @@ func TestWSCallCall(t *testing.T) {
waitForEvent(t, con, eid1, true, func() {
tx := makeDefaultCallTx(t, wsTyp, contractAddr2, nil, amt, gasLim, fee)
broadcastTx(t, wsTyp, tx)
*txid = account.HashSignBytes(chainID, tx)
*txid = types.TxID(chainID, tx)
}, unmarshalValidateCallCall(user[0].Address, returnVal, txid))
}

+ 2
- 3
rpc/test/tests.go View File

@ -3,7 +3,6 @@ package rpctest
import (
"bytes"
"fmt"
"github.com/tendermint/tendermint/account"
. "github.com/tendermint/tendermint/common"
"github.com/tendermint/tendermint/types"
"testing"
@ -59,9 +58,9 @@ func testSignedTx(t *testing.T, typ string) {
func testOneSignTx(t *testing.T, typ string, addr []byte, amt int64) {
tx := makeDefaultSendTx(t, typ, addr, amt)
tx2 := signTx(t, typ, tx, user[0])
tx2hash := account.HashSignBytes(chainID, tx2)
tx2hash := types.TxID(chainID, tx2)
tx.SignInput(chainID, 0, user[0])
txhash := account.HashSignBytes(chainID, tx)
txhash := types.TxID(chainID, tx)
if bytes.Compare(txhash, tx2hash) != 0 {
t.Fatal("Got different signatures for signing via rpc vs tx_utils")
}


+ 2
- 2
rpc/test/ws_helpers.go View File

@ -250,8 +250,8 @@ func unmarshalValidateCallCall(origin, returnCode []byte, txid *[]byte) func(str
if bytes.Compare(ret, returnCode) != 0 {
return fmt.Errorf("Call did not return correctly. Got %x, expected %x", ret, returnCode)
}
if bytes.Compare(response.Data.TxId, *txid) != 0 {
return fmt.Errorf("TxIds do not match up! Got %x, expected %x", response.Data.TxId, *txid)
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 nil
}


+ 1
- 1
state/execution.go View File

@ -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(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)
// NOTE: Call() transfers the value from caller to callee iff call succeeds.


+ 1
- 1
types/events.go View File

@ -62,7 +62,7 @@ type CallData struct {
type EventMsgCall struct {
CallData *CallData `json:"call_data"`
Origin []byte `json:"origin"`
TxId []byte `json:"tx_id"`
TxID []byte `json:"tx_id"`
Return []byte `json:"return"`
Exception string `json:"exception"`
}


+ 3
- 1
types/tx.go View File

@ -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)
return binary.BinaryRipemd160(signBytes)
}


Loading…
Cancel
Save