Skip to content

Commit

Permalink
Merge pull request #300 from Concordium/add-multi-sig-signing
Browse files Browse the repository at this point in the history
Add multi-sig support
  • Loading branch information
DOBEN authored May 24, 2024
2 parents 522cb3a + b423ec5 commit be58014
Show file tree
Hide file tree
Showing 6 changed files with 480 additions and 90 deletions.
10 changes: 7 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

- Rename subcommand `TransactionSubmit` to `TransactionSignAndSubmit`.
- Add subcommand `TransactionSubmit` to submit a signed transaction on chain.
- Add subcommand `TransactionAddSignature` to add a signature to a partially-signed transaction.
- Add optional `--out` flag to all transaction-creating commands to output a partially-singed transaction to a file.
- Update GHC version to 9.6.4 (lts-22.9).
- Update Rust version to 1.73.
- Support protocol version 7.
Expand Down Expand Up @@ -58,7 +62,7 @@
- Add round and epoch to the output of `raw GetBlockInfo`.
- Add round and epoch to the output of `block show` when they are present.
- Print "Block time" instead of "Slot time" in the output of `block show`.
- In the output of `consensus show-parameters`, only print election difficulty when present.
- In the output of `consensus show-parameters`, only print election difficulty when present.

## 5.2.0

Expand Down Expand Up @@ -121,10 +125,10 @@

- Add support of contract schema V3.
- V3 schemas offer the same options as V2, but also optionally includes a schema for contract events.
- `transaction status` now displays contract events, and a schema can be provided with `--schema`, which
- `transaction status` now displays contract events, and a schema can be provided with `--schema`, which
will be used to parse the contract events. By default events are parsed with the schema embedded in the
contract, if present.
- This enables concordium-client to interact with contracts and schemas
- This enables concordium-client to interact with contracts and schemas
using `concordium-std` version 5.
- Improved formatting of `transaction status` output using contract schemas if
they are available for displaying contract events.
Expand Down
2 changes: 1 addition & 1 deletion deps/concordium-base
Submodule concordium-base updated 60 files
+1 −0 concordium-base.cabal
+23 −6 haskell-src/Concordium/Cost.hs
+17 −0 haskell-src/Concordium/Crypto/EncryptedTransfers.hs
+8 −0 haskell-src/Concordium/ID/Types.hs
+1 −1 haskell-src/Concordium/Types.hs
+278 −15 haskell-src/Concordium/Types/Execution.hs
+13 −0 haskell-src/Concordium/Types/ProtocolVersion.hs
+2 −4 haskell-src/Concordium/Types/Transactions.hs
+72 −0 haskell-src/Concordium/Wasm.hs
+60 −2 haskell-tests/Generators.hs
+2 −0 haskell-tests/Spec.hs
+113 −14 haskell-tests/Types/PayloadSerializationSpec.hs
+99 −0 haskell-tests/Types/PayloadSpec.hs
+4 −4 mobile_wallet/Cargo.lock
+5 −0 rust-src/concordium_base/CHANGELOG.md
+115 −0 rust-src/concordium_base/src/cis3_types.rs
+5 −3 rust-src/concordium_base/src/lib.rs
+119 −41 rust-src/concordium_base/src/web3id/mod.rs
+4 −0 smart-contracts/contracts-common/concordium-contracts-common/CHANGELOG.md
+16 −0 smart-contracts/contracts-common/concordium-contracts-common/src/types.rs
+ smart-contracts/testdata/validation-time-consume.wasm
+459,862 −0 smart-contracts/testdata/validation-time-consume.wat
+ smart-contracts/testdata/validation-time-preserve.wasm
+439,015 −0 smart-contracts/testdata/validation-time-preserve.wat
+0 −121 smart-contracts/testdata/wasm-spec-test-suite/core/call.wast
+93 −223 smart-contracts/testdata/wasm-spec-test-suite/core/call_indirect.wast
+0 −42 smart-contracts/testdata/wasm-spec-test-suite/core/endianness.wast
+0 −18 smart-contracts/testdata/wasm-spec-test-suite/core/fac.wast
+0 −122 smart-contracts/testdata/wasm-spec-test-suite/core/local_set.wast
+0 −162 smart-contracts/testdata/wasm-spec-test-suite/core/local_tee.wast
+0 −48 smart-contracts/testdata/wasm-spec-test-suite/core/return.wast
+6 −39 smart-contracts/testdata/wasm-spec-test-suite/core/select.wast
+0 −32 smart-contracts/testdata/wasm-spec-test-suite/core/unreachable.wast
+20 −20 smart-contracts/testdata/wasm-spec-test-suite/core/unwind.wast
+1 −1 smart-contracts/wasm-chain-integration/Cargo.toml
+3 −2 smart-contracts/wasm-chain-integration/benches/v1-host-functions.rs
+34 −8 smart-contracts/wasm-chain-integration/benches/wasm.rs
+12 −0 smart-contracts/wasm-chain-integration/src/utils.rs
+20 −5 smart-contracts/wasm-chain-integration/src/v0/ffi.rs
+32 −6 smart-contracts/wasm-chain-integration/src/v0/mod.rs
+0 −15 smart-contracts/wasm-chain-integration/src/v0/types.rs
+8 −3 smart-contracts/wasm-chain-integration/src/v1/crypto_primitives_tests.rs
+44 −11 smart-contracts/wasm-chain-integration/src/v1/ffi.rs
+31 −11 smart-contracts/wasm-chain-integration/src/v1/mod.rs
+0 −15 smart-contracts/wasm-chain-integration/src/v1/types.rs
+26 −13 smart-contracts/wasm-test/src/main.rs
+8 −0 smart-contracts/wasm-transform/CHANGELOG.md
+8 −1 smart-contracts/wasm-transform/Cargo.toml
+60 −0 smart-contracts/wasm-transform/benches/validation-time.rs
+881 −237 smart-contracts/wasm-transform/src/artifact.rs
+38 −14 smart-contracts/wasm-transform/src/artifact_input.rs
+22 −1 smart-contracts/wasm-transform/src/artifact_output.rs
+1 −0 smart-contracts/wasm-transform/src/lib.rs
+556 −434 smart-contracts/wasm-transform/src/machine.rs
+389 −118 smart-contracts/wasm-transform/src/metering_transformation.rs
+8 −21 smart-contracts/wasm-transform/src/metering_transformation_test.rs
+14 −0 smart-contracts/wasm-transform/src/tests.rs
+9 −0 smart-contracts/wasm-transform/src/types.rs
+12 −4 smart-contracts/wasm-transform/src/utils.rs
+79 −18 smart-contracts/wasm-transform/src/validate.rs
102 changes: 94 additions & 8 deletions src/Concordium/Client/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,19 @@ registerDataParser =
<|> (RegisterRaw <$> strOption (long "raw" <> metavar "FILE" <> help "File with raw bytes to be registered on chain."))

data TransactionCmd
= TransactionSubmit
= TransactionSignAndSubmit
{ tssFile :: !FilePath,
tssInteractionOpts :: !InteractionOpts
}
| TransactionSubmit
{ tsFile :: !FilePath,
tsInteractionOpts :: !InteractionOpts
}
| TransactionAddSignature
{ tasFile :: !FilePath,
tasSigners :: !(Maybe Text),
tasToKeys :: !(Maybe FilePath)
}
| TransactionStatus
{ tsHash :: !Text,
-- | Path to a contract schema, used to display the transaction event info.
Expand Down Expand Up @@ -426,6 +435,9 @@ data TransactionOpts energyOrMaybe = TransactionOpts
toNonce :: !(Maybe Nonce),
toMaxEnergyAmount :: !energyOrMaybe,
toExpiration :: !(Maybe Text),
-- | Optional file name and path to output the signed/partially-signed
-- transaction to instead of submitting the transaction on-chain.
toOutFile :: !(Maybe FilePath),
toInteractionOpts :: !InteractionOpts
}
deriving (Show)
Expand Down Expand Up @@ -649,6 +661,7 @@ transactionOptsParserBuilder energyOrMaybeParser =
<*> optional (option auto (long "nonce" <> metavar "NONCE" <> help "Transaction nonce."))
<*> energyOrMaybeParser
<*> optional (strOption (long "expiry" <> metavar "EXPIRY" <> help "Expiration time of a transaction, specified as a relative duration (\"30s\", \"5m\", etc.) or UNIX epoch timestamp."))
<*> optional (strOption (long "out" <> metavar "FILE" <> help "File to output the signed/partially-signed transaction to instead of submitting the transaction on-chain."))
<*> interactionOptsParser

interactionOptsParser :: Parser InteractionOpts
Expand Down Expand Up @@ -700,7 +713,9 @@ transactionCmds =
( info
( TransactionCmd
<$> hsubparser
( transactionSubmitCmd
( transactionSignAndSubmitCmd
<> transactionSubmitCmd
<> transactionAddSignatureCmd
<> transactionStatusCmd
<> transactionSendCcdCmd
<> transactionWithScheduleCmd
Expand All @@ -712,18 +727,89 @@ transactionCmds =
(progDesc "Commands for submitting and inspecting transactions.")
)

transactionSignAndSubmitCmd :: Mod CommandFields TransactionCmd
transactionSignAndSubmitCmd =
command
"sign-and-submit"
( info
( TransactionSignAndSubmit
<$> strArgument (metavar "FILE" <> help "File containing the transaction parameters in JSON format.")
<*> interactionOptsParser
)
(progDesc "Parse a JSON transaction with keys, sign it, and send it to the node.")
)

transactionSubmitCmd :: Mod CommandFields TransactionCmd
transactionSubmitCmd =
command
"submit"
( info
( TransactionSubmit
<$> strArgument (metavar "FILE" <> help "File containing the transaction parameters in JSON format.")
<$> strArgument (metavar "FILE" <> help "File containing a signed transaction in JSON format.")
<*> interactionOptsParser
)
(progDesc "Parse transaction and send it to the node.")
( progDescDoc $
docFromLines $
[ "Parse signed transaction and send it to the node.",
"Expected format of the signed transaction in the `FILE`:"
]
++ expectedSignedTransactionFormat
)
)

transactionAddSignatureCmd :: Mod CommandFields TransactionCmd
transactionAddSignatureCmd =
command
"add-signature"
( info
( TransactionAddSignature
<$> strArgument (metavar "FILE" <> help "File containing a signed transaction in JSON format.")
<*> optional
( strOption
( long "signers" <> metavar "SIGNERS" <> help "Specification of which (local) keys to sign with. Example: \"0:1,0:2,3:0,3:1\" specifies that credential holder 0 signs with keys 1 and 2, while credential holder 3 signs with keys 0 and 1"
)
)
<*> optional
(strOption (long "keys" <> metavar "KEYS" <> help "Any number of sign/verify keys specified in a JSON file."))
)
( progDescDoc $
docFromLines $
[ "Adds a signature to the transaction in the file.",
"Expected format of the signed transaction in the `FILE`:"
]
++ expectedSignedTransactionFormat
++ [ "Expected format of the keys in the `KEYS` file:"
]
++ expectedKeysFileFormat
)
)

expectedSignedTransactionFormat :: [String]
expectedSignedTransactionFormat =
[ " {",
" \"energy\": 5000,",
" \"expiry\": 1715708777,",
" \"nonce\": 12,",
" \"payload\": {",
" \"address\": {",
" \"index\": 3383,",
" \"subindex\": 0",
" },",
" \"amount\": \"0\",",
" \"message\": \"01000101420c0000000000000000000000000000\",",
" \"receiveName\": \"cis2-bridgeable.updateOperator\"",
" \"transactionType\": \"update\"",
" },",
" \"sender\": \"4jxvYasaPncfmCFCLZCvuL5cZuvR5HAQezCHZH7ZA7AGsRYpix\",",
" \"signature\": {",
" \"0\": {",
" \"0\": \"6f17c110965054b262ef0d6dee02f77dccb7bd031c2af324b544f5ee3e6e18b3fd1be8a95782e92a89dd40a1b69cad8a37e8b86fc9107c8528d8267212cf030b\"",
" }",
" },",
" \"version\": 1",
" }"
]

transactionDeployCredentialCmd :: Mod CommandFields TransactionCmd
transactionDeployCredentialCmd =
command
Expand Down Expand Up @@ -1431,7 +1517,7 @@ configAccountAddKeysCmd =
[ "Add one or several key pairs to a specific account configuration.",
"Expected format of the key file:"
]
++ expectedAddOrUpdateKeysFileFormat
++ expectedKeysFileFormat
)
)

Expand All @@ -1449,12 +1535,12 @@ configAccountUpdateKeysCmd =
[ "Update one or several key pairs to a specific account configuration.",
"Expected format of the key file:"
]
++ expectedAddOrUpdateKeysFileFormat
++ expectedKeysFileFormat
)
)

expectedAddOrUpdateKeysFileFormat :: [String]
expectedAddOrUpdateKeysFileFormat =
expectedKeysFileFormat :: [String]
expectedKeysFileFormat =
[ " {",
" \"cidx\": {",
" \"kidx\": {",
Expand Down
Loading

0 comments on commit be58014

Please sign in to comment.