Skip to content

Commit

Permalink
Merge branch 'main' into rust-compile-target-setup-hs
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenbf committed Sep 18, 2024
2 parents 2b7f077 + 60710de commit a54db33
Show file tree
Hide file tree
Showing 152 changed files with 906,739 additions and 2,807 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-contracts-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
name: Clippy & fmt

env:
RUST_VERSION: "1.65"
RUST_VERSION: "1.73"
RUST_FMT: "nightly-2023-04-01"

defaults:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test-smart-contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

env:
RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu
RUST_CLIPPY: 1.68
RUST_CLIPPY: 1.73

jobs:

Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/build-test-sources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
strategy:
matrix:
plan:
- rust: 1.68
- rust: 1.73
crates:
- rust-src
- rust-bins
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
strategy:
matrix:
plan:
- rust: 1.65
- rust: 1.73

steps:
- name: Checkout
Expand All @@ -160,8 +160,8 @@ jobs:
strategy:
matrix:
plan:
- ghc: 9.2.7 # used as cache key only; stack uses the one specified in stack.yaml
rust: 1.68
- ghc: 9.6.4 # used as cache key only; stack uses the one specified in stack.yaml
rust: 1.73

steps:
- name: Checkout
Expand Down Expand Up @@ -197,9 +197,10 @@ jobs:
# Catching failure here avoids restoring of Haskell caches.
- name: Check that all Rust targets build
run: |
export RUSTFLAGS="-D warnings"
cargo check --locked --manifest-path rust-src/Cargo.toml --workspace
cargo check --locked --manifest-path rust-bins/Cargo.toml --workspace --features=vendored-ssl
cargo check --locked --manifest-path idiss/Cargo.toml --workspace
cargo check --locked --manifest-path idiss/Cargo.toml --workspace --features csharp
cargo check --locked --manifest-path mobile_wallet/Cargo.toml --workspace
cargo check --locked --manifest-path mobile_wallet/Cargo.toml --target aarch64-linux-android
cargo check --locked --manifest-path identity-provider-service/Cargo.toml --workspace --features=vendored-ssl
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pkg
*.iml
lib/
/idiss/libidiss.node
idiss-csharp/*/bin
idiss-csharp/*/obj

/smart-contracts/rust-contracts/concordium-std/Cargo.lock
/smart-contracts/wasm-transform/Cargo.lock
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ See documentation for

In order to build the components in this repository you need
- The [cargo](https://doc.rust-lang.org/cargo/) tool for building the Rust
components. The currently supported version is 1.68. Others may work, but we
components. The currently supported version is 1.73. Others may work, but we
do not regularly test with them. The easiest way to install it is via the
[rustup](https://rustup.rs/) tool.
- The [Haskell Stack](https://docs.haskellstack.org/en/stable/README/) tool for
Expand Down Expand Up @@ -140,7 +140,7 @@ issues.

## Rust workflow

We use **stable version** of rust, 1.68, to compile the code. This is the
We use **stable version** of rust, 1.73, to compile the code. This is the
minimal supported version.

The CI is configured to check two things
Expand Down
25 changes: 22 additions & 3 deletions Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ windowsBuild env verbosity = do
let libName = fst lib
libFeatures = snd lib
rawSystemExitWithEnv verbosity "cargo" (["rustc", "--release", "--manifest-path", "rust-src/" ++ libName ++"/Cargo.toml", "--crate-type", "cdylib"] ++ libFeatures) env
notice verbosity "Linking libraries to ./lib"
rawSystemExit verbosity "cp" ["-u", "rust-src/target/release/lib" ++ libName ++ ".a", "./lib/"]
notice verbosity "Copying libraries to ./lib"
-- We delete the static library if present to ensure that we only link with the
-- dynamic library.
rawSystemExit verbosity "rm" ["-f", "./lib/lib" ++ libName ++ ".a"]
rawSystemExit verbosity "cp" ["-u", "rust-src/target/release/" ++ libName ++ ".dll", "./lib/"]
notice verbosity $ "Copied " ++ libName ++ "."
mapM_ makeLib concordiumLibs
Expand Down Expand Up @@ -108,10 +110,27 @@ makeRust _ flags _ lbi = do
rawSystemExit verbosity "mkdir" ["-p", "./lib"]
build env verbosity

-- | On Windows, copy the DLL files to the binary install directory. This is to ensure that they
-- are accessible when running the binaries, tests and benchmarks.
copyDlls :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()
copyDlls _ flags pkgDescr lbi = case buildOS of
Windows -> do
let installDirs = absoluteComponentInstallDirs pkgDescr lbi (localUnitId lbi) copydest
let copyLib lib = do
rawSystemExit verbosity "cp" ["-u", "./lib/" ++ lib ++ ".dll", bindir installDirs]
notice verbosity $ "Copy " ++ lib ++ " to " ++ bindir installDirs
mapM_ copyLib concordiumLibs
_ -> return ()
where
distPref = fromFlag (copyDistPref flags)
verbosity = fromFlag (copyVerbosity flags)
copydest = fromFlag (copyDest flags)

main =
defaultMainWithHooks $
generatingProtos
"./concordium-grpc-api"
simpleUserHooks
{ postConf = makeRust
{ postConf = makeRust,
postCopy = copyDlls
}
24 changes: 14 additions & 10 deletions concordium-base.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.0

-- This file has been generated from package.yaml by hpack version 0.35.1.
-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand Down Expand Up @@ -62,6 +62,7 @@ library
Concordium.Genesis.Data.P5
Concordium.Genesis.Data.P6
Concordium.Genesis.Data.P7
Concordium.Genesis.Data.P8
Concordium.Genesis.Parameters
Concordium.GRPC2
Concordium.ID.Account
Expand All @@ -71,6 +72,7 @@ library
Concordium.ID.Parameters
Concordium.ID.Types
Concordium.Logger
Concordium.MerkleProofs
Concordium.Types
Concordium.Types.Accounts
Concordium.Types.Accounts.Releases
Expand Down Expand Up @@ -121,6 +123,7 @@ library
MultiParamTypeClasses
RecordWildCards
TupleSections
TypeOperators
ghc-options: -Wall -Wcompat -Werror=missing-fields -Werror=missing-methods -Wredundant-constraints -fno-ignore-asserts
extra-libraries:
concordium_base
Expand Down Expand Up @@ -148,7 +151,6 @@ library
, prettyprinter >=1.2
, primitive >=0.7
, proto-lens >=0.7
, proto-lens-protobuf-types >=0.7
, proto-lens-runtime >=0.7
, random >=1.1
, scientific >=0.3.2
Expand Down Expand Up @@ -185,6 +187,7 @@ executable generate-update-keys
MultiParamTypeClasses
RecordWildCards
TupleSections
TypeOperators
ghc-options: -Wall -Wcompat -Werror=missing-fields -Werror=missing-methods -Wredundant-constraints -fno-ignore-asserts
build-depends:
QuickCheck >=2.12
Expand Down Expand Up @@ -213,7 +216,6 @@ executable generate-update-keys
, prettyprinter >=1.2
, primitive >=0.7
, proto-lens >=0.7
, proto-lens-protobuf-types >=0.7
, proto-lens-runtime >=0.7
, random >=1.1
, scientific >=0.3.2
Expand Down Expand Up @@ -245,6 +247,7 @@ executable genesis
MultiParamTypeClasses
RecordWildCards
TupleSections
TypeOperators
ghc-options: -Wall -Wcompat -fno-ignore-asserts
build-depends:
QuickCheck >=2.12
Expand Down Expand Up @@ -273,7 +276,6 @@ executable genesis
, prettyprinter >=1.2
, primitive >=0.7
, proto-lens >=0.7
, proto-lens-protobuf-types >=0.7
, proto-lens-runtime >=0.7
, random >=1.1
, scientific >=0.3.2
Expand Down Expand Up @@ -303,6 +305,7 @@ test-suite test
ConcordiumTests.Crypto.VRF
ConcordiumTests.Data.Base58Encoding
ConcordiumTests.ID.Types
ConcordiumTests.MerkleProofs
ConcordiumTests.Utils.Encryption
ConcordiumTests.Utils.InterpolationSearch
Generators
Expand All @@ -313,6 +316,7 @@ test-suite test
Types.AmountSpec
Types.ParametersSpec
Types.PayloadSerializationSpec
Types.PayloadSpec
Types.TransactionSerializationSpec
Types.TransactionSummarySpec
Types.UpdatesSpec
Expand All @@ -330,6 +334,7 @@ test-suite test
MultiParamTypeClasses
RecordWildCards
TupleSections
TypeOperators
ghc-options: -threaded -with-rtsopts=-N -Wall -Wno-deprecations
build-depends:
HUnit >=1.6
Expand Down Expand Up @@ -358,7 +363,6 @@ test-suite test
, prettyprinter >=1.2
, primitive >=0.7
, proto-lens >=0.7
, proto-lens-protobuf-types >=0.7
, proto-lens-runtime >=0.7
, random
, scientific >=0.3.2
Expand Down Expand Up @@ -393,6 +397,7 @@ benchmark bls-perf
MultiParamTypeClasses
RecordWildCards
TupleSections
TypeOperators
build-depends:
QuickCheck >=2.12
, aeson >=1.4.2
Expand All @@ -418,7 +423,6 @@ benchmark bls-perf
, prettyprinter >=1.2
, primitive >=0.7
, proto-lens >=0.7
, proto-lens-protobuf-types >=0.7
, proto-lens-runtime >=0.7
, random >=1.1
, scientific >=0.3.2
Expand Down Expand Up @@ -451,6 +455,7 @@ benchmark ed25519-perf
MultiParamTypeClasses
RecordWildCards
TupleSections
TypeOperators
build-depends:
QuickCheck >=2.12
, aeson >=1.4.2
Expand All @@ -476,7 +481,6 @@ benchmark ed25519-perf
, prettyprinter >=1.2
, primitive >=0.7
, proto-lens >=0.7
, proto-lens-protobuf-types >=0.7
, proto-lens-runtime >=0.7
, random >=1.1
, scientific >=0.3.2
Expand Down Expand Up @@ -509,6 +513,7 @@ benchmark ed25519dlog-perf
MultiParamTypeClasses
RecordWildCards
TupleSections
TypeOperators
build-depends:
QuickCheck >=2.12
, aeson >=1.4.2
Expand All @@ -534,7 +539,6 @@ benchmark ed25519dlog-perf
, prettyprinter >=1.2
, primitive >=0.7
, proto-lens >=0.7
, proto-lens-protobuf-types >=0.7
, proto-lens-runtime >=0.7
, random >=1.1
, scientific >=0.3.2
Expand Down Expand Up @@ -567,6 +571,7 @@ benchmark sha256-perf
MultiParamTypeClasses
RecordWildCards
TupleSections
TypeOperators
build-depends:
QuickCheck >=2.12
, aeson >=1.4.2
Expand All @@ -592,7 +597,6 @@ benchmark sha256-perf
, prettyprinter >=1.2
, primitive >=0.7
, proto-lens >=0.7
, proto-lens-protobuf-types >=0.7
, proto-lens-runtime >=0.7
, random >=1.1
, scientific >=0.3.2
Expand Down Expand Up @@ -625,6 +629,7 @@ benchmark verify-credential-perf
MultiParamTypeClasses
RecordWildCards
TupleSections
TypeOperators
build-depends:
QuickCheck >=2.12
, aeson >=1.4.2
Expand All @@ -650,7 +655,6 @@ benchmark verify-credential-perf
, prettyprinter >=1.2
, primitive >=0.7
, proto-lens >=0.7
, proto-lens-protobuf-types >=0.7
, proto-lens-runtime >=0.7
, random >=1.1
, scientific >=0.3.2
Expand Down
2 changes: 1 addition & 1 deletion concordium-grpc-api
8 changes: 6 additions & 2 deletions haskell-bins/generate-update-keys/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

-- | A tool for generating update keys and authorizations for
Expand Down Expand Up @@ -181,11 +183,12 @@ generateKeys guk = do
doGenerateKeys @'AuthorizationsVersion1 Authorizations{..}
where
CommonUpdateKeys{..} = gukCommon guk
doGenerateKeys :: (IsAuthorizationsVersion auv) => Authorizations auv -> IO ()
doGenerateKeys :: forall auv. (IsAuthorizationsVersion auv) => Authorizations auv -> IO ()
doGenerateKeys level2KeysPre = do
putStrLn "Generating keys..."
asKeys <- Vec.fromList <$> sequence [makeKey k "level2-key" | k <- [0 .. cukKeyCount - 1]]
let level2Keys = level2KeysPre{asKeys = asKeys}
let level2Keys :: Authorizations auv
level2Keys = level2KeysPre{asKeys = asKeys}
rootKeys <- makeHAS cukRootKeys "root-key" "Root key structure"
level1Keys <- makeHAS cukLevel1Keys "level1-key" "Level 1 key structure"
let keyCollection = UpdateKeysCollection{..}
Expand All @@ -204,6 +207,7 @@ generateKeys guk = do
when (fromIntegral adThreshold > nKeys) $ die (desc ++ ": threshold (" ++ show adThreshold ++ ") cannot exceed number of keys (" ++ show nKeys ++ ")")
when (maxKey >= cukKeyCount) $ die (desc ++ ": key index " ++ show maxKey ++ " is out of bounds. Maximal index is " ++ show (cukKeyCount - 1))
return AccessStructure{accessThreshold = UpdateKeysThreshold adThreshold, ..}
makeHAS :: forall k. HigherAuthDetails -> String -> String -> IO (HigherLevelKeys k)
makeHAS HigherAuthDetails{..} name desc = do
when (hadThreshold > hadNumKeys) $ die (desc ++ ": threshold (" ++ show hadThreshold ++ ") cannot exceed number of keys (" ++ show hadNumKeys ++ ")")
hlkKeys <- Vec.fromList <$> sequence [makeKey k name | k <- [0 .. hadNumKeys - 1]]
Expand Down
Loading

0 comments on commit a54db33

Please sign in to comment.