waku2: log envelope hash and ids for all messages (#2427)
This commit is contained in:
parent
c95c29bba5
commit
38cc695753
|
@ -3,13 +3,14 @@ package protocol
|
||||||
import (
|
import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/jinzhu/copier"
|
"github.com/jinzhu/copier"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/status-im/status-go/eth-node/crypto"
|
"github.com/status-im/status-go/eth-node/crypto"
|
||||||
"github.com/status-im/status-go/eth-node/types"
|
"github.com/status-im/status-go/eth-node/types"
|
||||||
"github.com/status-im/status-go/protocol/encryption"
|
"github.com/status-im/status-go/protocol/encryption"
|
||||||
|
@ -155,6 +156,8 @@ func (m *StatusMessage) HandleApplicationMetadata() error {
|
||||||
m.ApplicationMetadataLayerSigPubKey = recoveredKey
|
m.ApplicationMetadataLayerSigPubKey = recoveredKey
|
||||||
// Calculate ID using the wrapped record
|
// Calculate ID using the wrapped record
|
||||||
m.ID = MessageID(recoveredKey, m.DecryptedPayload)
|
m.ID = MessageID(recoveredKey, m.DecryptedPayload)
|
||||||
|
log.Debug("calculated ID for envelope", "envelopeHash", hexutil.Encode(m.Hash), "messageId", hexutil.Encode(m.ID))
|
||||||
|
|
||||||
m.UnwrappedPayload = message.Payload
|
m.UnwrappedPayload = message.Payload
|
||||||
m.Type = message.Type
|
m.Type = message.Type
|
||||||
return nil
|
return nil
|
||||||
|
@ -197,7 +200,7 @@ func (m *StatusMessage) HandleApplication() error {
|
||||||
return m.unmarshalProtobufData(new(protobuf.SyncInstallation))
|
return m.unmarshalProtobufData(new(protobuf.SyncInstallation))
|
||||||
|
|
||||||
case protobuf.ApplicationMetadataMessage_SYNC_INSTALLATION_CONTACT:
|
case protobuf.ApplicationMetadataMessage_SYNC_INSTALLATION_CONTACT:
|
||||||
log.Printf("Sync installation contact")
|
log.Debug("Sync installation contact")
|
||||||
return m.unmarshalProtobufData(new(protobuf.SyncInstallationContactV2))
|
return m.unmarshalProtobufData(new(protobuf.SyncInstallationContactV2))
|
||||||
|
|
||||||
case protobuf.ApplicationMetadataMessage_SYNC_INSTALLATION_PUBLIC_CHAT:
|
case protobuf.ApplicationMetadataMessage_SYNC_INSTALLATION_PUBLIC_CHAT:
|
||||||
|
@ -268,7 +271,7 @@ func (m *StatusMessage) unmarshalProtobufData(pb proto.Message) error {
|
||||||
err := proto.Unmarshal(m.UnwrappedPayload, ptr)
|
err := proto.Unmarshal(m.UnwrappedPayload, ptr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.ParsedMessage = nil
|
m.ParsedMessage = nil
|
||||||
log.Printf("[message::DecodeMessage] could not decode %T: %#x, err: %v", pb, m.Hash, err.Error())
|
log.Error("[message::DecodeMessage] could not decode %T: %#x, err: %v", pb, m.Hash, err.Error())
|
||||||
} else {
|
} else {
|
||||||
rv = reflect.ValueOf(ptr)
|
rv = reflect.ValueOf(ptr)
|
||||||
elem := rv.Elem()
|
elem := rv.Elem()
|
||||||
|
|
|
@ -39,12 +39,12 @@ func (api *API) CheckRecentHistoryForChainIDs(ctx context.Context, chainIDs []ui
|
||||||
|
|
||||||
// GetTransfersByAddress returns transfers for a single address
|
// GetTransfersByAddress returns transfers for a single address
|
||||||
func (api *API) GetTransfersByAddress(ctx context.Context, address common.Address, toBlock, limit *hexutil.Big, fetchMore bool) ([]transfer.View, error) {
|
func (api *API) GetTransfersByAddress(ctx context.Context, address common.Address, toBlock, limit *hexutil.Big, fetchMore bool) ([]transfer.View, error) {
|
||||||
log.Debug("[WalletAPI:: GetTransfersByAddress] get transfers for an address", "address", address, "block", toBlock, "limit", limit)
|
log.Debug("[WalletAPI:: GetTransfersByAddress] get transfers for an address", "address")
|
||||||
return api.s.transferController.GetTransfersByAddress(ctx, api.s.rpcClient.UpstreamChainID, address, toBlock, limit, fetchMore)
|
return api.s.transferController.GetTransfersByAddress(ctx, api.s.rpcClient.UpstreamChainID, address, toBlock, limit, fetchMore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) GetTransfersByAddressAndChainID(ctx context.Context, chainID uint64, address common.Address, toBlock, limit *hexutil.Big, fetchMore bool) ([]transfer.View, error) {
|
func (api *API) GetTransfersByAddressAndChainID(ctx context.Context, chainID uint64, address common.Address, toBlock, limit *hexutil.Big, fetchMore bool) ([]transfer.View, error) {
|
||||||
log.Debug("[WalletAPI:: GetTransfersByAddressAndChainID] get transfers for an address", "address", address, "block", toBlock, "limit", limit)
|
log.Debug("[WalletAPI:: GetTransfersByAddressAndChainID] get transfers for an address", "address", address)
|
||||||
return api.s.transferController.GetTransfersByAddress(ctx, chainID, address, toBlock, limit, fetchMore)
|
return api.s.transferController.GetTransfersByAddress(ctx, chainID, address, toBlock, limit, fetchMore)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ func mapToList(m map[common.Address]struct{}) []common.Address {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) GetTransfersByAddress(ctx context.Context, chainID uint64, address common.Address, toBlock, limit *hexutil.Big, fetchMore bool) ([]View, error) {
|
func (c *Controller) GetTransfersByAddress(ctx context.Context, chainID uint64, address common.Address, toBlock, limit *hexutil.Big, fetchMore bool) ([]View, error) {
|
||||||
log.Debug("[WalletAPI:: GetTransfersByAddress] get transfers for an address", "address", address, "block", toBlock, "limit", limit)
|
log.Debug("[WalletAPI:: GetTransfersByAddress] get transfers for an address", "address", address)
|
||||||
var toBlockBN *big.Int
|
var toBlockBN *big.Int
|
||||||
if toBlock != nil {
|
if toBlock != nil {
|
||||||
toBlockBN = toBlock.ToInt()
|
toBlockBN = toBlock.ToInt()
|
||||||
|
|
|
@ -149,8 +149,7 @@ func NewReceivedMessage(env *protocol.Envelope) *ReceivedMessage {
|
||||||
// Hash returns the SHA3 hash of the envelope, calculating it if not yet done.
|
// Hash returns the SHA3 hash of the envelope, calculating it if not yet done.
|
||||||
func (msg *ReceivedMessage) Hash() common.Hash {
|
func (msg *ReceivedMessage) Hash() common.Hash {
|
||||||
if (msg.hash == common.Hash{}) {
|
if (msg.hash == common.Hash{}) {
|
||||||
envelopeHash := msg.Envelope.Hash()
|
msg.hash = common.BytesToHash(msg.Envelope.Hash())
|
||||||
msg.hash = crypto.Keccak256Hash(envelopeHash[:])
|
|
||||||
}
|
}
|
||||||
return msg.hash
|
return msg.hash
|
||||||
}
|
}
|
||||||
|
|
|
@ -828,6 +828,7 @@ func (w *Waku) Query(topics []common.TopicType, from uint64, to uint64, opts []s
|
||||||
|
|
||||||
for _, msg := range result.Messages {
|
for _, msg := range result.Messages {
|
||||||
envelope := wakuprotocol.NewEnvelope(msg, string(relay.DefaultWakuTopic))
|
envelope := wakuprotocol.NewEnvelope(msg, string(relay.DefaultWakuTopic))
|
||||||
|
w.logger.Debug("received waku2 store message", zap.Any("envelopeHash", hexutil.Encode(envelope.Hash())))
|
||||||
_, err = w.OnNewEnvelopes(envelope)
|
_, err = w.OnNewEnvelopes(envelope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue