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 ContractInfo table and versionable ContractInfoType to on-chain storage #1657

Merged
merged 14 commits into from
Feb 27, 2024
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

Description of the upcoming release here.

### Added

- [#1671](https://github.com/FuelLabs/fuel-core/pull/1671): Added a new `Merklized` blueprint that maintains the binary Merkle tree over the storage data. It supports only the insertion of the objects without removing them.
- [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Moved `ContractsInfo` table from `fuel-vm` to on-chain tables, and created version-able `ContractsInfoType` to act as the table's data type.

### Changed

- [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Upgrade to `fuel-vm` 0.46.0.
- [#1671](https://github.com/FuelLabs/fuel-core/pull/1671): The logic related to the `FuelBlockIdsToHeights` is moved to the off-chain worker.
- [#1663](https://github.com/FuelLabs/fuel-core/pull/1663): Reduce the punishment criteria for mempool gossipping.
- [#1658](https://github.com/FuelLabs/fuel-core/pull/1658): Removed `Receipts` table. Instead, receipts are part of the `TransactionStatuses` table.
Expand All @@ -38,6 +38,8 @@ Description of the upcoming release here.
- [#1636](https://github.com/FuelLabs/fuel-core/pull/1636): Add more docs to GraphQL DAP API.

#### Breaking

- [#1657](https://github.com/FuelLabs/fuel-core/pull/1657): Changed `CROO` gas price type from `Word` to `DependentGasPrice`. The dependent gas price values are dummy values while awaiting updated benchmarks.
- [#1671](https://github.com/FuelLabs/fuel-core/pull/1671): The GraphQL API uses block height instead of the block id where it is possible. The transaction status contains `block_height` instead of the `block_id`.
- [#1675](https://github.com/FuelLabs/fuel-core/pull/1675): Simplify GQL schema by disabling contract resolvers in most cases, and just return a ContractId scalar instead.
- [#1658](https://github.com/FuelLabs/fuel-core/pull/1658): Receipts are part of the transaction status.
Expand Down
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fuel-core-tests = { version = "0.0.0", path = "./tests" }
fuel-core-xtask = { version = "0.0.0", path = "./xtask" }

# Fuel dependencies
fuel-vm-private = { version = "0.45.0", package = "fuel-vm", default-features = false }
fuel-vm-private = { version = "0.46.0", package = "fuel-vm", default-features = false }

# Common dependencies
anyhow = "1.0"
Expand Down
6 changes: 5 additions & 1 deletion benches/src/default_gas_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn default_gas_costs() -> GasCostsValues {
cb: 2,
cfei: 2,
cfsi: 2,
croo: 40,
div: 2,
divi: 2,
eck1: 3347,
Expand Down Expand Up @@ -101,6 +100,11 @@ pub fn default_gas_costs() -> GasCostsValues {
base: 59,
units_per_gas: 20,
},
// TODO: Update CROO values based on benchmarks: https://github.com/FuelLabs/fuel-core/issues/1660
croo: DependentCost::LightOperation {
base: 1,
units_per_gas: 1,
},
csiz: DependentCost::LightOperation {
base: 59,
units_per_gas: 195,
Expand Down
22 changes: 6 additions & 16 deletions benches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ impl From<Vec<u8>> for ContractCode {

Self {
contract,
salt,
id,
root,
storage_root,
salt,
slots,
}
}
Expand Down Expand Up @@ -162,8 +162,6 @@ impl VmBench {

let program = Witness::from(program);

let salt = rng.gen();

let contract = Contract::from(program.as_ref());
let state_root = Contract::default_state_root();
let id = VmBench::CONTRACT;
Expand All @@ -175,7 +173,7 @@ impl VmBench {
let input = Input::contract(utxo_id, balance_root, state_root, tx_pointer, id);
let output = Output::contract(0, rng.gen(), rng.gen());

db.deploy_contract_with_id(&salt, &[], &contract, &state_root, &id)?;
db.deploy_contract_with_id(&[], &contract, &id)?;

let data = id
.iter()
Expand Down Expand Up @@ -359,7 +357,6 @@ impl TryFrom<VmBench> for VmBenchPrepared {
let code = iter::once(op::ret(RegId::ONE));
let code: Vec<u8> = code.collect();
let code = Contract::from(code);
let root = code.root();

let input = tx.inputs().len();
let output =
Expand All @@ -375,16 +372,15 @@ impl TryFrom<VmBench> for VmBenchPrepared {
tx.add_input(input);
tx.add_output(output);

db.deploy_contract_with_id(&VmBench::SALT, &[], &code, &root, &contract)?;
db.deploy_contract_with_id(&[], &code, &contract)?;
}

if let Some(ContractCode {
contract,
salt,
id,
root,
slots,
storage_root,
..
}) = contract_code
{
let input_count = tx.inputs().len();
Expand All @@ -401,7 +397,7 @@ impl TryFrom<VmBench> for VmBenchPrepared {
tx.add_input(input);
tx.add_output(output);

db.deploy_contract_with_id(&salt, &slots, &contract, &root, &id)?;
db.deploy_contract_with_id(&slots, &contract, &id)?;
}

for contract_id in empty_contracts {
Expand All @@ -419,13 +415,7 @@ impl TryFrom<VmBench> for VmBenchPrepared {
tx.add_input(input);
tx.add_output(output);

db.deploy_contract_with_id(
&VmBench::SALT,
&[],
&Contract::default(),
&Bytes32::zeroed(),
&contract_id,
)?;
db.deploy_contract_with_id(&[], &Contract::default(), &contract_id)?;
}

inputs.into_iter().for_each(|i| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ expression: json
"cb": 1,
"cfei": 1,
"cfsi": 1,
"croo": 16,
"div": 1,
"divi": 1,
"eck1": 951,
Expand Down Expand Up @@ -137,6 +136,12 @@ expression: json
"units_per_gas": 103
}
},
"croo": {
"LightOperation": {
"base": 1,
"units_per_gas": 1
}
},
"csiz": {
"LightOperation": {
"base": 17,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ expression: json
"cb": 1,
"cfei": 1,
"cfsi": 1,
"croo": 16,
"div": 1,
"divi": 1,
"eck1": 951,
Expand Down Expand Up @@ -149,6 +148,12 @@ expression: json
"units_per_gas": 103
}
},
"croo": {
"LightOperation": {
"base": 1,
"units_per_gas": 1
}
},
"csiz": {
"LightOperation": {
"base": 17,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ expression: json
"cb": 1,
"cfei": 1,
"cfsi": 1,
"croo": 16,
"div": 1,
"divi": 1,
"eck1": 951,
Expand Down Expand Up @@ -149,6 +148,12 @@ expression: json
"units_per_gas": 103
}
},
"croo": {
"LightOperation": {
"base": 1,
"units_per_gas": 1
}
},
"csiz": {
"LightOperation": {
"base": 17,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ expression: json
"cb": 1,
"cfei": 1,
"cfsi": 1,
"croo": 16,
"div": 1,
"divi": 1,
"eck1": 951,
Expand Down Expand Up @@ -145,6 +144,12 @@ expression: json
"units_per_gas": 103
}
},
"croo": {
"LightOperation": {
"base": 1,
"units_per_gas": 1
}
},
"csiz": {
"LightOperation": {
"base": 17,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ expression: json
"cb": 1,
"cfei": 1,
"cfsi": 1,
"croo": 16,
"div": 1,
"divi": 1,
"eck1": 951,
Expand Down Expand Up @@ -145,6 +144,12 @@ expression: json
"units_per_gas": 103
}
},
"croo": {
"LightOperation": {
"base": 1,
"units_per_gas": 1
}
},
"csiz": {
"LightOperation": {
"base": 17,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ expression: json
"cb": 1,
"cfei": 1,
"cfsi": 1,
"croo": 16,
"div": 1,
"divi": 1,
"eck1": 951,
Expand Down Expand Up @@ -163,6 +162,12 @@ expression: json
"units_per_gas": 103
}
},
"croo": {
"LightOperation": {
"base": 1,
"units_per_gas": 1
}
},
"csiz": {
"LightOperation": {
"base": 17,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ expression: json
"cb": 1,
"cfei": 1,
"cfsi": 1,
"croo": 16,
"div": 1,
"divi": 1,
"eck1": 951,
Expand Down Expand Up @@ -148,6 +147,12 @@ expression: json
"units_per_gas": 103
}
},
"croo": {
"LightOperation": {
"base": 1,
"units_per_gas": 1
}
},
"csiz": {
"LightOperation": {
"base": 17,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ expression: json
"cb": 1,
"cfei": 1,
"cfsi": 1,
"croo": 16,
"div": 1,
"divi": 1,
"eck1": 951,
Expand Down Expand Up @@ -143,6 +142,12 @@ expression: json
"units_per_gas": 103
}
},
"croo": {
"LightOperation": {
"base": 1,
"units_per_gas": 1
}
},
"csiz": {
"LightOperation": {
"base": 17,
Expand Down
Loading
Loading