GIP-0012: Reduced gas usage by caching address resolution

Hey,

I’m posting this new proposal to reduce gas cost by caching addresses in the contracts and to avoid some expensive CALL opcodes every time we need to read contract addresses.

For convenience, I’ve pasted the “Abstract” and “Motivation” of the GIP below.

Abstract

Improve the gas cost of fetching network contract addresses by caching them locally in each contract.

Motivation

The Controller contract works as a single registry for all the network contracts addresses. Whenever a contract needs to call another one it will fetch the address from the Controller.

Having a Controller contract is great in that we can sync addresses across the protocol from a single place, but it involves a roundtrip of CALL opcodes to get the addresses each time they are used.

An improvement to this is to have a state within each contract to cache the list of contract addresses and refresh it when the Controller is changed.

Gas saving are approximately 5% to 15% gas depending on the transaction.

The full GIP is available on the following link. Additionally it will be pushed to Radicle.

6 Likes