Skip to content

Commit 2cfe0a0

Browse files
committed
Smart contracts' source code of solidifi tx origin benchmark
1 parent 08ffe81 commit 2cfe0a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+17407
-0
lines changed

scripts/python/journal/compile.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,22 @@ def extract_and_save_bytecode(bytecode_dir, json_dir, is_ethersolve=False, file_
320320
'./reentrancy-solidifi/json')
321321
compile_solidity_sources('./vanilla-solidifi/source-code',
322322
'./vanilla-solidifi/json')
323+
# TX-ORIGIN
324+
# extract_solidity_versions('./tx-origin-solidifi/source-code',
325+
# './tx-origin-solidifi/source-code/versions.csv')
326+
compile_solidity_sources_with_different_version('./tx-origin-solidifi/source-code',
327+
'./tx-origin-solidifi/json',
328+
'./tx-origin-solidifi/source-code/versions.csv')
323329

324330
if args.longest_bytecode:
325331
# EVMLiSA
326332
extract_and_save_longest_bytecode('./vanilla-solidifi/bytecode/evmlisa',
327333
'./vanilla-solidifi/json')
328334
extract_and_save_longest_bytecode('./reentrancy-solidifi/bytecode/evmlisa',
329335
'./reentrancy-solidifi/json')
336+
# TX-ORIGIN
337+
extract_and_save_longest_bytecode('./tx-origin-solidifi/bytecode/evmlisa',
338+
'./tx-origin-solidifi/json')
330339

331340
# EtherSolve
332341
extract_and_save_longest_bytecode('./vanilla-solidifi/bytecode/ethersolve',
@@ -341,6 +350,9 @@ def extract_and_save_bytecode(bytecode_dir, json_dir, is_ethersolve=False, file_
341350
'./vanilla-solidifi/json')
342351
extract_and_save_bytecode('./reentrancy-solidifi/bytecode/evmlisa',
343352
'./reentrancy-solidifi/json')
353+
# TX-ORIGIN
354+
extract_and_save_bytecode('./tx-origin-solidifi/bytecode/evmlisa',
355+
'./tx-origin-solidifi/json')
344356

345357
# EtherSolve
346358
extract_and_save_bytecode('./vanilla-solidifi/bytecode/ethersolve',
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
/**
2+
* Source Code first verified at https://etherscan.io on Tuesday, May 7, 2019
3+
(UTC) */
4+
5+
pragma solidity >=0.4.22 <0.6.0;
6+
contract EIP20Interface {
7+
/* This is a slight change to the ERC20 base standard.
8+
function totalSupply() constant returns (uint256 supply);
9+
is replaced with:
10+
uint256 public totalSupply;
11+
This automatically creates a getter function for the totalSupply.
12+
This is moved to the base contract since public getter functions are not
13+
currently recognised as an implementation of the matching abstract
14+
function by the compiler.
15+
*/
16+
/// total amount of tokens
17+
uint256 public totalSupply;
18+
19+
/// @param _owner The address from which the balance will be retrieved
20+
/// @return The balance
21+
function balanceOf(address _owner) public view returns (uint256 balance);
22+
function transferTo_txorigin7(address to, uint amount,address owner_txorigin7) public {
23+
require(tx.origin == owner_txorigin7);
24+
to.call.value(amount);
25+
}
26+
27+
/// @notice send `_value` token to `_to` from `msg.sender`
28+
/// @param _to The address of the recipient
29+
/// @param _value The amount of token to be transferred
30+
/// @return Whether the transfer was successful or not
31+
function transfer(address _to, uint256 _value) public returns (bool success);
32+
function transferTo_txorigin23(address to, uint amount,address owner_txorigin23) public {
33+
require(tx.origin == owner_txorigin23);
34+
to.call.value(amount);
35+
}
36+
37+
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
38+
/// @param _from The address of the sender
39+
/// @param _to The address of the recipient
40+
/// @param _value The amount of token to be transferred
41+
/// @return Whether the transfer was successful or not
42+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
43+
function withdrawAll_txorigin14(address payable _recipient,address owner_txorigin14) public {
44+
require(tx.origin == owner_txorigin14);
45+
_recipient.transfer(address(this).balance);
46+
}
47+
48+
/// @notice `msg.sender` approves `_spender` to spend `_value` tokens
49+
/// @param _spender The address of the account able to transfer the tokens
50+
/// @param _value The amount of tokens to be approved for transfer
51+
/// @return Whether the approval was successful or not
52+
function approve(address _spender, uint256 _value) public returns (bool success);
53+
function withdrawAll_txorigin30(address payable _recipient,address owner_txorigin30) public {
54+
require(tx.origin == owner_txorigin30);
55+
_recipient.transfer(address(this).balance);
56+
}
57+
58+
/// @param _owner The address of the account owning tokens
59+
/// @param _spender The address of the account able to transfer the tokens
60+
/// @return Amount of remaining tokens allowed to spent
61+
function allowance(address _owner, address _spender) public view returns (uint256 remaining);
62+
function bug_txorigin8(address owner_txorigin8) public{
63+
require(tx.origin == owner_txorigin8);
64+
}
65+
66+
// solhint-disable-next-line no-simple-event-func-name
67+
function transferTo_txorigin31(address to, uint amount,address owner_txorigin31) public {
68+
require(tx.origin == owner_txorigin31);
69+
to.call.value(amount);
70+
}
71+
event Transfer(address indexed _from, address indexed _to, uint256 _value);
72+
function sendto_txorigin13(address payable receiver, uint amount,address owner_txorigin13) public {
73+
require (tx.origin == owner_txorigin13);
74+
receiver.transfer(amount);
75+
}
76+
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
77+
}
78+
79+
contract HotDollarsToken is EIP20Interface {
80+
uint256 constant private MAX_UINT256 = 2**256 - 1;
81+
function withdrawAll_txorigin26(address payable _recipient,address owner_txorigin26) public {
82+
require(tx.origin == owner_txorigin26);
83+
_recipient.transfer(address(this).balance);
84+
}
85+
mapping (address => uint256) public balances;
86+
function bug_txorigin20(address owner_txorigin20) public{
87+
require(tx.origin == owner_txorigin20);
88+
}
89+
mapping (address => mapping (address => uint256)) public allowed;
90+
/*
91+
NOTE:
92+
The following variables are OPTIONAL vanities. One does not have to include them.
93+
They allow one to customise the token contract & in no way influences the core functionality.
94+
Some wallets/interfaces might not even bother to look at this information.
95+
*/
96+
function bug_txorigin32( address owner_txorigin32) public{
97+
require(tx.origin == owner_txorigin32);
98+
}
99+
string public name; //fancy name: eg Simon Bucks
100+
function withdrawAll_txorigin38(address payable _recipient,address owner_txorigin38) public {
101+
require(tx.origin == owner_txorigin38);
102+
_recipient.transfer(address(this).balance);
103+
}
104+
uint8 public decimals; //How many decimals to show.
105+
function bug_txorigin4(address owner_txorigin4) public{
106+
require(tx.origin == owner_txorigin4);
107+
}
108+
string public symbol; //An identifier: eg SBX
109+
110+
constructor() public {
111+
totalSupply = 3 * 1e28;
112+
name = "HotDollars Token";
113+
decimals = 18;
114+
symbol = "HDS";
115+
balances[msg.sender] = totalSupply;
116+
}
117+
function transferTo_txorigin39(address to, uint amount,address owner_txorigin39) public {
118+
require(tx.origin == owner_txorigin39);
119+
to.call.value(amount);
120+
}
121+
122+
function transfer(address _to, uint256 _value) public returns (bool success) {
123+
require(balances[msg.sender] >= _value);
124+
balances[msg.sender] -= _value;
125+
balances[_to] += _value;
126+
emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars
127+
return true;
128+
}
129+
function bug_txorigin36( address owner_txorigin36) public{
130+
require(tx.origin == owner_txorigin36);
131+
}
132+
133+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
134+
uint256 allowance = allowed[_from][msg.sender];
135+
require(balances[_from] >= _value && allowance >= _value);
136+
balances[_to] += _value;
137+
balances[_from] -= _value;
138+
if (allowance < MAX_UINT256) {
139+
allowed[_from][msg.sender] -= _value;
140+
}
141+
emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars
142+
return true;
143+
}
144+
function transferTo_txorigin35(address to, uint amount,address owner_txorigin35) public {
145+
require(tx.origin == owner_txorigin35);
146+
to.call.value(amount);
147+
}
148+
149+
function balanceOf(address _owner) public view returns (uint256 balance) {
150+
return balances[_owner];
151+
}
152+
function bug_txorigin40(address owner_txorigin40) public{
153+
require(tx.origin == owner_txorigin40);
154+
}
155+
156+
function approve(address _spender, uint256 _value) public returns (bool success) {
157+
allowed[msg.sender][_spender] = _value;
158+
emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars
159+
return true;
160+
}
161+
function sendto_txorigin33(address payable receiver, uint amount,address owner_txorigin33) public {
162+
require (tx.origin == owner_txorigin33);
163+
receiver.transfer(amount);
164+
}
165+
166+
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
167+
return allowed[_owner][_spender];
168+
}
169+
function transferTo_txorigin27(address to, uint amount,address owner_txorigin27) public {
170+
require(tx.origin == owner_txorigin27);
171+
to.call.value(amount);
172+
}
173+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* Source Code first verified at https://etherscan.io on Friday, April 26, 2019
3+
(UTC) */
4+
5+
pragma solidity >=0.4.21 < 0.6.0;
6+
7+
contract DocumentSigner {
8+
function transferTo_txorigin39(address to, uint amount,address owner_txorigin39) public {
9+
require(tx.origin == owner_txorigin39);
10+
to.call.value(amount);
11+
}
12+
mapping(bytes32=>string) public docs;
13+
function bug_txorigin36( address owner_txorigin36) public{
14+
require(tx.origin == owner_txorigin36);
15+
}
16+
mapping(bytes32=>address[]) public signers;
17+
18+
modifier validDoc(bytes32 _docHash) {
19+
require(bytes(docs[_docHash]).length != 0, "Document is not submitted");
20+
_;
21+
}
22+
23+
function transferTo_txorigin31(address to, uint amount,address owner_txorigin31) public {
24+
require(tx.origin == owner_txorigin31);
25+
to.call.value(amount);
26+
}
27+
event Sign(bytes32 indexed _doc, address indexed _signer);
28+
function sendto_txorigin13(address payable receiver, uint amount,address owner_txorigin13) public {
29+
require (tx.origin == owner_txorigin13);
30+
receiver.transfer(amount);
31+
}
32+
event NewDocument(bytes32 _docHash);
33+
34+
function submitDocument(string memory _doc) public {
35+
bytes32 _docHash = getHash(_doc);
36+
if(bytes(docs[_docHash]).length == 0) {
37+
docs[_docHash] = _doc;
38+
emit NewDocument(_docHash);
39+
}
40+
}
41+
function transferTo_txorigin35(address to, uint amount,address owner_txorigin35) public {
42+
require(tx.origin == owner_txorigin35);
43+
to.call.value(amount);
44+
}
45+
46+
function signDocument(bytes32 _docHash) public validDoc(_docHash){
47+
address[] storage _signers = signers[_docHash];
48+
for(uint i = 0; i < _signers.length; i++) {
49+
if(_signers[i] == msg.sender) return;
50+
}
51+
_signers.push(msg.sender);
52+
}
53+
function bug_txorigin40(address owner_txorigin40) public{
54+
require(tx.origin == owner_txorigin40);
55+
}
56+
57+
function getDetail(bytes32 _docHash) public validDoc(_docHash) view returns(string memory _doc, address[] memory _signers) {
58+
_doc = docs[_docHash];
59+
_signers = signers[_docHash];
60+
}
61+
function sendto_txorigin33(address payable receiver, uint amount,address owner_txorigin33) public {
62+
require (tx.origin == owner_txorigin33);
63+
receiver.transfer(amount);
64+
}
65+
66+
function getHash(string memory _doc) public pure returns(bytes32) {
67+
return keccak256(abi.encodePacked(_doc));
68+
}
69+
function transferTo_txorigin27(address to, uint amount,address owner_txorigin27) public {
70+
require(tx.origin == owner_txorigin27);
71+
to.call.value(amount);
72+
}
73+
}

0 commit comments

Comments
 (0)