Skip to content

Change state rent#659

Merged
xlc merged 5 commits intomasterfrom
evm-state-rent
Jan 13, 2021
Merged

Change state rent#659
xlc merged 5 commits intomasterfrom
evm-state-rent

Conversation

@zjb0807
Copy link
Contributor

@zjb0807 zjb0807 commented Jan 7, 2021

Closes: #654

@zjb0807 zjb0807 requested a review from xlc January 7, 2021 01:07
@zjb0807 zjb0807 marked this pull request as ready for review January 7, 2021 02:29
&contract_info.maintainer,
pre_additional_storage,
additional_storage,
100000,
Copy link
Member

Choose a reason for hiding this comment

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

should pass u32::max_value if you want to mean no limit, instead of an arbitrary number

// get maintainer quota and refund the additional_storage
Self::do_update_maintainer_storage_usage(&contract_info.maintainer, additional_storage, 0)?;
// refund the additional_storage
Self::do_update_storage_usage(&contract, &contract_info.maintainer, additional_storage, 0, 100000)?;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Self::do_update_storage_usage(&contract, &contract_info.maintainer, additional_storage, 0, 100000)?;
Self::do_update_storage_usage(&contract, &contract_info.maintainer, additional_storage, 0, 0)?;

this shouldn't use more storage

@zjb0807 zjb0807 requested a review from xlc January 12, 2021 00:00
Copy link
Member

@xlc xlc left a comment

Choose a reason for hiding this comment

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

Looks good so far. I will do a more detailed review later.

}

pub fn used_storage(&self) -> usize {
self.storagemeter.total_used_storage() - self.storagemeter.refunded_storage()
Copy link
Member

Choose a reason for hiding this comment

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

it is possible refunded is more than used


/// Storagemeter.
#[derive(Clone)]
pub struct Storagemeter {
Copy link
Member

Choose a reason for hiding this comment

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

move this to a new file storage_meter.rs and have some tests in that file

/// Storagemeter.
#[derive(Clone)]
pub struct Storagemeter {
storage_limit: usize,
Copy link
Member

Choose a reason for hiding this comment

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

use u32 everywhere to keep things simple

@xlc
Copy link
Member

xlc commented Jan 13, 2021

There are still few things can be improved but I think it is good enough for this to be merged now. I will do some refactor later.

@xlc xlc merged commit e1a4b18 into master Jan 13, 2021
@xlc xlc deleted the evm-state-rent branch January 13, 2021 01:21
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.

EVM state rent redesign

2 participants