Skip to content

Instantly share code, notes, and snippets.

@ihor
Last active February 10, 2023 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihor/65cfa2f43eae2fb8b7a349138875bca3 to your computer and use it in GitHub Desktop.
Save ihor/65cfa2f43eae2fb8b7a349138875bca3 to your computer and use it in GitHub Desktop.

CES as Casper ecosystem-wide standard

Events play a crucial role in the functioning and interactivity of decentralized applications (dApps) built on top of the blockchain. Events allow dApps to communicate and respond to changes in the blockchain state, making them a fundamental component of the overall blockchain ecosystem.

For example, events can be used to trigger a specific action or process when a certain condition is met, such as when an NFT token was transfered on the chain. This allows dApps to interact with the blockchain in real-time and provide users with instant feedback and updates.

Due to the absence of native events, developers of Casper dApps have resorted to workaround solutions to emulate events in deploy execution results. This involves creating distinctive WriteCLValue transforms that hold the event data, an approach commonly referred to as contract-level events.

When discussing contract-level events, the following aspects are of particular concern:

  1. Cost overhead
  2. Integration complexity
  3. Observability and trustworthiness

Let's take a closer look at each of these areas and explore how the Casper Event Standard (CES) represents an improvement compared to other options.

Cost Overhead

Contract-level events implemented as write operations to the global storage incur additional costs associated with the consumed space. CES events are encoded as raw bytes that take up only as much space as the underlying data structure that holds the information. The only part of the event that doesn't contain event information is the prefix, which is essential for event identification at scale.

This means that, apart from the prefix, there are no further optimizations that can be made to the event structure itself. All other optimizations can still be performed on the consumer level by smart contract developers.

The core team was pleased with the cost estimates for the CEP-78 events implemented using CES, and as a result, they decided to integrate them into the reference implementation. A member of the Casper Association noted that "there is a limit to what one can achieve on the contract level" and that CES "has reached that limit".

Integration Complexity

Developing smart contracts can be a complex task in and of itself, so it's important to minimize the impact of events on contract logic and design decisions made by developers. It's crucial to keep developers focused on their core domain rather than worrying about optimizing the side effects of events.

CES addresses this challenge by providing an independent library that abstracts all complexity behind a simple, domain-level interface. This allows dApp developers to easily integrate events into their contracts without needing to delve into the technical details of how the network operates.

Observability and Trustworthiness

Observability refers to the ease with which events can be identified and extracted from deployment execution results. It's crucial for event tracking to be scalable and accessible to all dApp developers, not just those with a deep understanding of the Casper network.

Trustworthiness, on the other hand, ensures that events can be confidently traced back to the contract that emitted them.

CES tackles these concerns by providing:

  • Event tracking without the need for additional RPC requests during the parsing of deployment execution results
  • Contract verification through event URef owned by the contract
  • Accessibility to anyone to observe contract events due to event schemas declared by the contract

Moreover, MAKE will provide CES event parsing libraries for the JavaScript and Golang programming languages, empowering dApp developers to integrate and observe their on-chain logic easily without the need for additional support, making the Casper ecosystem more accessible to the developers.

Ecosystem-wide adoption

Having a common event standard is beneficial because it enables interoperability and consistency across different dApps. A common event standard provides a clear and standardized format for emitting and handling events, which makes it easier for developers to build and integrate with other applications. This allows for the creation of a more cohesive and interconnected ecosystem of dApps, where different dApps can seamlessly interact with one another.

CES offers a cost-effective and developer-friendly event solution for Casper dApp developers, making it an ideal candidate for becoming such a standard in the Casper ecosystem. This standardized approach will make the ecosystem more appealing to developers and businesses, ultimately driving growth and innovation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment