Skip to content

Commit 8293833

Browse files
dkcummingjberthold
andauthored
Corrections to Multisig cheatcodes (#942)
The cheatcode previously left the signers of the multisig as an existential `?SIGNERS` representing the whole list. This meant that the proof state could not make progress without a more detailed form. Now the cheatcode explicitly lists out each of the [11 Signers](https://github.com/runtimeverification/solana-token/blob/233457bf2f619a7875349c177b61401128d69e0c/p-interface/src/state/multisig.rs#L25) as `Key(?Signer<N>)` where `0 <= N < 11`. Each of these signers is also restricted to be 32 bytes by predicates in the `ensures` clause e.g.: `size(?Signer0) ==Int 32 andBool allBytes(?Signer0)`. This change has been tested and makes progress with the `InitializeMultisig` proof (P-Token). --------- Co-authored-by: Jost Berthold <jost.berthold@gmail.com>
1 parent 280f602 commit 8293833

1 file changed

Lines changed: 40 additions & 8 deletions

File tree

  • kmir/src/kmir/kdist/mir-semantics/symbolic

kmir/src/kmir/kdist/mir-semantics/symbolic/p-token.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ The code uses some helper sorts for better readability.
100100
| KeyError ( Value )
101101
102102
syntax Key ::= toKey ( Value ) [function, total]
103-
// -----------------------------------------------------------
103+
// ---------------------------------------------
104104
rule toKey(Range(ELEMS)) => Key( ELEMS ) requires size(ELEMS) ==Int 32 andBool allBytes(ELEMS) [preserves-definedness]
105105
rule toKey(VAL) => KeyError(VAL) [owise]
106106
@@ -111,7 +111,7 @@ The code uses some helper sorts for better readability.
111111
rule allBytes( ListItem(_OTHER) _:List) => false [owise]
112112
113113
syntax Value ::= fromKey ( Key ) [function, total]
114-
// -----------------------------------------------------------
114+
// -----------------------------------------------
115115
// We assume that the Key always contains valid data, because it is constructed via toKey.
116116
rule fromKey(KeyError(VAL)) => VAL
117117
rule fromKey(Key(VAL)) => Range(VAL) [preserves-definedness]
@@ -129,15 +129,26 @@ This ensures that branches on the key value are not duplicated.
129129
| SignersError ( Value )
130130
131131
syntax Signers ::= toSigners ( Value ) [function, total]
132-
// -----------------------------------------------------------
133-
rule toSigners(Range(ELEMS)) => Signers( ELEMS ) requires size(ELEMS) ==Int 11 andBool allKeys(ELEMS) [preserves-definedness]
132+
// -----------------------------------------------------
133+
rule toSigners(Range(ELEMS)) => Signers( toKeys(ELEMS) ) requires size(ELEMS) ==Int 11 andBool allKeys(ELEMS)
134134
rule toSigners(VAL) => SignersError(VAL) [owise]
135135
136136
syntax Value ::= fromSigners ( Signers ) [function, total]
137-
// -----------------------------------------------------------
137+
// -------------------------------------------------------
138138
// We assume that the Signers always contains valid data, because it is constructed via toSigners.
139139
rule fromSigners(SignersError(VAL)) => VAL
140-
rule fromSigners(Signers(VAL)) => Range(VAL) [preserves-definedness]
140+
rule fromSigners(Signers(VAL)) => Range(fromKeys(VAL))
141+
142+
syntax List ::= fromKeys ( List ) [function, total]
143+
| toKeys ( List ) [function, total]
144+
// ------------------------------------------------
145+
rule fromKeys(.List) => .List
146+
rule fromKeys(ListItem(KEY:Key) REST) => ListItem(fromKey(KEY)) fromKeys(REST)
147+
rule fromKeys(ListItem(_NOTKEY) REST) => ListItem(StringVal("Not a Key")) fromKeys(REST) [owise] // HACK
148+
149+
rule toKeys(.List) => .List
150+
rule toKeys(ListItem(KEYBYTES:Value) REST) => ListItem(toKey(KEYBYTES)) toKeys(REST)
151+
rule toKeys(ListItem( _NOTBYTES ) REST) => ListItem(KeyError(StringVal("Not Bytes"))) toKeys(REST) [owise]
141152
142153
syntax Bool ::= allKeys ( List ) [function, total]
143154
// -----------------------------------------------------------
@@ -648,13 +659,34 @@ An `AccountInfo` reference is passed to the function.
648659
IMulti(U8(?M),
649660
U8(?N),
650661
U8(?INITIALISED),
651-
Signers(?SIGNERS)
662+
Signers( ListItem(Key(?Signer0))
663+
ListItem(Key(?Signer1))
664+
ListItem(Key(?Signer2))
665+
ListItem(Key(?Signer3))
666+
ListItem(Key(?Signer4))
667+
ListItem(Key(?Signer5))
668+
ListItem(Key(?Signer6))
669+
ListItem(Key(?Signer7))
670+
ListItem(Key(?Signer8))
671+
ListItem(Key(?Signer9))
672+
ListItem(Key(?Signer10))
673+
)
652674
)
653675
)
654676
ensures 0 <=Int ?M andBool ?M <=Int 256
655677
andBool 0 <=Int ?N andBool ?N <=Int 256
656678
andBool 0 <=Int ?INITIALISED andBool ?INITIALISED <=Int 256
657-
andBool size(?SIGNERS) ==Int 11 andBool allKeys(?SIGNERS)
679+
andBool size(?Signer0) ==Int 32 andBool allBytes(?Signer0)
680+
andBool size(?Signer1) ==Int 32 andBool allBytes(?Signer1)
681+
andBool size(?Signer2) ==Int 32 andBool allBytes(?Signer2)
682+
andBool size(?Signer3) ==Int 32 andBool allBytes(?Signer3)
683+
andBool size(?Signer4) ==Int 32 andBool allBytes(?Signer4)
684+
andBool size(?Signer5) ==Int 32 andBool allBytes(?Signer5)
685+
andBool size(?Signer6) ==Int 32 andBool allBytes(?Signer6)
686+
andBool size(?Signer7) ==Int 32 andBool allBytes(?Signer7)
687+
andBool size(?Signer8) ==Int 32 andBool allBytes(?Signer8)
688+
andBool size(?Signer9) ==Int 32 andBool allBytes(?Signer9)
689+
andBool size(?Signer10) ==Int 32 andBool allBytes(?Signer10)
658690
andBool DATA_LEN ==Int 355 // size_of(Multisig), see pinocchio_token_interface::state::Transmutable instance
659691
```
660692

0 commit comments

Comments
 (0)