Skip to content

Commit

Permalink
wire debug event relevancy in gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
tudor-malene committed Oct 1, 2024
1 parent 6aafb89 commit 165e1ad
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions integration/tengateway/tengateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ func testErrorHandling(t *testing.T, startPort int, httpURL, wsURL string, w wal
`{"jsonrpc":"2.0","method":"eth_getLogs","params":[[]],"id":1}`,
`{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"topics":[]}],"id":1}`,
`{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock":"0x387","topics":["0xc6d8c0af6d21f291e7c359603aa97e0ed500f04db6e983b9fce75a91c6b8da6b"]}],"id":1}`,
`{"jsonrpc":"2.0","method":"debug_eventLogRelevancy","params":[{"fromBlock":"0x387","topics":["0xc6d8c0af6d21f291e7c359603aa97e0ed500f04db6e983b9fce75a91c6b8da6b"]}],"id":1}`,
//`{"jsonrpc":"2.0","method":"eth_subscribe","params":["logs"],"id":1}`,
//`{"jsonrpc":"2.0","method":"eth_subscribe","params":["logs",{"topics":[]}],"id":1}`,
`{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}`,
Expand Down
29 changes: 23 additions & 6 deletions tools/walletextension/rpcapi/debug_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package rpcapi
import (
"context"

"github.com/ethereum/go-ethereum/common"
"github.com/ten-protocol/go-ten/go/common"
"github.com/ten-protocol/go-ten/go/common/tracers"

gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ten-protocol/go-ten/lib/gethfork/rpc"
)
Expand All @@ -28,7 +31,7 @@ func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.Block
return nil, rpcNotImplemented
}

func (s *DebugAPI) GetRawTransaction(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) {
func (s *DebugAPI) GetRawTransaction(ctx context.Context, hash gethcommon.Hash) (hexutil.Bytes, error) {
return nil, rpcNotImplemented
}

Expand All @@ -48,8 +51,22 @@ func (api *DebugAPI) SetHead(number hexutil.Uint64) {
// not implemented
}

// EventLogRelevancy - specific to TEN - todo
func (api *DebugAPI) EventLogRelevancy(_ context.Context, _ common.Hash) (interface{}, error) {
// todo
return nil, rpcNotImplemented
// EventLogRelevancy - specific to TEN
func (api *DebugAPI) EventLogRelevancy(ctx context.Context, crit common.FilterCriteria) ([]*tracers.DebugLogs, error) {
l, err := ExecAuthRPC[[]*tracers.DebugLogs](
ctx,
api.we,
&ExecCfg{
cacheCfg: &CacheCfg{
CacheType: NoCache,
},
tryUntilAuthorised: true,
},
"debug_eventLogRelevancy",
crit,
)
if err != nil {
return nil, err
}
return *l, nil
}
8 changes: 5 additions & 3 deletions tools/walletextension/rpcapi/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ const (
var rpcNotImplemented = fmt.Errorf("rpc endpoint not implemented")

type ExecCfg struct {
// these 4 fields specify the account(s) that should make the backend call
account *gethcommon.Address
computeFromCallback func(user *GWUser) *gethcommon.Address
tryAll bool
tryUntilAuthorised bool
adjustArgs func(acct *GWAccount) []any
cacheCfg *CacheCfg
timeout time.Duration

adjustArgs func(acct *GWAccount) []any
cacheCfg *CacheCfg
timeout time.Duration
}

type CacheStrategy uint8
Expand Down

0 comments on commit 165e1ad

Please sign in to comment.