Skip to content

Commit

Permalink
Add No Eth client error
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Oct 3, 2024
1 parent 7322767 commit 11d6ba0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 7 additions & 2 deletions rpc/l1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,7 +58,7 @@ func (h *Handler) GetMessageStatus(ctx context.Context, l1TxnHash *common.Hash)
if rpcErr != nil {
return nil, rpcErr

Check warning on line 59 in rpc/l1.go

View check run for this annotation

Codecov / codecov/patch

rpc/l1.go#L59

Added line #L59 was not covered by tests
}
// (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)
Expand All @@ -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

Check warning on line 83 in rpc/l1.go

View check run for this annotation

Codecov / codecov/patch

rpc/l1.go#L83

Added line #L83 was not covered by tests
}

receipt, err := h.ethClient.TransactionReceipt(ctx, *txHash)
if err != nil {
return nil, ErrTxnHashNotFound

Check warning on line 88 in rpc/l1.go

View check run for this annotation

Codecov / codecov/patch

rpc/l1.go#L88

Added line #L88 was not covered by tests
}
logMsgToL2SigHash := common.HexToHash("0xdb80dd488acf86d17c747445b0eabb5d57c541d3bd7b6b87af987858e5066b2b")

var messageHashes []*common.Hash
for _, vLog := range receipt.Logs {
Expand Down

0 comments on commit 11d6ba0

Please sign in to comment.