This repository has been archived by the owner on Jan 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use local state during a transaction (#771)
Time spent on this PR: 2.5 ## Pull request type Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? Every opcode makes real changes to contract storages. This is harder to revert and more expensive in steps. ## What is the new behavior? A local `State` is created in the beginning of a tx/ExecutionContext and used as a buffer for SSTORE/SLOAD/BALANCE. Changes are committed or discarded at the end in `finalize`. The split between `ExecutionContext` and `CallContext` has been reviewed to put in the `CallContext` every constants parts of the `ExecutionContext`, ie parameters/values set at init and not changed afterwards. Resolves: #770 #726 #690 #689 #688
- Loading branch information
1 parent
bdc82af
commit 748f50a
Showing
55 changed files
with
3,375 additions
and
2,423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,51 @@ | ||
pragma solidity >=0.8.0; | ||
|
||
import "./Counter.sol"; | ||
|
||
contract ContractRevertsOnMethodCall { | ||
Counter public counter; | ||
uint public value; | ||
event PartyTime(bool shouldDance); | ||
|
||
uint256 public value; | ||
|
||
event PartyTime(bool shouldDance); | ||
|
||
function triggerRevert() public { | ||
counter = new Counter(); | ||
counter = new Counter(); | ||
value = 1; | ||
emit PartyTime(true); | ||
|
||
emit PartyTime(true); | ||
revert("FAIL"); | ||
} | ||
} | ||
|
||
contract ContractRevertsOnConstruction { | ||
uint public value; | ||
uint256 public value; | ||
|
||
constructor() { | ||
value = 42; | ||
revert("FAIL"); | ||
} | ||
} | ||
|
||
contract ContractWithSelfdestructMethod { | ||
uint256 public count; | ||
|
||
constructor() payable {} | ||
|
||
function inc() public { | ||
count++; | ||
} | ||
|
||
function kill() public { | ||
selfdestruct(payable(msg.sender)); | ||
} | ||
} | ||
|
||
contract ContractRevertOnFallbackAndReceive { | ||
fallback() external payable { | ||
revert("reverted on fallback"); | ||
} | ||
|
||
receive() external payable { | ||
revert("reverted on receive"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.