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

Reshuffled fields Script and Create transactions to unify part used by all chargeable transactions #703

Merged
merged 19 commits into from
Mar 26, 2024

Conversation

xgreenx
Copy link
Collaborator

@xgreenx xgreenx commented Mar 22, 2024

Related specification change: FuelLabs/fuel-specs#562

This change is a preparation for a small refactoring to create a template for chargeable transactions. Any chargeable transaction should contain inputs and output for coins, policies to actually charge the user, and witnesses for verifying signatures and any arbitrary data.

The template will look like:

pub struct ChargeableTransaction<Body, MetadataBody> {
    pub(crate) body: Body,
    pub(crate) policies: Policies,
    pub(crate) inputs: Vec<Input>,
    pub(crate) outputs: Vec<Output>,
    pub(crate) witnesses: Vec<Witness>,
    #[cfg_attr(feature = "serde", serde(skip))]
    #[derivative(PartialEq = "ignore", Hash = "ignore")]
    #[canonical(skip)]
    pub(crate) metadata: Option<ChargeableMetadata<MetadataBody>>,
}

Where Body is a unique part related to the business logic of the transaction.

In the case of the Script it is:

pub struct ScriptBody {
    pub(crate) script_gas_limit: Word,
    pub(crate) receipts_root: Bytes32,
    #[derivative(Debug(format_with = "fmt_truncated_hex::<16>"))]
    pub(crate) script: Vec<u8>,
    #[derivative(Debug(format_with = "fmt_truncated_hex::<16>"))]
    pub(crate) script_data: Vec<u8>,
}

In the case of the Create it is:

pub struct CreateBody {
    pub(crate) bytecode_length: Word,
    pub(crate) bytecode_witness_index: u16,
    pub(crate) salt: Salt,
    pub(crate) storage_slots: Vec<StorageSlot>,
}

Reduced default `MAX_SIZE` to be 110kb.
Reduced default `MAX_CONTRACT_SIZE` to be 100kb.
# Conflicts:
#	CHANGELOG.md
#	fuel-tx/src/builder.rs
#	fuel-tx/src/tests/valid_cases/transaction.rs
#	fuel-tx/src/transaction/consensus_parameters.rs
#	fuel-vm/src/checked_transaction.rs
#	fuel-vm/src/tests/limits.rs
#	fuel-vm/src/tests/validation.rs
@xgreenx xgreenx requested a review from a team March 22, 2024 13:32
@xgreenx xgreenx self-assigned this Mar 22, 2024
bvrooman
bvrooman previously approved these changes Mar 22, 2024
Dentosal
Dentosal previously approved these changes Mar 25, 2024
Base automatically changed from feature/versioning-sub-parameters to master March 25, 2024 15:57
@xgreenx xgreenx dismissed stale reviews from Dentosal and bvrooman March 25, 2024 15:57

The base branch was changed.

@xgreenx xgreenx requested review from Dentosal, bvrooman and a team March 25, 2024 16:01
@xgreenx xgreenx enabled auto-merge March 25, 2024 16:01
xgreenx added a commit to FuelLabs/fuel-specs that referenced this pull request Mar 26, 2024
Soon, we will add several more transaction variants that are also
chargeable. Because of that, I've decided to move unique fields of the
transaction to the top while keeping the common part at the end.

Implementation part with description of how it can be used
FuelLabs/fuel-vm#703 (comment)
@xgreenx xgreenx added this pull request to the merge queue Mar 26, 2024
Merged via the queue into master with commit 999b03f Mar 26, 2024
38 checks passed
@xgreenx xgreenx deleted the feature/common-payable-part branch March 26, 2024 14:41
@xgreenx xgreenx mentioned this pull request Mar 28, 2024
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.

3 participants