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

feat(rfq-relayer): regenerate with updated fastbridgev2 and zap terminology [SLT-442] #3394

Merged
merged 5 commits into from
Nov 14, 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
1,097 changes: 877 additions & 220 deletions services/rfq/contracts/fastbridgev2/fastbridgev2.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions services/rfq/e2e/rfq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func (i *IntegrationSuite) TestETHtoETH() {
}

//nolint:gosec
func (i *IntegrationSuite) TestArbitraryCall() {
func (i *IntegrationSuite) TestZap() {
// start the relayer and guard
go func() {
_ = i.relayer.Start(i.GetTestContext())
Expand Down Expand Up @@ -475,8 +475,8 @@ func (i *IntegrationSuite) TestArbitraryCall() {
paramsV2 := fastbridgev2.IFastBridgeV2BridgeParamsV2{
QuoteRelayer: i.relayerWallet.Address(),
QuoteExclusivitySeconds: new(big.Int).SetInt64(30),
CallParams: []byte("Hello, world!"),
CallValue: big.NewInt(1_337_420),
ZapData: []byte("Hello, world!"),
ZapNative: big.NewInt(1_337_420),
}
tx, err = originFastBridge.Bridge0(auth.TransactOpts, params, paramsV2)
i.NoError(err)
Expand Down
4 changes: 2 additions & 2 deletions services/rfq/relayer/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func (c Chain) SubmitRelay(ctx context.Context, request reldb.QuoteRequest) (uin
// Check to see if ETH should be sent to destination
if util.IsGasToken(request.Transaction.DestToken) {
gasAmount = request.Transaction.DestAmount
} else if request.Transaction.CallValue != nil {
gasAmount = request.Transaction.CallValue
} else if request.Transaction.ZapNative != nil {
gasAmount = request.Transaction.ZapNative
} else if request.TransactionV1.SendChainGas {
gasAmount, err = c.Bridge.ChainGasAmount(&bind.CallOpts{Context: ctx})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions services/rfq/relayer/relapi/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ func (c *RelayerServerSuite) getTestQuoteRequest(status reldb.QuoteRequestStatus
Nonce: big.NewInt(0),
ExclusivityEndTime: big.NewInt(0),
OriginFeeAmount: big.NewInt(0),
CallValue: big.NewInt(0),
CallParams: []byte{},
ZapNative: big.NewInt(0),
ZapData: []byte{},
Comment on lines +214 to +215
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance test coverage for new Zap fields

The test data initializes ZapNative to zero and ZapData to empty, which might not adequately exercise the new functionality. Consider adding test cases that cover:

  • Non-zero ZapNative values
  • Non-empty ZapData payloads
  • Edge cases for both fields

Here's a suggested enhancement to the test data:

 func (c *RelayerServerSuite) getTestQuoteRequest(status reldb.QuoteRequestStatus) reldb.QuoteRequest {
+    // Add test cases with different ZapNative and ZapData values
+    testCases := []struct {
+        zapNative *big.Int
+        zapData   []byte
+    }{
+        {big.NewInt(0), []byte{}},                    // Current case
+        {big.NewInt(1000), []byte{0x1, 0x2, 0x3}},   // Non-zero values
+        {big.NewInt(1e18), []byte("test payload")},   // Large number and string payload
+    }
     // ... rest of the function
 }

Committable suggestion skipped: line range outside the PR's diff.

},
OriginTxHash: common.HexToHash("0x0000000"),
DestTxHash: common.HexToHash("0x0000001"),
Expand Down
16 changes: 8 additions & 8 deletions services/rfq/relayer/reldb/base/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ type RequestForQuote struct {
DestAmount decimal.Decimal `gorm:"index"`
// OriginFeeAmount is the origin fee amount
OriginFeeAmount decimal.Decimal
// CallValue is the call value
CallValue decimal.Decimal
// ZapNative is the zap native value
ZapNative decimal.Decimal
// DestTxHash is the destination tx hash
DestTxHash sql.NullString
// Deadline is the deadline for the relay
Expand All @@ -91,8 +91,8 @@ type RequestForQuote struct {
ExclusivityRelayer string
// ExclusivityEndTime is the exclusivity end time
ExclusivityEndTime time.Time
// CallParams is the call params
CallParams []byte
// ZapData is the zap data
ZapData []byte
// SendChainGas is whether the relay should send gas to the destination chain
SendChainGas bool
// Status is the current status of the event
Expand Down Expand Up @@ -148,8 +148,8 @@ func FromQuoteRequest(request reldb.QuoteRequest) RequestForQuote {
DestAmountOriginal: request.Transaction.DestAmount.String(),
DestAmount: decimal.NewFromBigInt(request.Transaction.DestAmount, int32(request.DestTokenDecimals)),
OriginFeeAmount: decimal.NewFromBigInt(request.Transaction.OriginFeeAmount, int32(request.OriginTokenDecimals)),
CallValue: decimal.NewFromBigInt(request.Transaction.CallValue, int32(nativeTokenDecimals)),
CallParams: request.Transaction.CallParams,
ZapNative: decimal.NewFromBigInt(request.Transaction.ZapNative, int32(nativeTokenDecimals)),
ZapData: request.Transaction.ZapData,
Deadline: time.Unix(int64(request.Transaction.Deadline.Uint64()), 0),
OriginNonce: int(request.Transaction.Nonce.Uint64()),
SendChainGas: request.TransactionV1.SendChainGas,
Expand Down Expand Up @@ -239,10 +239,10 @@ func (r RequestForQuote) ToQuoteRequest() (*reldb.QuoteRequest, error) {
OriginAmount: new(big.Int).Div(r.OriginAmount.BigInt(), big.NewInt(int64(math.Pow10(int(r.OriginTokenDecimals))))),
DestAmount: new(big.Int).Div(r.DestAmount.BigInt(), big.NewInt(int64(math.Pow10(int(r.DestTokenDecimals))))),
OriginFeeAmount: new(big.Int).Div(r.OriginFeeAmount.BigInt(), big.NewInt(int64(math.Pow10(int(r.OriginTokenDecimals))))),
CallValue: new(big.Int).Div(r.CallValue.BigInt(), big.NewInt(int64(math.Pow10(int(nativeTokenDecimals))))),
ZapNative: new(big.Int).Div(r.ZapNative.BigInt(), big.NewInt(int64(math.Pow10(int(nativeTokenDecimals))))),
ZapData: r.ZapData,
ExclusivityRelayer: common.HexToAddress(r.ExclusivityRelayer),
ExclusivityEndTime: big.NewInt(r.ExclusivityEndTime.Unix()),
CallParams: r.CallParams,
Deadline: big.NewInt(r.Deadline.Unix()),
Nonce: big.NewInt(int64(r.OriginNonce)),
},
Expand Down
4 changes: 2 additions & 2 deletions services/rfq/relayer/reldb/base/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func TestRoundtripBetweenFromQuoteRequestAndToQuoteRequest(t *testing.T) {
Nonce: big.NewInt(1),
ExclusivityEndTime: big.NewInt(0),
OriginFeeAmount: big.NewInt(0),
CallValue: big.NewInt(0),
CallParams: []byte{},
ZapNative: big.NewInt(0),
ZapData: []byte{},
},
Status: reldb.QuoteRequestStatus(1),
}
Expand Down
Loading