Skip to content

Commit

Permalink
rm old methods
Browse files Browse the repository at this point in the history
  • Loading branch information
RensR committed Nov 20, 2024
1 parent a6a70ec commit 75fde6d
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 1,057 deletions.
701 changes: 201 additions & 500 deletions pkg/loop/internal/pb/ccip/factories.pb.go

Large diffs are not rendered by default.

28 changes: 0 additions & 28 deletions pkg/loop/internal/pb/ccip/factories.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ service ExecutionCustomHandlers {
rpc NewOffRampReader(NewOffRampReaderRequest) returns (NewOffRampReaderResponse) {}
rpc NewOnRampReader(NewOnRampReaderRequest) returns (NewOnRampReaderResponse) {}
rpc NewPriceRegistryReader(NewPriceRegistryReaderRequest) returns (NewPriceRegistryReaderResponse) {}
rpc NewTokenDataReader(NewTokenDataRequest) returns (NewTokenDataResponse) {}
rpc NewTokenPoolBatchedReader(NewTokenPoolBatchedReaderRequest) returns (NewTokenPoolBatchedReaderResponse) {}
rpc SourceNativeToken(SourceNativeTokenRequest) returns (SourceNativeTokenResponse) {}
rpc Close(google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
Expand Down Expand Up @@ -147,32 +145,6 @@ message NewPriceRegistryReaderResponse {
int32 price_registry_reader_service_id = 1;
}


// NewTokenDataRequest is a gRPC adapter for the input arguments of
// [github.com/smartcontractkit/chainlink-common/pkg/types/CCIPExecProvider.NewTokenDataReader]
message NewTokenDataRequest {
string address = 1;
}

// NewTokenDataResponse is a gRPC adapter for the output arguments of
// [github.com/smartcontractkit/chainlink-common/pkg/types/CCIPExecProvider.NewTokenDataReader]
// It contains the id of the created token data reader service that was created
message NewTokenDataResponse {
int32 token_data_reader_service_id = 1;
}

message NewTokenPoolBatchedReaderRequest {
string address = 1;
uint64 sourceChainSelector = 2;
}

// NewTokenPoolBatchedReaderResponse is a gRPC adapter for the output arguments of
// [github.com/smartcontractkit/chainlink-common/pkg/types/CCIPExecProvider.NewTokenPoolBatchedReader]
// It contains the id of the created token pool batched reader service that was created
message NewTokenPoolBatchedReaderResponse {
int32 token_pool_batched_reader_service_id = 1;
}

// SourceNativeTokenResponse is a gRPC adapter for the input arguments of
// [github.com/smartcontractkit/chainlink-common/pkg/types/CCIPCommitProvider.SourceNativeToken]
message SourceNativeTokenRequest {
Expand Down
88 changes: 7 additions & 81 deletions pkg/loop/internal/pb/ccip/factories_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -136,40 +136,6 @@ func (e *ExecProviderClient) NewPriceRegistryReader(ctx context.Context, addr cc
return priceReader, nil
}

// NewTokenDataReader implements types.CCIPExecProvider.
func (e *ExecProviderClient) NewTokenDataReader(ctx context.Context, tokenAddress cciptypes.Address) (cciptypes.TokenDataReader, error) {
req := ccippb.NewTokenDataRequest{Address: string(tokenAddress)}
resp, err := e.grpcClient.NewTokenDataReader(ctx, &req)
if err != nil {
return nil, err
}
// TODO BCF-3061: make this work for proxied relayer
tokenDataConn, err := e.BrokerExt.Dial(uint32(resp.TokenDataReaderServiceId))
if err != nil {
return nil, fmt.Errorf("failed to lookup token data reader service at %d: %w", resp.TokenDataReaderServiceId, err)
}
// need to wrap grpc tokenDataReader into the desired interface
tokenDataReader := NewTokenDataReaderGRPCClient(tokenDataConn)

return tokenDataReader, nil
}

// NewTokenPoolBatchedReader implements types.CCIPExecProvider.
func (e *ExecProviderClient) NewTokenPoolBatchedReader(ctx context.Context, offRampAddress cciptypes.Address, srcChainSelector uint64) (cciptypes.TokenPoolBatchedReader, error) {
req := ccippb.NewTokenPoolBatchedReaderRequest{Address: string(offRampAddress), SourceChainSelector: srcChainSelector}
resp, err := e.grpcClient.NewTokenPoolBatchedReader(ctx, &req)
if err != nil {
return nil, err
}
// TODO BCF-3061: make this work for proxied relayer
tokenPoolConn, err := e.BrokerExt.Dial(uint32(resp.TokenPoolBatchedReaderServiceId))
if err != nil {
return nil, fmt.Errorf("failed to lookup token poll batched reader service at %d: %w", resp.TokenPoolBatchedReaderServiceId, err)
}
tokenPool := NewTokenPoolBatchedReaderGRPCClient(tokenPoolConn)
return tokenPool, nil
}

// SourceNativeToken implements types.CCIPExecProvider.
func (e *ExecProviderClient) SourceNativeToken(ctx context.Context, addr cciptypes.Address) (cciptypes.Address, error) {
// unlike the other methods, this one does not create a new resource, so we do not
Expand All @@ -187,7 +153,7 @@ func (e *ExecProviderClient) Close() error {
}

// ExecProviderServer is a server that wraps the custom methods of the [types.CCIPExecProvider]
// this is necessary because those method create new resources that need to be served by the broker
// this is necessary because those methods create new resources that need to be served by the broker
// when we are running in legacy mode.
type ExecProviderServer struct {
ccippb.UnimplementedExecutionCustomHandlersServer
Expand Down Expand Up @@ -255,7 +221,7 @@ func (e *ExecProviderServer) NewOffRampReader(ctx context.Context, req *ccippb.N
if err != nil {
return nil, err
}
// ensure the grpc server is closed when the offRamp is closed. See comment in NewPriceRegistryReader for more details
// Ensure the grpc server is closed when the offRamp is closed. See comment in NewPriceRegistryReader for more details
offRampHandler.AddDep(offRampResource)
return &ccippb.NewOffRampReaderResponse{OfframpReaderServiceId: int32(offRampID)}, nil
}
Expand All @@ -274,7 +240,7 @@ func (e *ExecProviderServer) NewOnRampReader(ctx context.Context, req *ccippb.Ne
if err != nil {
return nil, err
}
// ensure the grpc server is closed when the onRamp is closed. See comment in NewPriceRegistryReader for more details
// Ensure the grpc server is closed when the onRamp is closed. See comment in NewPriceRegistryReader for more details
srv.AddDep(onRampResource)
return &ccippb.NewOnRampReaderResponse{OnrampReaderServiceId: int32(onRampID)}, nil
}
Expand All @@ -294,51 +260,13 @@ func (e *ExecProviderServer) NewPriceRegistryReader(ctx context.Context, req *cc
return nil, err
}
// There is a chicken-and-egg problem here. Our broker is responsible for spawning the grpc server.
// that server needs to be shutdown when the priceRegistry is closed. We don't have a handle to the
// That server needs to be shutdown when the priceRegistry is closed. We don't have a handle to the
// grpc server until we after we have constructed the priceRegistry, so we can't configure the shutdown
// handler up front.
priceRegistryHandler.AddDep(spawnedServer)
return &ccippb.NewPriceRegistryReaderResponse{PriceRegistryReaderServiceId: int32(priceReaderID)}, nil
}

func (e *ExecProviderServer) NewTokenDataReader(ctx context.Context, req *ccippb.NewTokenDataRequest) (*ccippb.NewTokenDataResponse, error) {
reader, err := e.impl.NewTokenDataReader(ctx, cciptypes.Address(req.Address))
if err != nil {
return nil, err
}
// wrap the reader in a grpc server and serve it
tokenDataHandler := NewTokenDataReaderGRPCServer(reader)
// the id is handle to the broker, we will need it on the other side to dial the resource
tokeDataReaderID, spawnedServer, err := e.ServeNew("TokenDataReader", func(s *grpc.Server) {
ccippb.RegisterTokenDataReaderServer(s, tokenDataHandler)
})
if err != nil {
return nil, err
}

tokenDataHandler.AddDep(spawnedServer)
return &ccippb.NewTokenDataResponse{TokenDataReaderServiceId: int32(tokeDataReaderID)}, nil
}

func (e *ExecProviderServer) NewTokenPoolBatchedReader(ctx context.Context, req *ccippb.NewTokenPoolBatchedReaderRequest) (*ccippb.NewTokenPoolBatchedReaderResponse, error) {
reader, err := e.impl.NewTokenPoolBatchedReader(ctx, cciptypes.Address(req.Address), req.SourceChainSelector)
if err != nil {
return nil, err
}
// wrap the reader in a grpc server and serve it
tokenPoolHandler := NewTokenPoolBatchedReaderGRPCServer(reader)
// the id is handle to the broker, we will need it on the other side to dial the resource
tokenPoolID, spawnedServer, err := e.ServeNew("TokenPoolBatchedReader", func(s *grpc.Server) {
ccippb.RegisterTokenPoolBatcherReaderServer(s, tokenPoolHandler)
})
if err != nil {
return nil, err
}
// ensure the grpc server is closed when the tokenPool is closed. See comment in NewPriceRegistryReader for more details
tokenPoolHandler.AddDep(spawnedServer)
return &ccippb.NewTokenPoolBatchedReaderResponse{TokenPoolBatchedReaderServiceId: int32(tokenPoolID)}, nil
}

func (e *ExecProviderServer) SourceNativeToken(ctx context.Context, req *ccippb.SourceNativeTokenRequest) (*ccippb.SourceNativeTokenResponse, error) {
addr, err := e.impl.SourceNativeToken(ctx, cciptypes.Address(req.SourceRouterAddress))
if err != nil {
Expand Down
Loading

0 comments on commit 75fde6d

Please sign in to comment.