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(wallet)!: allowing client to set custom values for fees, nonce, gas #6124

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

saledjenic
Copy link
Contributor

Removed properties from Path type:

  • MaxFeesPerGas, based on the sending flow progress appropriate new properties (TxMaxFeesPerGas, ApprovalMaxFeesPerGas) should be used

Added new properties to Path type:

  • RouterInputParamsUuid, used to identify from which router input params this path was created
  • TxNonce, used to set nonce for the tx
  • TxMaxFeesPerGas, used to set max fees per gas for the tx
  • TxEstimatedTime, used to estimate time for executing the tx
  • ApprovalTxNonce, used to set nonce for the approval tx
  • ApprovalTxMaxFeesPerGas, used to set max fees per gas for the approval tx
  • ApprovalTxEstimatedTime, used to estimate time for executing the approval tx

New request types added:

  • PathTxCustomParams, used to pass tx custom params from the client
  • PathTxIdentity, used to uniquely identify the path (tx) to which the custom params need to be applied

New endpoints added:

  • SetFeeMode, used to set fee mode (GasFeeLow, GasFeeMedium or GasFeeHigh)
  • SetCustomTxDetails, used to set custom fee mode (SetCustomTxDetails), if this mode is set, the client needs to provide:
    • Max fees per gas
    • Max priority fee
    • Nonce
    • Gas amount

Closes #6109

Closes backed part for

Copy link

github-actions bot commented Nov 26, 2024

Looks like you have BREAKING CHANGES in your PR.
Please make sure to follow 💔How to introduce breaking changes guide:

Check-list

@status-im-auto
Copy link
Member

status-im-auto commented Nov 26, 2024

Jenkins Builds

Click to see older builds (24)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 03d79cf #1 2024-11-26 11:36:52 ~4 min linux 📦zip
✔️ 03d79cf #1 2024-11-26 11:37:21 ~5 min macos 📦zip
✔️ 03d79cf #1 2024-11-26 11:37:30 ~5 min ios 📦zip
✔️ 03d79cf #1 2024-11-26 11:37:57 ~5 min tests-rpc 📄log
✔️ 03d79cf #1 2024-11-26 11:38:04 ~5 min windows 📦zip
✔️ 03d79cf #1 2024-11-26 11:38:52 ~6 min android 📦aar
✔️ 03d79cf #1 2024-11-26 11:42:09 ~9 min macos 📦zip
✖️ 03d79cf #1 2024-11-26 12:02:29 ~30 min tests 📄log
✖️ 38e658a #2 2024-11-26 14:05:50 ~4 min tests 📄log
✔️ 38e658a #2 2024-11-26 14:06:33 ~4 min macos 📦zip
✖️ 38e658a #2 2024-11-26 14:06:54 ~5 min tests-rpc 📄log
✔️ 38e658a #2 2024-11-26 14:07:14 ~5 min ios 📦zip
✔️ 38e658a #2 2024-11-26 14:07:22 ~5 min android 📦aar
✔️ 38e658a #2 2024-11-26 14:07:22 ~5 min linux 📦zip
✔️ 38e658a #2 2024-11-26 14:07:48 ~6 min windows 📦zip
✔️ 38e658a #2 2024-11-26 14:09:52 ~8 min macos 📦zip
✔️ f15bd8c #3 2024-11-28 11:41:23 ~4 min windows 📦zip
✔️ f15bd8c #3 2024-11-28 11:42:07 ~5 min tests-rpc 📄log
✔️ f15bd8c #3 2024-11-28 11:42:13 ~5 min linux 📦zip
✔️ f15bd8c #3 2024-11-28 11:42:26 ~5 min android 📦aar
✔️ f15bd8c #3 2024-11-28 11:42:55 ~5 min macos 📦zip
✔️ f15bd8c #3 2024-11-28 11:43:43 ~6 min ios 📦zip
✔️ f15bd8c #3 2024-11-28 11:47:08 ~10 min macos 📦zip
✖️ f15bd8c #3 2024-11-28 12:07:20 ~30 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 011767c #4 2024-11-28 11:45:26 ~3 min windows 📦zip
✔️ 011767c #4 2024-11-28 11:46:55 ~3 min macos 📦zip
✖️ 011767c #4 2024-11-28 11:47:13 ~4 min tests-rpc 📄log
✔️ 011767c #4 2024-11-28 11:47:49 ~5 min linux 📦zip
✔️ 011767c #4 2024-11-28 11:49:28 ~5 min ios 📦zip
✔️ 011767c #4 2024-11-28 11:50:58 ~8 min android 📦aar
✔️ 011767c #4 2024-11-28 11:58:59 ~11 min macos 📦zip
✖️ 011767c #5 2024-11-28 12:00:20 ~2 min tests-rpc 📄log
✖️ 011767c #4 2024-11-28 12:37:44 ~30 min tests 📄log
✖️ 011767c #6 2024-11-28 12:53:06 ~2 min tests-rpc 📄log
✔️ aae6e8b #5 2024-11-28 13:08:04 ~4 min windows 📦zip
✔️ aae6e8b #5 2024-11-28 13:08:37 ~4 min linux 📦zip
✔️ aae6e8b #7 2024-11-28 13:09:11 ~5 min tests-rpc 📄log
✔️ aae6e8b #5 2024-11-28 13:10:26 ~6 min ios 📦zip
✔️ aae6e8b #5 2024-11-28 13:10:27 ~6 min android 📦aar
✔️ aae6e8b #5 2024-11-28 13:11:08 ~7 min macos 📦zip
✔️ aae6e8b #5 2024-11-28 13:15:32 ~11 min macos 📦zip
✔️ aae6e8b #5 2024-11-28 13:34:06 ~30 min tests 📄log

@saledjenic saledjenic changed the title feat!: allowing client to set custom values for fees, nonce, gas feat(wallet)!: allowing client to set custom values for fees, nonce, gas Nov 26, 2024
@@ -55,6 +55,9 @@ type RouteInputParams struct {
PublicKey string `json:"publicKey"`
PackID *hexutil.Big `json:"packID"`

// Used internally
PathTxCustomParams map[string]*PathTxCustomParams `json:"-"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

if used internally it could be lower case?
that way it won't even be exported in json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cannot cause it's a different package. So either this or to have a function that will set this property, but more or less the same thing.

RouterInputParamsUuid string `json:"routerInputParamsUuid" validate:"required"`
PathName string `json:"pathName" validate:"required"`
ChainID uint64 `json:"chainID" validate:"required"`
ApprovalTx bool `json:"approvalTx"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: IsApprovalTx

@@ -50,23 +56,28 @@ type SuggestedFeesGwei struct {
MaxFeePerGasLow *big.Float `json:"maxFeePerGasLow"`
MaxFeePerGasMedium *big.Float `json:"maxFeePerGasMedium"`
MaxFeePerGasHigh *big.Float `json:"maxFeePerGasHigh"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

shall we adjust our various fees level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do you mean this? To have a new formula for each?

This is what we have now:

{
	Low:    (*hexutil.Big)(new(big.Int).Add(baseFee, maxPriorityFeePerGas)),
	Medium: (*hexutil.Big)(new(big.Int).Add(new(big.Int).Mul(baseFee, big.NewInt(2)), maxPriorityFeePerGas)),
	High:   (*hexutil.Big)(new(big.Int).Add(new(big.Int).Mul(baseFee, big.NewInt(3)), maxPriorityFeePerGas)),
}

Let me know if you want to change the equation and to what?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest: high to be 2x base fee and medium to be 1.2 base fee

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alaibe I've created a new PR for that, please check it here #6156

return r.setCustomTxDetails(pathTxIdentity, &requests.PathTxCustomParams{GasFeeMode: feeMode})
}

func (r *Router) SetCustomTxDetails(ctx context.Context, pathTxIdentity *requests.PathTxIdentity, pathTxCustomParams *requests.PathTxCustomParams) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we find a better name for the private function? IMO a bit unclear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am open to suggestions, but it's not private, it's exposed via API.
There are 2 new functions that we're exposing, mentioned in the description of this PR, under "New endpoints added:" section.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes this one is not private but there is also setCustomTxDetails
so 2 functions with same name one private, on public
I didn't suggest cause nothing comes to mind but ... there is probably a better naming

@saledjenic saledjenic force-pushed the feat/custom-fees branch 2 times, most recently from 38e658a to f15bd8c Compare November 28, 2024 11:36
@saledjenic saledjenic marked this pull request as ready for review November 28, 2024 11:37
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 71.05263% with 66 lines in your changes missing coverage. Please review.

Project coverage is 61.01%. Comparing base (991d5df) to head (aae6e8b).

Files with missing lines Patch % Lines
services/wallet/router/router_helper.go 66.25% 20 Missing and 7 partials ⚠️
services/wallet/router/router_updates.go 40.74% 14 Missing and 2 partials ⚠️
services/connector/commands/send_transaction.go 0.00% 4 Missing ⚠️
services/wallet/requests/tx_custom_params.go 66.66% 2 Missing and 2 partials ⚠️
services/wallet/router/router.go 92.00% 2 Missing and 2 partials ⚠️
services/wallet/router/routes/router_path.go 86.95% 2 Missing and 1 partial ⚠️
services/wallet/router/fees/fees.go 71.42% 1 Missing and 1 partial ⚠️
...allet/router/pathprocessor/processor_bridge_hop.go 0.00% 2 Missing ⚠️
...vices/wallet/transfer/transaction_manager_route.go 60.00% 2 Missing ⚠️
...s/wallet/router/pathprocessor/processor_erc1155.go 0.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #6124       +/-   ##
============================================
+ Coverage    14.10%   61.01%   +46.91%     
============================================
  Files          812      828       +16     
  Lines       108163   109888     +1725     
============================================
+ Hits         15258    67053    +51795     
+ Misses       90958    34974    -55984     
- Partials      1947     7861     +5914     
Flag Coverage Δ
functional 14.23% <58.77%> (+0.13%) ⬆️
unit 59.95% <39.91%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
services/wallet/api.go 19.05% <100.00%> (+13.04%) ⬆️
services/wallet/requests/router_input_params.go 26.38% <ø> (+19.44%) ⬆️
transactions/transactor.go 66.15% <100.00%> (+34.54%) ⬆️
...s/wallet/router/pathprocessor/processor_erc1155.go 4.34% <0.00%> (ø)
...es/wallet/router/pathprocessor/processor_erc721.go 3.20% <0.00%> (ø)
services/wallet/router/fees/fees.go 35.61% <71.42%> (+10.61%) ⬆️
...allet/router/pathprocessor/processor_bridge_hop.go 11.66% <0.00%> (+9.07%) ⬆️
...vices/wallet/transfer/transaction_manager_route.go 48.18% <60.00%> (+0.01%) ⬆️
services/wallet/router/routes/router_path.go 93.90% <86.95%> (+4.19%) ⬆️
services/connector/commands/send_transaction.go 54.83% <0.00%> (+54.83%) ⬆️
... and 4 more

... and 641 files with indirect coverage changes

@saledjenic saledjenic requested a review from friofry November 28, 2024 12:19
Removed properties from `Path` type:
- `MaxFeesPerGas`, based on the sending flow progress appropriate new properties (`TxMaxFeesPerGas`, `ApprovalMaxFeesPerGas`) should be used

Added new properties to `Path` type:
- `RouterInputParamsUuid`, used to identify from which router input params this path was created
- `TxNonce`, used to set nonce for the tx
- `TxMaxFeesPerGas`, used to set max fees per gas for the tx
- `TxEstimatedTime`, used to estimate time for executing the tx
- `ApprovalTxNonce`, used to set nonce for the approval tx
- `ApprovalTxMaxFeesPerGas`, used to set max fees per gas for the approval tx
- `ApprovalTxEstimatedTime`, used to estimate time for executing the approval tx

New request types added:
- `PathTxCustomParams`, used to pass tx custom params from the client
- `PathTxIdentity`, used to uniquely identify path (tx) to which the custom params need to be applied

New endpoints added:
- `SetFeeMode` used to set fee mode (`GasFeeLow`, `GasFeeMedium` or `GasFeeHigh`)
- `SetCustomTxDetails` used to set custom fee mode (`SetCustomTxDetails`), if this mode is set, client needs to provide:
  - Max fees per gas
  - Max priority fee
  - Nonce
  - Gas amount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add custom GasFeeMode to RouteInputParams
6 participants