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: Remove ContractsInfo #673

Merged
merged 25 commits into from
Feb 19, 2024
Merged

Conversation

bvrooman
Copy link
Contributor

@bvrooman bvrooman commented Feb 10, 2024

@@ -31,16 +31,31 @@ impl Mappable for ContractsRawCode {
type Value = [u8];
}

/// The storage table for contract's additional information as salt, root hash, etc.
/// The storage table for contract's additional information
pub struct ContractsInfo;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not even sure that we need this table here=) Since we don't use salt in any logic, we can simply skip it, and it can be fully off-chain information.

@xgreenx
Copy link
Collaborator

xgreenx commented Feb 12, 2024

And we need to update CROO to be DependentCost instead of the Word

@bvrooman bvrooman changed the title feat: Versionable ContractsInfo Value feat: Remove ContractsInfo Feb 13, 2024
@bvrooman bvrooman marked this pull request as ready for review February 14, 2024 01:20
@bvrooman bvrooman requested a review from a team February 14, 2024 01:20
@bvrooman bvrooman self-assigned this Feb 14, 2024
Comment on lines +110 to +113
croo: DependentCost::LightOperation {
base: 1,
units_per_gas: 1,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating the costs is captured in a follow up task here: FuelLabs/fuel-core#1660

Dentosal
Dentosal previously approved these changes Feb 14, 2024
ContractId::from_bytes_ref(contract_id.read(&self.memory));
let code_size = contract_size(&self.storage, contract_id)? as Word;
let gas_cost = self.gas_costs().croo.resolve(code_size);
self.gas_charge(gas_cost)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to charge for it in the code_root. You can see how it was done in the code_size

@@ -1021,13 +1024,55 @@ fn code_copy_c_gt_vm_max_ram() {

#[test]
fn code_root_a_plus_32_overflow() {
Copy link
Member

@MitchTurner MitchTurner Feb 14, 2024

Choose a reason for hiding this comment

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

These tests are pretty noisy, and very imperative. It would be nice to kinda hide the details behind declarative functions deploy_contract, etc. That code can be shared as well.

Also given/when/then would be useful 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.

This is much better. I'm still kinda confused what these tests are for, but it's not really your job to fix all the tests in this PR.

Ideally, we just have one SUT (system under test) per tests and a single variable. And the name of the tests just is sut__when_x_then_y, but this
check_expected_reason_for_instructions_with_client we are using everywhere is hiding the SUT from us. i.e. we are expecting MemoryOverflow, but I'm not sure what we are even doing that is generating that error.

Kinda a perfect example of how writing code with DRY as a top priority can create a lack of clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. We lacked a proper standard for testing at the time and the consequence is an unstructured and incongruent series of tests across the codebase. This series of tests specifically could be rewritten to make the SUT, test setup, and success conditions more explicit, but I won't address it all at this time. It ultimately represents technical debt, and hopefully we can address it at some point.

xgreenx
xgreenx previously approved these changes Feb 15, 2024
Comment on lines 255 to 256
let mut cgas = 0;
let mut ggas = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to check that cgas and ggas are udpated=)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored the CROO test into croo_tests.rs and broke it up into individual tests. Each test now checks the cgas and ggas explicitly, for both success and failure cases.

Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
@xgreenx xgreenx added this pull request to the merge queue Feb 19, 2024
Merged via the queue into master with commit 2f90c90 Feb 19, 2024
37 checks passed
@xgreenx xgreenx deleted the bvrooman/feat/versionable-contract-info branch February 19, 2024 17:46
@xgreenx xgreenx mentioned this pull request Feb 21, 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.

4 participants