Skip to content

Estimate contract creation properly#2113

Closed
axic wants to merge 1 commit intodevelopfrom
estimate-creation
Closed

Estimate contract creation properly#2113
axic wants to merge 1 commit intodevelopfrom
estimate-creation

Conversation

@axic
Copy link
Contributor

@axic axic commented Apr 10, 2017

It should take the size of the creation code in consideration and not the deployed one.

{
Gas gas = GasEstimator::functionalEstimation(*items);
u256 bytecodeSize(m_compiler->runtimeObject(_contract).bytecode.size());
u256 bytecodeSize(m_compiler->object(_contract).bytecode.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this was correct. The part after the + is the costs of code deployment. The cost of the transaction is not visible here at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cost of the transaction is the cost of deployment. The creation code only does a return. Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

After the return, you still have to pay a fee that is linear with the code deposit size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, found it in the YP:

If the initialization code completes successfully, a fi-
nal contract-creation cost is paid, the code-deposit cost,
c, proportional to the size of the created contract’s code:
(96) c ≡ Gcodedeposit × |o

codeDepositCost seems appropriate then to keep in line with the YP.

@axic axic closed this Apr 11, 2017
@axic axic deleted the estimate-creation branch April 11, 2017 02:08
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.

2 participants