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: add beta-4 target, and point --testnet to beta-4 network for forc-deploy #4974

Closed
wants to merge 15 commits into from

Conversation

kayagokalp
Copy link
Member

Description

closes #4973.

waiting for #4972 to be merged first.

With this PR, we are now adding --target beta-4 and alias --testnet to --target beta-4 so that users can deploy to beta-4 with just providing --tesnet flag.

forc-deploy --testnet
 Compiling library core (/Users/kayagokalp/.forc/git/checkouts/std-9be0d6062747ea7/04a597093e7441898933dd412b8e4dc6ac860cd3/sway-lib-core)
 Compiling library std (git+https://github.com/fuellabs/sway?tag=v0.44.1#04a597093e7441898933dd412b8e4dc6ac860cd3)
 Compiling contract deploy-to-beta-4 (/Users/kayagokalp/fuel/test_projects/deploy-to-beta-4)
  Finished debug in 4.57878525s
  contract deploy-to-beta-4
      Bytecode size: 68 bytes

Please provide the password of your encrypted wallet vault at "/Users/kayagokalp/.fuel/wallets/.wallet": 

Account 0 -- fuel18caanqmumttfnm8qp0eq7u9yluydxtqmzuaqtzdjlsww5t2jmg9skutn8n:
  Asset ID                                                           Amount
  0000000000000000000000000000000000000000000000000000000000000000 499999960

Please provide the index of account to use for signing: 0
Do you agree to sign this transaction with fuel18caanqmumttfnm8qp0eq7u9yluydxtqmzuaqtzdjlsww5t2jmg9skutn8n? [y/N]: y


Contract deploy-to-beta-4 Deployed!

Network: beta-4.fuel.network/graphql
Contract ID: 0x7e59d984c57b01ef3ffb873781e938fb389f57e14fa4553c54f730a54a6016ec
Deployed in block 0x7d8238d863ece8d3dfb62eae9341ea66b42545b4edcc41265f1f183394d5d717

@kayagokalp kayagokalp added enhancement New feature or request forc-deploy Everything to do with forc-deploy labels Aug 17, 2023
@kayagokalp kayagokalp self-assigned this Aug 17, 2023
@kayagokalp kayagokalp changed the base branch from master to kayagokalp/4862 August 17, 2023 21:37
@kayagokalp kayagokalp marked this pull request as ready for review August 17, 2023 21:37
@kayagokalp kayagokalp requested a review from a team August 17, 2023 21:37
@kayagokalp
Copy link
Member Author

We should point this PR to master once we have #4972 merged.

@Voxelot
Copy link
Member

Voxelot commented Aug 17, 2023

In the future is there a way we could dynamically update this via a config file we host somewhere (ie. github) instead of needing to make new releases of forc?

@kayagokalp
Copy link
Member Author

In the future is there a way we could dynamically update this via a config file we host somewhere (ie. github) instead of needing to make new releases of forc?

Yeah that is definitely a better idea. Opened #4975.

@kayagokalp kayagokalp requested a review from sdankel August 17, 2023 22:28
@kayagokalp kayagokalp requested a review from a team August 17, 2023 22:30
Base automatically changed from kayagokalp/4862 to master August 18, 2023 04:29
@kayagokalp kayagokalp enabled auto-merge (squash) August 18, 2023 10:14
@kayagokalp kayagokalp requested review from sdankel, JoshuaBatty, eureka-cpu and a team August 18, 2023 10:14
@kayagokalp kayagokalp requested a review from JoshuaBatty August 18, 2023 10:27
JoshuaBatty
JoshuaBatty previously approved these changes Aug 18, 2023
Copy link
Member

@JoshuaBatty JoshuaBatty left a comment

Choose a reason for hiding this comment

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

utACK, looks good though.

@kayagokalp kayagokalp requested a review from a team August 18, 2023 14:21
@kayagokalp kayagokalp mentioned this pull request Aug 18, 2023
Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Should we also add tests for beta-4?

testnet: false,
gas: Gas {
price: 1,
limit: 100000000,
Copy link
Member

@sdankel sdankel Aug 18, 2023

Choose a reason for hiding this comment

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

Added some unit tests to show the current behavior - still don't understand the logic behind overriding the gas limit for beta-4.

Copy link
Member Author

@kayagokalp kayagokalp Aug 20, 2023

Choose a reason for hiding this comment

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

Thanks so much for adding the tests 💯 I am not sure why this is only needed for beta4 but the default max gas limit returns:

Error: Decode error: Custom { kind: Other, error: "Response errors; TransactionGasLimit" }

This is not the case for other beta networks.

If i change the default value, beta-3 and beta-2 would break, so I patched it only for beta-4 and if users provide gas_limit their gas_limit will override our preset value (unless they specified the max value, but again providing max value for gas limit returns the error above). This is not ideal but it enables to deploy without specifying any other flags.

Also I imagine this feature is only for beta networks for mainnet we would require users to specify --gas-limit and --gas-price by themselves (or if there is a way to estimate gas-limit using SDK, we can explore that later on as well)

Copy link
Member

@sdankel sdankel Aug 21, 2023

Choose a reason for hiding this comment

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

I'm just wondering if there's a more appropriate gas limit than 1. Does a gas limit of 1 work actually work for any transactions?

We might want to fix the issue with the default gas limit in forc-tx rather than overriding it in forc-deploy.

Copy link
Member Author

Choose a reason for hiding this comment

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

We now ask the test net for min gas price if the user left it as 0 by default. The testnet returns the accepted min gas price and we use that instead of 0 so that the transaction is valid.

We do the same thing for gas_limit if they left as the default max value, we ask the chain the valid max value and use it instead, so that we do not exceed the limit set by the node.

I think that while deploying to test net we can override this as we want the transactions to be valid by default and if the user choses to be providing the extremes we can use the extreme set by the node instead. Maybe I can add a warning to notify them?

Copy link
Member Author

Choose a reason for hiding this comment

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

On a second thought modiying this rn to make sure we do not override any user given data. If the user wants to override the default data returned by the node they can. Maybe they would want to test some stuff around that

create
.gas
.limit
.unwrap_or(fuel_tx::ConsensusParameters::DEFAULT.max_gas_per_tx),
Copy link
Member

Choose a reason for hiding this comment

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

Should we be using the defaults from the node here as well?

Copy link
Member

Choose a reason for hiding this comment

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

Actually it seems like forc-tx doesn't specify the node, so there's no way to use the node's defaults

auto-merge was automatically disabled August 23, 2023 15:21

Pull request was closed

sdankel added a commit that referenced this pull request Aug 23, 2023
…4991)

## Description

Closes #4974

Added the beta-4 target and updated documentation (from
#4974)

Refactored part of forc-deploy and added unit tests.
- No longer mutating the Command, so the Command is always whatever the
user gave us
- Using the default values from the node itself via API call, rather
than hardcoded constants
- The values of `Gas` are now optional, so we only override them when
the user hasn't specified anything

Other changes:
- deployment works using the urls without `/graphql` prefixes, so I
updated the constants to remove the prefix. This is shown to the user
and it looks cleaner without it.
- Added coloring and consistent styling for errors and warnings to
printed to the console. It looks like this now (previously no color)
- `deploy`, `run`, and `submit` all now have the same options for
specifying the node (node_url, testnet, and target), capture in the
`TargetNode` struct. They use the same helper functions to extract the
node url and determine gas limit & price.


![image](https://github.com/FuelLabs/sway/assets/47993817/711382e4-c79e-49f0-85a3-b75704f7af9d)

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: kayagokalp <[email protected]>
Co-authored-by: Joshua Batty <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request forc-deploy Everything to do with forc-deploy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add beta-4 target/testnet to forc-client with meaningful default tx params
4 participants