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

Added a new Upgrade transaction to perform a network upgrade #567

Merged
merged 12 commits into from
Apr 9, 2024

Conversation

xgreenx
Copy link
Contributor

@xgreenx xgreenx commented Apr 5, 2024

Corresponding implementation: FuelLabs/fuel-vm#707

The change adds a new Upgrade transaction that allows upgrading either consensus parameters or state transition function used by the network to produce future blocks.

The purpose of the upgrade is defined by the Upgrade Purpose type.

The Upgrade transaction is chargeable, and the sender should pay for it. Transaction inputs should contain only base assets.

Only the privileged address can upgrade the network. The privileged address can be either a real account or a predicate.

We use postcard algorithm to serialize and deserialize consensus parameters during the upgrade. This algorithm works with numbers in a more sufficient way and compresses them well.

@@ -50,6 +51,8 @@ Sway
TAI
TODO
TypeScript
UpgradePurpose
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding UpgradePurpose and UpgradePurposeType to this file, you can just wrap them in backticks like UpgradePurpose so the spell checker will ignore them. Otherwise LGTM!

Copy link
Member

@Dentosal Dentosal left a comment

Choose a reason for hiding this comment

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

This describes the new data types and validity rules. However, I think the semantics of an upgrade should be described as well.

@@ -179,6 +179,12 @@ def metadata_gas_fees(tx) -> int:
elif tx.type == TransactionType.Script:
# add intrinsic cost of calculating the transaction id
total += sha256_gas_fee(size(tx))
elif tx.type == TransactionType.Upgrade:
# add intrinsic cost of calculating the transaction id
total += sha256_gas_fee(size(tx))
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this same for all tx types? Could we maybe move it outside the if statement, e.g. to the initializer of total? Also above we add it for every created output contract which doesn't seem correct. Not really part of this PR, but noticed that while reviewing.

src/tx-format/consensus_parameters.md Show resolved Hide resolved
Comment on lines +127 to +129
- Any input uses non-base asset.
- Any output is of type `OutputType.Contract` or `OutputType.Variable` or `OutputType.Message`
- More than one output is of type `OutputType.Change` with `asset_id` of zero
- Any output is of type `OutputType.Change` with non-zero `asset_id`
- Any output is of type `OutputType.Change` with non-base `asset_id`
Copy link
Member

Choose a reason for hiding this comment

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

nit: Out-of-scope for this PR. Still nice fixes and having them here is ok for me.

Comment on lines 178 to 181
Given helper `max_gas()` returns the maximum gas that the transaction can use.
Given helper `count_ones()` that returns the number of ones in the binary representation of a field.
Given helper `count_variants()` that returns the number of variants in an enum.
Given helper `sum_variants()` that sums all variants of an enum.
Copy link
Member

Choose a reason for hiding this comment

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

We're repeating these quite a bit. Maybe we should have a centralized list of these? Although I think these might be almost evident enough tha they don't need explanations.


Transaction is invalid if:

- `type > UpgradePurposeType.StateTransition`
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd prefer to just say that "type is not valid UpgradePurposeType value"

Comment on lines 54 to 55
UpgradePurpose
UpgradePurposeType
Copy link
Member

Choose a reason for hiding this comment

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

nit: these should probably just be in backticks (code) everywhere, so we don't need to spellcheck-allow them

@xgreenx xgreenx requested review from Dentosal, Voxelot and a team April 5, 2024 15:54
Copy link
Member

@Dentosal Dentosal left a comment

Choose a reason for hiding this comment

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

Now I'm happy with this

@@ -174,9 +174,12 @@ def metadata_gas_fees(tx) -> int:
# add intrinsic cost of calculating the contract id
# size = 4 byte seed + 32 byte salt + 32 byte code root + 32 byte state root
total += sha256_gas_fee(100)
# add intrinsic cost of calculating the transaction id
total += sha256_gas_fee(size(tx))
elif tx.type == TransactionType.Script:
Copy link
Member

Choose a reason for hiding this comment

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

Wait, what happened to the Script path?

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 is handled below=)
image

Since that part is identical for all transactions except Mint

@xgreenx xgreenx merged commit 1f50504 into master Apr 9, 2024
6 checks passed
@xgreenx xgreenx deleted the feature/upgrade-transaciton branch April 9, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants