Skip to content

Commit

Permalink
[engine] kill Daml withAuthority / LF WITH_AUTHORITY (#16548)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickchapman-da committed Apr 17, 2023
1 parent e1a96bc commit ac68bdf
Show file tree
Hide file tree
Showing 21 changed files with 16 additions and 620 deletions.
3 changes: 0 additions & 3 deletions compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ data BuiltinExpr
| BEFoldr -- :: ∀a b. (a -> b -> b) -> b -> List a -> b
| BEEqualList -- :: ∀a. (a -> a -> Bool) -> List a -> List a -> Bool

-- Authority operations
| BEWithAuthority -- :: ∀ a. List Party -> Update a -> Update a

-- Map operations
| BETextMapEmpty -- :: ∀ a. TextMap a
| BETextMapInsert -- :: ∀ a. Text -> a -> TextMap a -> TextMap a
Expand Down
1 change: 0 additions & 1 deletion compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ instance Pretty BuiltinExpr where
BEExpInt64 -> "EXP_INT64"
BEFoldl -> "FOLDL"
BEFoldr -> "FOLDR"
BEWithAuthority -> "WITH_AUTHORITY"
BETextMapEmpty -> "TEXTMAP_EMPTY"
BETextMapInsert -> "TEXTMAP_INSERT"
BETextMapLookup -> "TEXTMAP_LOOKUP"
Expand Down
1 change: 0 additions & 1 deletion compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/DecodeV1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,6 @@ decodeBuiltinFunction = \case

LF1.BuiltinFunctionFOLDL -> pure BEFoldl
LF1.BuiltinFunctionFOLDR -> pure BEFoldr
LF1.BuiltinFunctionWITH_AUTHORITY -> pure BEWithAuthority
LF1.BuiltinFunctionEQUAL_LIST -> pure BEEqualList
LF1.BuiltinFunctionAPPEND_TEXT -> pure BEAppendText

Expand Down
1 change: 0 additions & 1 deletion compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/EncodeV1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ encodeBuiltinExpr = \case

BEFoldl -> builtin P.BuiltinFunctionFOLDL
BEFoldr -> builtin P.BuiltinFunctionFOLDR
BEWithAuthority -> builtin P.BuiltinFunctionWITH_AUTHORITY
BEEqualList -> builtin P.BuiltinFunctionEQUAL_LIST
BEExplodeText -> builtin P.BuiltinFunctionEXPLODE_TEXT
BEAppendText -> builtin P.BuiltinFunctionAPPEND_TEXT
Expand Down
1 change: 0 additions & 1 deletion compiler/daml-lf-tools/src/DA/Daml/LF/Simplifier.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ safetyStep = \case
BEExpInt64 -> Safe 1
BEFoldl -> Safe 2
BEFoldr -> Safe 2
BEWithAuthority -> Safe 2 -- not reachable; so "undefined" would suffice
BETextMapEmpty -> Safe 0
BETextMapInsert -> Safe 3
BETextMapLookup -> Safe 2
Expand Down
6 changes: 0 additions & 6 deletions compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,6 @@ typeOfBuiltin = \case
BEFoldr -> pure $ TForall (alpha, KStar) $ TForall (beta, KStar) $
(tAlpha :-> tBeta :-> tBeta) :-> tBeta :-> TList tAlpha :-> tBeta

BEWithAuthority ->
pure $ TForall (alpha, KStar) $
TList TParty :->
TUpdate tAlpha :->
TUpdate tAlpha

BETextMapEmpty -> pure $ TForall (alpha, KStar) $ TTextMap tAlpha
BETextMapInsert -> pure $ TForall (alpha, KStar) $ TText :-> tAlpha :-> TTextMap tAlpha :-> TTextMap tAlpha
BETextMapLookup -> pure $ TForall (alpha, KStar) $ TText :-> TTextMap tAlpha :-> TOptional tAlpha
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ convertPrim _ "BEFoldl" ((b1 :-> a1 :-> b2) :-> b3 :-> TList a2 :-> b4) | a1 ==
convertPrim _ "BEFoldr" ((a1 :-> b1 :-> b2) :-> b3 :-> TList a2 :-> b4) | a1 == a2, b1 == b2, b2 == b3, b3 == b4 =
pure $ EBuiltin BEFoldr `ETyApp` a1 `ETyApp` b1

-- Authority operations
convertPrim _ "BEWithAuthority" (TList TParty :-> TUpdate a1 :-> TUpdate a2) | a1 == a2 =
pure $ EBuiltin BEWithAuthority `ETyApp` a1

-- Error
convertPrim _ "BEError" (TText :-> t2) =
pure $ ETyApp (EBuiltin BEError) t2
Expand Down
12 changes: 0 additions & 12 deletions compiler/damlc/daml-stdlib-src/DA/Internal/LF.daml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ module DA.Internal.LF
, AnyException
#endif

#ifdef DAML_WITH_AUTHORITY
, withAuthorityOf
#endif

) where

import GHC.Stack.Types (HasCallStack)
Expand Down Expand Up @@ -276,11 +272,3 @@ instance Ord TypeRep where
data AnyException = AnyException Opaque

#endif

#ifdef DAML_WITH_AUTHORITY

-- | Authority operations.
withAuthorityOf : [Party] -> Update a -> Update a
withAuthorityOf = primitive @"BEWithAuthority"

#endif
3 changes: 3 additions & 0 deletions compiler/damlc/tests/daml-test-files/WithAuthority.daml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ template ProposeConsortiumAuthority
withAuthorityOf accepted $ do
withAuthorityOf [consortiumParty] $ do
create HasConsortiumAutority with consortiumParty

withAuthorityOf : [Party] -> Update a -> Update a
withAuthorityOf _ u = u -- TODO #15882 -- require rework
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,7 @@ enum BuiltinFunction {

TYPE_REP_TYCON_NAME = 148; // *Available in versions >= 1.dev*

WITH_AUTHORITY = 149; // *Available in versions >= 1.dev*

// Next id is 150.
// Next id is 149.

// EXPERIMENTAL TEXT PRIMITIVES -- these do not yet have stable numbers.
TEXT_TO_UPPER = 9901; // *Available in versions >= 1.dev*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,6 @@ private[archive] object DecodeV1 {
BuiltinFunctionInfo(NUMERIC_TO_INT64, BNumericToInt64, minVersion = numeric),
BuiltinFunctionInfo(FOLDL, BFoldl),
BuiltinFunctionInfo(FOLDR, BFoldr),
BuiltinFunctionInfo(WITH_AUTHORITY, BWithAuthority),
BuiltinFunctionInfo(TEXTMAP_EMPTY, BTextMapEmpty),
BuiltinFunctionInfo(TEXTMAP_INSERT, BTextMapInsert),
BuiltinFunctionInfo(TEXTMAP_LOOKUP, BTextMapLookup),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2509,8 +2509,8 @@ class EngineTest
case Right((_, _)) =>
}
}

"authority required; not granted" in {
/*
"authority required; not granted" in { // TODO #15882 -- rework required
inside(run(mkCommand(party1 = alice, party2 = bob), grantNeedAuthority = false)) {
case Left(
Interpretation(
Expand All @@ -2523,11 +2523,12 @@ class EngineTest
}
}
"authority required; granted" in {
"authority required; granted" in { // TODO #15882 -- rework required
inside(run(mkCommand(party1 = alice, party2 = bob), grantNeedAuthority = true)) {
case Right((_, _)) =>
}
}
*/
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,6 @@ private[lf] final class PhaseOne(
case BFoldr => SBFoldr
case BEqualList => SBEqualList

// Authority functions
case BWithAuthority => SBWithAuthority

// Errors
case BError => SBUserError

Expand Down
Loading

0 comments on commit ac68bdf

Please sign in to comment.