Module read_write_set

Module read_write_set 

Source
Expand description

Defines a struct that serves as a cache layer on top of World State.

There are two data caches:

  • reads (first-hand data obtained from world state)
  • writes (the data pended to commit to world state)

The cache layer also measures gas consumption for the read-write operations.

In Read Operation, writes is accessed first. If data is not found, search reads. If it fails in both Sets, then finally World State is accessed. The result will then be cached to reads.

In Write Operation, it first performs a Read Operation, and then updates the writes with the newest data.

At the end of state transition, if it succeeds, the data in writes will be committed to World State. Otherwise, writes is discarded without any changes to World State.