@@ -27,9 +27,13 @@ means a contract can only interact with the outside world via messages and only
27
27
manipulate its own state.
28
28
29
29
Picture two people living in two houses, each house has a mailbox. If person A
30
- wants to talk to person B, they write a letter and put it in person B's mailbox.
31
- Person B will read the letter and write a response, putting it in person A's
32
- mailbox.
30
+ wants to talk to person B, they write a letter, address to to person B, and send
31
+ it off. The mailman (or in this case, the chain) will put the letter in person
32
+ B's mailbox.
33
+
34
+ Person B will then read the letter and can choose to write a response, address
35
+ it to person A with a note indicating that this is a reply, and send it off once
36
+ again.
33
37
34
38
No direct interaction is happening here, nobody visits each other's house which
35
39
would allow them to rummage around in their belongings (state). They simply
50
54
51
55
But how does that fix reentrancy? In CosmWasm, you can only send out messages at
52
56
the end of a contract execution as part of the response. This ensures you have
53
- already written everything to the state, meaning your state is in a consistent
54
- state .
57
+ already written everything to the state, meaning the state can't suddenly change
58
+ mid-execution and make your contract exhibit buggy behaviour .
55
59
56
60
CosmWasm effectively forces you to follow the
57
61
[ CEI pattern (Checks, Effects, Interactions)] ( https://fravoll.github.io/solidity-patterns/checks_effects_interactions.html )
0 commit comments