3

I'm trying to figure out from Ethereum's yellow paper (Homestead edition) how does its storage model works (NOT memory model).

It seems that the storage is updated only once, after a transaction is over.

Specifically, SSTORE updates σ' (the post-transaction state in the yellow's paper notation), and SLOAD loads from σ (the pre-transaction state).

If that's true, then this pseudo-OPCODE:

SLOAD(1)

would act the same as:

SSTORE(1,"question") SLOAD(1) SSTORE(1,"another question") SLOAD(1)

Did I get it right? Is there a way to update the storage during a transaction (using it as a RAM)?

1 Answer 1

3

The definition you're reading from the Yellow Paper is for a single instance of SSTORE, and a single instance of SLOAD. You need to combine it with the rest of the paper, for example Section 6.2 Execution.

SSTORE and SLOAD works in the natural way: an SLOAD immediately following an SSTORE, will load the value that was just stored.

An example contract with storage variables x and y (so SSTORE and SLOAD are used):

contract C {
  uint x;
  uint y;

  function f() {
    x = 1;
    y = x;  // y is 1
    x = 2;
    y = x;  // y is 2
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.