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
ERC XXXX - Standard Contract Upgrade Events #1530
Comments
I support this ERC. We need to have a standard way to detect migrations and upgrades to new versions of smart contracts. Watching this thread. |
Yes, this ERC is critical for contract migrations and event-based semantics to work. We need something like this to standardize event scraping. I think you want events for both the retired contract (pointing to the new one) and the new contract (pointing to the retired one). I am not sure you even need/want ERC165 since you don't have an API to call. As soon as a contract is live/relevant it should have done an emit already. |
Does it makes sense to have a third argument to the event which is a reason string, giving some information about why the contract was upgraded? Kind of like a commit message. |
Adding from an offline conversation: If you want to do the delegate call to a contract that sends the events, your API contract will have to have a "this is where my events will come from" function that returns the constant address you will always use to emit your events. Then you can upgrade from v1Logic to v2Logic but both of those return eventsAddress. So, to me seems like the above ERC should have the retire(old,new) event and both old and new contracts should have a function that returns the events address then that can return "this" or a separate/common contract.
This de-couples API from (delegate) events address/contract so third parties can see where they should subscribe for events without knowing specifics about your particular implementation. Note: this could maybe return an array of addresses, then you could return your entire chain of upgraded event contracts addresses through this and/or use the retire event + function. |
Closing this as I don't think standardizing this is currently relevant considering most upgradable contract relay on delegate call methods. If anyone is interested in taking this forward, please free to reply and I can re-open it. |
eip: XXXX
title: Standard for Contract Upgrade Events Proposal
authors: ???
status: Draft
type: Standards Track
category: ERC
created: 2018-10-26
Simple Summary
Various third parties rely on events to track the state of contracts, such as token contracts. By listening to events, these parties can update their local database accordingly to suit their needs. For instance, Etherscan keeps track of ERC-20 and ERC-721 token transfer events to properly reflect users balances. However, contract upgrades can break the event traces if the events are now emitted in a new contract. This break in the event trace forces third parties to manually modify their local database and could easily be avoided if every contract upgrade used a standard event indicating where the new events will be.
Abstract
Establishing a standard on event emitted when contracts are upgraded to ensure contiguous event traces. This will enable third parties to efficiently follow event traces without having to manually intervene in case of a contract upgrade.
Motivation
Event traces can be very helpful for third parties to maintain a local database that is more efficient to query from. For instance, this should be the case for token balances, where one should be able to maintain a valid representation of the current balances of any given token contract by simply listening to events and updating the database accordingly. However, contracts that upgrade their logic while keeping the storage identical will lead to having events emitted in the new proxy contracts. If no standard events are emitted, third parties will be unaware that the events of a given contracts are now happening elsewhere and will be unable to adjust accordingly without manual intervention. This proposal aims to standardize the events emitted during contract upgrades to ensure that all other events can be track in a bidirectional matter.
Specification
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
We will refer to the storage contract as the contract that maintains all the storage variable and that can't be migrated. We will refer to logic contract as the contract that has write and read permission to the storage contract.
Every ERC-XXXX compliant contract must implement the ERC721 and ERC165 interfaces
Rationale
Imposing this event should be sufficient to allow any third party to track the events describing updates to a storage contract in a forward and backward manner.
Properly using ERC-165 is necessary such that third parties can automatically know that storage related events will be in a separate contract, a contract that can change.
Backwards Compatibility
?
Implementation
To potentially include :
Logic contract pointing to their respective storage contract?
Logic contract signal via ERC-165 that they only a logic contract?
Questions
Copyright
Copyright and related rights waived via CC0.
The text was updated successfully, but these errors were encountered: