FuelLabs / fuel-vm

Fuel v2 interpreter in Rust
Other
358 stars 88 forks source link

Store the base asset id in the metadata #781

Closed xgreenx closed 5 months ago

xgreenx commented 5 months ago

Having the base asset id allows to get the base asset balance by just using metadata without consensus parameters.

Before requesting review

xgreenx commented 5 months ago

It is possible to change the base asset id via consensus parameters.

While checked transactions live inside of the memory pool, consensus parameters could change. When we try to ask for a transaction about its base asset balance, it will return the wrong value.

Another reason for the change is to make the Checked transaction self-contained. You can request the base balance without providing the consensus parameters.

Taking into account that each time to get the latest consensus parameters, we need to lock and clone the consensus parameters from the cache, it will not affect performance.

MitchTurner commented 5 months ago

But we don't want to let a tx submitter just choose some arbitrary base asset. I guess we are going to still check that the base asset is correct for the block when we call into_ready, maybe?

xgreenx commented 5 months ago

The TX submitter can't choose it. We cached the value from consensus parameters. The Checked transactions created within the node=)

In the same way, we could just case base_asset_amount. But having a base asset it is more flexible.