diff --git a/node/node.go b/node/node.go index 61ed2838e8..8fb2c206e6 100644 --- a/node/node.go +++ b/node/node.go @@ -188,7 +188,7 @@ func New(cfg *Config, version string) (*Node, error) { //nolint:gocyclo,funlen rpcHandler := rpc.New(chain, syncReader, throttledVM, version, log).WithGateway(gatewayClient).WithFeeder(client) if cfg.EthNode == "" { - log.Warnw("Ethereum node address not found; will not serve starknet_getMessageStatus") // Todo + log.Warnw(rpc.ErrL1ClientNotFound.Message) } else { ethClient, err := l1.NewETHClient(cfg.EthNode) if err != nil { diff --git a/rpc/l1.go b/rpc/l1.go index 61f2a316dd..7b3af578bc 100644 --- a/rpc/l1.go +++ b/rpc/l1.go @@ -11,6 +11,8 @@ import ( "golang.org/x/crypto/sha3" ) +var ErrL1ClientNotFound = jsonrpc.Err(jsonrpc.InternalError, fmt.Errorf("L1 client not found, cannot serve starknet_getMessage")) + type LogMessageToL2 struct { FromAddress *common.Address ToAddress *common.Address @@ -56,7 +58,7 @@ func (h *Handler) GetMessageStatus(ctx context.Context, l1TxnHash *common.Hash) if rpcErr != nil { return nil, rpcErr } - // (l1 handler) msg hashes -> l1 handler txn hashes, etc + // (l1 handler) msg hashes -> l1 handler txn hashes results := make([]MsgStatus, len(msgHashes)) for i, msgHash := range msgHashes { hash, err := h.bcReader.L1HandlerTxnHash(msgHash) @@ -77,12 +79,15 @@ func (h *Handler) GetMessageStatus(ctx context.Context, l1TxnHash *common.Hash) } func (h *Handler) messageToL2Logs(ctx context.Context, txHash *common.Hash) ([]*common.Hash, *jsonrpc.Error) { - logMsgToL2SigHash := common.HexToHash("0xdb80dd488acf86d17c747445b0eabb5d57c541d3bd7b6b87af987858e5066b2b") + if h.ethClient == nil { + return nil, ErrL1ClientNotFound + } receipt, err := h.ethClient.TransactionReceipt(ctx, *txHash) if err != nil { return nil, ErrTxnHashNotFound } + logMsgToL2SigHash := common.HexToHash("0xdb80dd488acf86d17c747445b0eabb5d57c541d3bd7b6b87af987858e5066b2b") var messageHashes []*common.Hash for _, vLog := range receipt.Logs {