forked from cerc-io/laconicd-deprecated
update web3 transaction hash from RLP (#250)
* remove ethereum hash of web3 transaction type (always amino hash) * Update changelog
This commit is contained in:
+5
-3
@@ -43,7 +43,8 @@ func HandleMsgEthereumTx(ctx sdk.Context, k Keeper, msg types.MsgEthereumTx) sdk
|
||||
return sdk.ResultFromError(err)
|
||||
}
|
||||
|
||||
txHash := msg.Hash()
|
||||
txHash := tmtypes.Tx(ctx.TxBytes()).Hash()
|
||||
ethHash := common.BytesToHash(txHash)
|
||||
|
||||
st := types.StateTransition{
|
||||
Sender: sender,
|
||||
@@ -55,12 +56,13 @@ func HandleMsgEthereumTx(ctx sdk.Context, k Keeper, msg types.MsgEthereumTx) sdk
|
||||
Payload: msg.Data.Payload,
|
||||
Csdb: k.CommitStateDB.WithContext(ctx),
|
||||
ChainID: intChainID,
|
||||
THash: &txHash,
|
||||
THash: ðHash,
|
||||
Simulate: ctx.IsCheckTx(),
|
||||
}
|
||||
|
||||
// Prepare db for logs
|
||||
// TODO: block hash
|
||||
k.CommitStateDB.Prepare(txHash, txHash, k.TxCount)
|
||||
k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount)
|
||||
k.TxCount++
|
||||
|
||||
// TODO: move to keeper
|
||||
|
||||
@@ -198,18 +198,6 @@ func (msg *MsgEthereumTx) DecodeRLP(s *rlp.Stream) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Hash hashes the RLP encoding of a transaction.
|
||||
func (msg *MsgEthereumTx) Hash() ethcmn.Hash {
|
||||
if hash := msg.hash.Load(); hash != nil {
|
||||
return hash.(ethcmn.Hash)
|
||||
}
|
||||
|
||||
v := rlpHash(msg)
|
||||
msg.hash.Store(v)
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Sign calculates a secp256k1 ECDSA signature and signs the transaction. It
|
||||
// takes a private key and chainID to sign an Ethereum transaction according to
|
||||
// EIP155 standard. It mutates the transaction as it populates the V, R, S
|
||||
|
||||
@@ -89,14 +89,6 @@ func TestMsgEthereumTxRLPDecode(t *testing.T) {
|
||||
require.Equal(t, expectedMsg.Data, msg.Data)
|
||||
}
|
||||
|
||||
func TestMsgEthereumTxHash(t *testing.T) {
|
||||
addr := ethcmn.BytesToAddress([]byte("test_address"))
|
||||
msg := NewMsgEthereumTx(0, &addr, nil, 100000, nil, []byte("test"))
|
||||
|
||||
hash := msg.Hash()
|
||||
require.Equal(t, "E2AA2E68E7586AE9700F1D3D643330866B6AC2B6CA4C804F7C85ECB11D0B0B29", fmt.Sprintf("%X", hash))
|
||||
}
|
||||
|
||||
func TestMsgEthereumTxSig(t *testing.T) {
|
||||
chainID := big.NewInt(3)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user