Skip to content

Conversation

@axic
Copy link
Member

@axic axic commented Sep 4, 2018

No description provided.

@axic axic force-pushed the call-to-self branch 2 times, most recently from 9a5ac7b to 00aa665 Compare September 4, 2018 17:38
@axic
Copy link
Member Author

axic commented Sep 4, 2018

I'm puzzled. Not sure what the requirements are on the filename, because eip-X.md only states

When opening a pull request to submit your EIP, please use an abbreviated title in the filename, eip-draft_title_abbrev.md.

But travis fails with:

Files found with invalid names:
eip-draft_reduced_cost_call_self.md

@chriseth
Copy link
Contributor

chriseth commented Sep 5, 2018

I would prefer a more comprehensive solution that also reduces the costs for e.g. repeated calls to the same library.

them through `JUMP` requires a bigger effort from the compiler as opposed to being able to use `CALL`s.

Using call-to-self provides the guarentee that when making an internal call the function can rely on a clear reset state of memory or context, benefiting both
contract writers and contract consumers against potentially undetetected edge cases were memory could poison the context of the internal function.
Copy link
Member

Choose a reason for hiding this comment

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

typo in undetected

@nateawelch
Copy link
Contributor

@chriseth The simple version of which would probably be keeping a list of addresses touched in the current transaction and searching the list each time there's a call, lowering the gas cost if there's a hit. That would also mean the client would have to keep all touched contracts loaded, which would probably mean an increase to the base cost of a CALL opcode. Analysis would have to be done to see if existing contracts would benefit or suffer from those changes.

Though I also have no idea how clients currently handle un-loading of contracts after execution so maybe they already keep it cached.

@axic
Copy link
Member Author

axic commented Sep 5, 2018

I would prefer a more comprehensive solution that also reduces the costs for e.g. repeated calls to the same library.

As discussed offline, that would really be similar to how "net sstore gas metering" is working: the VM should maintain the list of loaded contracts by a given contract and only charge once for loading it.

Therefore it doesn't make sense to extend this EIP with that, but would warrant its own EIP.

@chriseth
Copy link
Contributor

chriseth commented Sep 5, 2018

Note that such an extended version would also reduce the cost of contract calls because the actual call after an extcodesize check would be cheaper.


## Specification
If `block.number >= FORK_BLKNUM`, then decrease the cost of `CALL`, `DELEGATECALL`, `CALLCODE` and `STATICCALL` from 700 to 40,
if and only if, the destination address of the call equals to the address of the caller.
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this could be combined with a reduction for calling precompiles, as an alternative to EIP-1109?

@Souptacular Souptacular merged commit 8030c5b into ethereum:master Sep 18, 2018
@axic
Copy link
Member Author

axic commented Sep 18, 2018

Since this was merged as a draft, please take all the discussion to https://ethereum-magicians.org/t/eip-1380-reduced-gas-cost-for-call-to-self/1242

@axic axic deleted the call-to-self branch September 18, 2018 23:19
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.

6 participants