-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcabal_factory.evm
88 lines (76 loc) · 4.78 KB
/
cabal_factory.evm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
###---------------------------------------------------------------------
### Multisig factory constructor: Trivially return all the bytecode
###---------------------------------------------------------------------
600d 80 38 03 90 6000 39 # Copy the factory bytecode into memory
59 6000 f3 # Return the factory bytecode
###---------------------------------------------------------------------
### Multisig factory: Called with `quorum, member, member, ...'
###---------------------------------------------------------------------
606f 80 38 03 90 6000 39 # Copy the bytecode template into memory
6000 35 6046 53 # Set the quorum to the first calldata word
6020 # Start the loop at the second calldata word
###------------------------------------------------------------------
5b ### Add members: Append one `Auth' entry for each multisig member
###------------------------------------------------------------------
80 36 11 15 6038 57 # Exit the loop when end of calldata reached
6028 6047 59 39 # Copy the auth template to the end of memory
6020 81 04 60f8 03 # Compute the member ID as `f7', `f6', ...
6027 59 03 53 # Fill in the member ID of the current entry
80 35 6025 59 03 52 # Fill in the address of the current entry
6020 01 6011 56 # Move to the next word and continue the loop
###------------------------------------------------------------------
5b ### Finish: Create a new multisig from the constructed bytecode
###------------------------------------------------------------------
59 6000 6000 f0 # Create a contract from the bytecode in memory
6000 52 6020 6000 f3 # Return the address of the new multisig
###---------------------------------------------------------------------
### Auth template: This is copied to the end once for each member:
###---------------------------------------------------------------------
60f7 7f000000000000000000000000ffffffffffffffffffffffffffffffffffffffff
33 14 6003 57
###---------------------------------------------------------------------
### Multisig constructor: Trivially return all the bytecode
###---------------------------------------------------------------------
600d 80 38 03 90 6000 39 # Copy the multisig bytecode into memory
59 6000 f3 # Return the multisig bytecode
###---------------------------------------------------------------------
### Multisig: Called with either an action hash or a full action
###---------------------------------------------------------------------
6075 56 # Go to `Auth' (kept at the end of the bytecode)
###------------------------------------------------------------------
5b ### Main: Start here if and when the membership check succeeds
###------------------------------------------------------------------
36 6000 6000 37 # Copy all the calldata into memory
6020 36 11 6033 57 # Go to `Fire' if the calldata is many words
## Abort if the confirmation flag of the caller was already set:
6000 35 80 54 82 6002 0a 80 82 16 6071 57
## Set the confirmation flag and increment the confirmation counter:
81 17 60ff 19 16 90 60ff 16 6001 01 17 90 55
6066 56 # Go to `Note'
###------------------------------------------------------------------
5b ### Fire: When calldata is `deadline, target, value, calldata...'
###------------------------------------------------------------------
36 6000 20 # Compute the hash of the full action
## Abort if the action is unconfirmed (`04' is altered by the factory):
60 04 81 54 60ff 16 10 6071 57
## Abort if the current time is past the deadline of the action:
6000 35 42 11 6071 57
## Otherwise, mark the action as triggered and perform the call:
60ff 19 90 55 6000 6000 6060 36 03 6060 6040 35 6020 35 45 f1
15 6073 57 # Go to `Fail' if the call failed
###------------------------------------------------------------------
5b ### Note: Log `target, caller, callvalue, timestamp' and calldata
###------------------------------------------------------------------
36 6000 42 34 33 6020 35 a4
###------------------------------------------------------------------
5b ### Exit: Come here to stop the transaction
###------------------------------------------------------------------
00
###------------------------------------------------------------------
5b ### Fail: Come here to revert the transaction
###------------------------------------------------------------------
fe
###------------------------------------------------------------------
5b ### Auth: Verify membership, leave ID on the stack and go to `Main':
###------------------------------------------------------------------
## (this part is filled in by the factory)