Applying transactions that modify SC state with t.Apply #600
-
We are trying to implement a blockRewards system to compensate validators. Similar to how your team added the read transaction Although our function is getting queried, the state doesn't appear to change (msg.sender isn't being stored). Is there any recommended way to do this from within polygon-edge using Earlier on we tried storing a defined blockRewardAmount within the snapshot (updated each epoch), and then tried paying out this amount within PreStateCommit() that gets called from buildBlock(), unfortunately this would work for some time until a validator would fail to verify due to an invalid block root state :
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello, @dankostiuk. All validator needs to do same state change. Blockchain calls For example, staking contract is deployed without transaction at the specific height in the following code: polygon-edge/consensus/ibft/pos.go Lines 155 to 175 in 009a813 |
Beta Was this translation helpful? Give feedback.
Hello, @dankostiuk.
All validator needs to do same state change. Blockchain calls
PreStateCommit
of Blockchain with the state transition object after all transactions in a block are processed. You can use this callback to update your state.For example, staking contract is deployed without transaction at the specific height in the following code:
polygon-edge/consensus/ibft/pos.go
Lines 155 to 175 in 009a813