Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/chainlink: add Context to TxManager.Enqueue #544

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion relayer/pkg/chainlink/ocr2/contract_transmitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (c *contractTransmitter) Transmit(
return err
}

err = c.txm.Enqueue(c.accountAddress, c.senderAddress, starknetrpc.FunctionCall{
err = c.txm.Enqueue(ctx, c.accountAddress, c.senderAddress, starknetrpc.FunctionCall{
ContractAddress: c.contractAddress,
EntryPointSelector: starknetutils.GetSelectorFromNameFelt("transmit"),
Calldata: calldata,
Expand Down
6 changes: 3 additions & 3 deletions relayer/pkg/chainlink/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
)

type TxManager interface {
Enqueue(accountAddress *felt.Felt, publicKey *felt.Felt, txFn starknetrpc.FunctionCall) error
Enqueue(ctx context.Context, accountAddress *felt.Felt, publicKey *felt.Felt, txFn starknetrpc.FunctionCall) error
InflightCount() (int, int)
}

Expand Down Expand Up @@ -483,12 +483,12 @@ func (txm *starktxm) HealthReport() map[string]error {
return map[string]error{txm.Name(): txm.Healthy()}
}

func (txm *starktxm) Enqueue(accountAddress, publicKey *felt.Felt, tx starknetrpc.FunctionCall) error {
func (txm *starktxm) Enqueue(ctx context.Context, accountAddress, publicKey *felt.Felt, tx starknetrpc.FunctionCall) error {
// validate key exists for sender
// use the embedded Loopp Keystore to do this; the spec and design
// encourage passing nil data to the loop.Keystore.Sign as way to test
// existence of a key
if _, err := txm.ks.Loopp().Sign(context.Background(), publicKey.String(), nil); err != nil {
if _, err := txm.ks.Loopp().Sign(ctx, publicKey.String(), nil); err != nil {
return fmt.Errorf("enqueue: failed to sign: %+w", err)
}

Expand Down
4 changes: 3 additions & 1 deletion relayer/pkg/chainlink/txm/txm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/loop"
adapters "github.com/smartcontractkit/chainlink-common/pkg/loop/adapters/starknet"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/txm/mocks"
"github.com/smartcontractkit/chainlink-starknet/relayer/pkg/starknet"
)

func TestIntegration_Txm(t *testing.T) {
ctx := tests.Context(t)
n := 2 // number of txs per key
// url := SetupLocalStarknetNode(t)
url := "http://127.0.0.1:5050"
Expand Down Expand Up @@ -100,7 +102,7 @@ func TestIntegration_Txm(t *testing.T) {
selector := starknetutils.GetSelectorFromNameFelt("totalSupply")

for i := 0; i < n; i++ {
require.NoError(t, txm.Enqueue(accountAddress, publicKey, starknetrpc.FunctionCall{
require.NoError(t, txm.Enqueue(ctx, accountAddress, publicKey, starknetrpc.FunctionCall{
ContractAddress: contractAddress, // send to ETH token contract
EntryPointSelector: selector,
}))
Expand Down
Loading