-
Notifications
You must be signed in to change notification settings - Fork 32
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
RFQ Relayer: configure chain confirmations #2967
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import ( | |
"github.com/synapsecns/sanguine/ethergo/listener" | ||
"github.com/synapsecns/sanguine/ethergo/submitter" | ||
"github.com/synapsecns/sanguine/services/rfq/contracts/fastbridge" | ||
"github.com/synapsecns/sanguine/services/rfq/relayer/relconfig" | ||
"github.com/synapsecns/sanguine/services/rfq/relayer/reldb" | ||
) | ||
|
||
|
@@ -30,21 +31,28 @@ type Chain struct { | |
} | ||
|
||
// NewChain creates a new chain. | ||
func NewChain(ctx context.Context, chainClient client.EVM, addr common.Address, chainListener listener.ContractListener, ts submitter.TransactionSubmitter) (*Chain, error) { | ||
bridge, err := fastbridge.NewFastBridgeRef(addr, chainClient) | ||
func NewChain(ctx context.Context, cfg relconfig.Config, chainClient client.EVM, chainListener listener.ContractListener, ts submitter.TransactionSubmitter) (*Chain, error) { | ||
chainID, err := chainClient.ChainID(ctx) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not get chain id: %w", err) | ||
} | ||
addr, err := cfg.GetRFQAddress(int(chainID.Int64())) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not get rfq address: %w", err) | ||
Comment on lines
+39
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Ensure |
||
} | ||
bridge, err := fastbridge.NewFastBridgeRef(common.HexToAddress(addr), chainClient) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not create bridge contract: %w", err) | ||
} | ||
chainID, err := chainClient.ChainID(ctx) | ||
confirmations, err := cfg.GetConfirmations(int(chainID.Int64())) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not get chain id: %w", err) | ||
return nil, fmt.Errorf("could not get confirmations: %w", err) | ||
Comment on lines
+47
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check: Validate that |
||
} | ||
return &Chain{ | ||
ChainID: uint32(chainID.Int64()), | ||
Bridge: bridge, | ||
Client: chainClient, | ||
// TODO: configure | ||
Confirmations: 1, | ||
ChainID: uint32(chainID.Int64()), | ||
Bridge: bridge, | ||
Client: chainClient, | ||
Confirmations: confirmations, | ||
listener: chainListener, | ||
submitter: ts, | ||
}, nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,7 @@ func NewRelayerAPI( | |
if err != nil { | ||
return nil, fmt.Errorf("could not get chain listener: %w", err) | ||
} | ||
chains[uint32(chainID)], err = chain.NewChain(ctx, chainClient, common.HexToAddress(chainCfg.RFQAddress), chainListener, submitter) | ||
chains[uint32(chainID)], err = chain.NewChain(ctx, cfg, chainClient, chainListener, submitter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Ensure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Ensure |
||
if err != nil { | ||
return nil, fmt.Errorf("could not create chain: %w", err) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,12 +200,7 @@ func (r *Relayer) chainIDToChain(ctx context.Context, chainID uint32) (*chain.Ch | |
return nil, fmt.Errorf("could not get origin client: %w", err) | ||
} | ||
|
||
//nolint: wrapcheck | ||
rfqAddr, err := r.cfg.GetRFQAddress(id) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not get rfq address: %w", err) | ||
} | ||
chain, err := chain.NewChain(ctx, chainClient, common.HexToAddress(rfqAddr), r.chainListeners[id], r.submitter) | ||
chain, err := chain.NewChain(ctx, r.cfg, chainClient, r.chainListeners[id], r.submitter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Ensure the configuration object includes all necessary parameters previously fetched separately. |
||
if err != nil { | ||
return nil, fmt.Errorf("could not create chain: %w", err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Consider caching the chain ID to avoid repeated calls to
chainClient.ChainID(ctx)
.