Skip to content

Commit

Permalink
Merge pull request #29 from CosmWasm/actor-model-rewording
Browse files Browse the repository at this point in the history
Partially reword the actor model page
  • Loading branch information
aumetra authored May 24, 2024
2 parents d03386c + 9bb0eb4 commit 38fe113
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/pages/core/architecture/actor-model.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ means a contract can only interact with the outside world via messages and only
manipulate its own state.

Picture two people living in two houses, each house has a mailbox. If person A
wants to talk to person B, they write a letter and put it in person B's mailbox.
Person B will read the letter and write a response, putting it in person A's
mailbox.
wants to talk to person B, they write a letter, address to to person B, and send
it off. The mailman (or in this case, the chain) will put the letter in person
B's mailbox.

Person B will then read the letter and can choose to write a response, address
it to person A with a note indicating that this is a reply, and send it off once
again.

No direct interaction is happening here, nobody visits each other's house which
would allow them to rummage around in their belongings (state). They simply
Expand All @@ -50,8 +54,8 @@ be.

But how does that fix reentrancy? In CosmWasm, you can only send out messages at
the end of a contract execution as part of the response. This ensures you have
already written everything to the state, meaning your state is in a consistent
state.
already written everything to the state, meaning the state can't suddenly change
mid-execution and make your contract exhibit buggy behaviour.

CosmWasm effectively forces you to follow the
[CEI pattern (Checks, Effects, Interactions)](https://fravoll.github.io/solidity-patterns/checks_effects_interactions.html)
Expand Down

0 comments on commit 38fe113

Please sign in to comment.