Commit Graph

206 Commits

Author SHA1 Message Date
Mike Hearn
701fc853ad Refactor the core transaction types to improve clarity, simplify verification and prepare for sandboxing.
Changes include:
- LedgerTransaction is now much more central: it represents a fully resolved and looked-up tx, with the inputs available.
- TransactionGroup and TransactionForVerification are gone. There is a temporary TransactionForContract class for backwards
  compatibility but it will also be gone soon.
- ResolveTransactionsProtocol is simplified, and now commits a tx to the database as soon as it's determined to be valid.
- ServiceHub is now passed in more consistently to verification code, so we can use more services in future more easily e.g. a sandboxing service.
- A variety of APIs have been tweaked or documented better.
2016-08-04 13:05:50 +02:00
Mike Hearn
ba05b90b8f Testing: change fillWithTestCash to issue cash under the DUMMY_CASH_ISSUER identity and adjust code that uses it. Introduce some code that'll prove useful later in WalletWithCashTest.
This change reduces the  testing confusion that can occur when cash is issued by one of the parties in a transaction rather than e.g. a neutral third party like a central bank.
2016-08-04 12:52:01 +02:00
Ross Nicoll
8539a7c9d3 Clean up contracts
* Merge common code between Cash and CommodityContract into OnLedgerAsset
* Move spend/exit tx generation logic into the clauses
* Add generateExit() function for Obligation
2016-08-03 17:29:55 +01:00
Mike Hearn
0662798b0f Introduce some new cryptographic utility functions
1. Function for converting raw entropy into an EDDSA key pair. This is useful for unit tests when you don't want a random key but would rather be able to identify it from the logs by eyesight, and will be useful later also when implementing deterministic key derivation.
2. Function that can format any collection of public keys using the bitcoin-style base58 form.
3. A dummy NullSignature object, again, useful for tests when you don't want to provide a real signature.

Then set a handful of dummy unit testing keys to predictable/fixed values.
2016-08-01 16:42:56 +02:00
Mike Hearn
b40fee1512 Allow for easier conversion from Amount<Issued<T>> to Amount<T> and de-issuerify a few places. 2016-08-01 16:42:56 +02:00
Ross Nicoll
a44d3edebf Correct obligationTestRoots to cashObligationTestRoots 2016-08-01 15:05:00 +01:00
Ross Nicoll
0ac29bec26 Merged in rnicoll-obligation-fungible (pull request #199)
Add commodities to provide worked example of a different thing under Obligation
2016-08-01 14:26:13 +01:00
Ross Nicoll
e1d1aed541 Add commodity contract and test obligations can be settled for it 2016-08-01 14:20:04 +01:00
Ross Nicoll
406196fb69 Add missing checks on settled amount
The obligation `Settle` command takes in an amount to be settled, but only uses the underlying token from it.
This enforces that the settled amount matches the value seen moving.
2016-08-01 14:19:07 +01:00
Clinton Alexander
7d39a101d4 Merged in COR-276 (pull request #239)
Added Jacoco code coverage to gradle.
2016-07-29 13:29:47 +01:00
Mike Hearn
5167ed7df2 Merged in mike-fix-irs (pull request #244)
Fix how the IRS contract uses fix commands
2016-07-28 10:19:16 +02:00
Clinton Alexander
188fc29436 Cleaned up build.gradle files. 2016-07-28 09:17:49 +01:00
Mike Hearn
1a9cdf992f Fix an issue in the IRS contract where it was expecting two different kinds of fix command simultaneously for apparently no good reason. The unit tests didn't spot that because the unit test wasn't actually verifying the constructed transactions: fix that too.
Uncovered during the tx types refactoring work.
2016-07-27 14:38:21 +02:00
Mike Hearn
62e91000e9 Minor: some minor tweaks to IRSUtils types 2016-07-27 14:37:32 +02:00
Mike Hearn
889b74ca9b Minor: apply some inspector and reformatting cleanups to IRS.kt 2016-07-27 11:17:00 +02:00
Andrius Dagys
2142bd1d8a Added Log4j bindings for SLF4J. Test log output is redirected to the console, and demo output is now additionally stored in a rolling log file. 2016-07-22 16:15:00 +01:00
Ross Nicoll
f25e19ed5e Add Cash.generateExit() function 2016-07-20 13:20:43 +01:00
Andrius Dagys
c442cd01a7 Merged in andrius-cleanup-tweaks (pull request #208)
Remove the "verify correct notary has signed" check from TwoParty protocols
2016-07-18 10:40:25 +01:00
Ross Nicoll
c32af56b41 Rebuild commercial paper contracts using clauses 2016-07-13 16:55:18 +01:00
Ross Nicoll
e03dd19979 Rebuild IRS contract using clauses 2016-07-13 16:15:01 +01:00
Ross Nicoll
49b58d8a43 Split IRS verification into individual functions 2016-07-13 13:19:51 +01:00
Ross Nicoll
cba3aab96e Rebuild asset contracts using clauses 2016-07-13 13:08:23 +01:00
Ross Nicoll
ea051d57be Move clauses into main 2016-07-13 11:48:51 +01:00
Mike Hearn
ead19c619a Merged in mike-cp-issuance-fix (pull request #224)
Disentangle the concept of CP issuer vs underlying redeemable asset issuer in the CP contract.
2016-07-13 11:13:23 +02:00
Ross Nicoll
15bc48b49b Minor: Add note about refactoring TwoPartyTradeProtocol 2016-07-12 18:42:36 +01:00
Mike Hearn
f6789c93dd Disentangle the concept of CP issuer vs underlying redeemable asset issuer in the CP contract.
This confusion was introduced by a previous refactoring.
2016-07-12 16:01:50 +02:00
Ross Nicoll
e09710e421 Update contract tutorial example to match JavaCommercialPaper 2016-07-12 14:48:50 +01:00
Ross Nicoll
52be94866a Use requireThat in JavaCommercialPaper
Replaces verification logic in JavaCommercialPaper, which previously manually
throw IllegalStateException, with calls to requireThat().
2016-07-12 14:24:50 +01:00
Ross Nicoll
79e3ce23f8 Tweak conditions on JavaCommercialPaper to match CommercialPaper 2016-07-12 14:24:50 +01:00
Ross Nicoll
0d78df33f8 Add standard clauses 2016-07-12 11:31:23 +01:00
Andras Slemmer
635da20fe2 contracts: Maybe we don't need a full stop there 2016-07-11 18:37:27 +01:00
Andras Slemmer
d7cc34c9a5 all: Full stops in comments! 2016-07-11 17:58:53 +01:00
Mike Hearn
e28ecae8c0 Address review comments 2016-07-11 18:47:24 +02:00
Mike Hearn
41d092a169 Minor: optimize imports 2016-07-11 18:15:28 +02:00
Mike Hearn
6b7580c977 Minor: fix compiler warnings. 2016-07-11 18:15:28 +02:00
Mike Hearn
cc22810b09 Testing cleanup:
- Move code out of ambiguously named TestUtils files (there were three). Sometimes it's simpler to just put these things into the contract source files directly.
- Remove JavaTestHelpers objects (there were three), in favour of just giving the top level kotlin file class better names.
- Misc other small tweaks and cleanups.
2016-07-11 16:22:02 +02:00
Ross Nicoll
6b775ebd4d Replace named timestamping authority with notary
As the timestamping authority is now always the notary service, contracts should
no longer be using name-based lookup of the timestamping authority (as this will
generally be wrong). This introduces a new "timestamp" property on a transaction,
and updates most contracts to refer to it.

In some cases (IRS, CommercialPaper) there are transactions with no input states
to derive notary from, that use timestamps. In these cases a notary is specified
in the command.
2016-07-11 14:54:36 +01:00
Andras Slemmer
4324e33fea testdsl: Removed R type parameter, unify verifies() interface 2016-07-11 14:25:27 +01:00
Andras Slemmer
fb55ceeb79 contracts: Remove Tmp* files 2016-07-11 14:25:27 +01:00
Andras Slemmer
9bb8439dc3 testdsl: Add failsWith to Ledger 2016-07-11 14:25:27 +01:00
Andras Slemmer
cd0299f650 testdsl: Javadoc comments 2016-07-11 14:25:27 +01:00
Andras Slemmer
3d885eb928 testdsl: Clean up TestUtils.kt 2016-07-11 14:25:27 +01:00
Ross Nicoll
0404ef4f62 Standardise error messages regarding state issuance
This makes the error messages when verifying state issuance consistent between
Cash, CommercialPaper and Obligation contracts, in preparation for introducing
a common issue clause between the contracts.
2016-07-11 11:32:36 +01:00
Ross Nicoll
7655356ec2 Minor: Remove unneeded backquotes 2016-07-11 11:32:34 +01:00
Ross Nicoll
ae1d3e96b1 Extend obligation tests to cover input lifecycle checks 2016-07-11 11:30:36 +01:00
Andrius Dagys
b498928f75 Remove the "verify correct notary has signed" check. This is no longed necessary as the required notary key is added to the "signers" list during transaction construction. We have general validation rules that check the correct notary was included in the signers list, and that we have signatures for all "signers". 2016-07-07 13:22:30 +01:00
Mike Hearn
bbc5c2e981 Merged in mike-july-dependency-upgrades (pull request #200)
Upgrade dependencies, July edition.
2016-07-06 16:25:52 +01:00
Mike Hearn
9e849378cf Minor: add some assertions in the WalletFiller code after a test was observed to fail due to a negative amount. 2016-07-06 14:02:40 +01:00
Mike Hearn
6fb7e59b91 Upgrade dependencies, July edition. 2016-07-06 13:56:22 +01:00
Andras Slemmer
0cf54d1c1f test dsl: Comment full stops 2016-07-06 13:25:08 +01:00
Andras Slemmer
f177b1ffaa test dsl: LastLineShouldTestForVerifiesOrFails->EnforceVerifyOrFail 2016-07-06 13:25:08 +01:00
Andras Slemmer
e31b769fef test dsl: Dsl->DSL, add top-level transaction primitive, add ledger-embedded signAll, other cosmetics 2016-07-06 13:25:08 +01:00
Andras Slemmer
e3d6f51049 contracts, core, node: Port TransactionForTest tests to new DSL 2016-07-06 13:25:08 +01:00
Andras Slemmer
bdda3d239a contracts: Port Java CashTests to new DSL 2016-07-06 13:25:08 +01:00
Andras Slemmer
7634331f68 contracts: Port CashTests to new dsl 2016-07-06 13:25:08 +01:00
Andras Slemmer
f4a6a43aa6 contracts, core: Port CommercialPaperTests, IRSTests, ObligationTests, TransactioGroupTests 2016-07-06 13:25:08 +01:00
Andras Slemmer
cde315aca9 contracts, node: Port CommercialPaperTests, TwoPartyTradeProtocolTests and GroupToGraphConversion to use new dsl 2016-07-06 13:25:08 +01:00
Shams Asari
5c0e7fbbf2 Moved topic parameter from send/receive methods to a ProtocolLogic property 2016-07-05 15:12:25 +01:00
Ross Nicoll
2121824662 Rename com.r3cord.contracts.cash package to ...asset 2016-06-30 13:31:59 +01:00
Ross Nicoll
6dad7efa22 Replace references to cash, with (fungible) asset 2016-06-30 12:47:18 +01:00
Shams Asari
a02263937c send and sendAndReceive use Party for the destination 2016-06-30 12:04:39 +01:00
rick.parker
5271882dcd Event scheduling and docs for event scheduling 2016-06-30 08:51:52 +01:00
Ross Nicoll
c767638127 Move DummyContract.State into its own file
DummyContract.State isn't actually used by the DummyContract any more, so shouldn't
be part of that contract class.
2016-06-29 17:16:46 +01:00
Ross Nicoll
dc304199c8 Remove warnings from Obligation contract 2016-06-29 13:27:00 +01:00
Ross Nicoll
228513671d Move Obligation contract into contracts module 2016-06-27 17:54:04 +01:00
Ross Nicoll
9994d129f2 General cleanup based on first round of feedback
* Rename AggregateCommands to IssuanceCommands
 * Reorder comparisons to be consistent
 * Rename verifyDefaultCommand to verifySetLifecycleCommand
 * Rename currency to issued/product
 * Add note about needing to rethink timestamping
 * Rename issuer to obligor, and owner to beneficiary
 * Move lifecycle inversion code into SetLifecycle command
 * Correct comments regarding cash states
 * Rework description of contractHash parameter
 * Fixes 'netting equal balances due between parties', and add further netting tests
 * Separate calculations involving issued products and the underlying product
 * Use signed transactions in obligation tests
 * Add verification tests for changing lifecycle
2016-06-27 17:49:52 +01:00
Andras Slemmer
bc326660a3 contracts, core: Fix static init cycle issue of JavaTestHelpers 2016-06-24 16:37:43 +01:00
Andras Slemmer
341adafd3a contracts, core: Rename Java to JavaTestHelpers 2016-06-24 16:37:43 +01:00
Andras Slemmer
040e51ec12 contracts, core: Expose top-level DSL values/functions to Java by wrapping them in an object
core: Add overloads for convenient Java interop

contracts, core: Uniform Java interop for tests, use camelCase
2016-06-24 16:37:43 +01:00
Andras Slemmer
28e85923a3 core: Add CashTestsJava.java, containing some of CashTests.kt in Java 2016-06-24 16:37:43 +01:00
Mike Hearn
2dfcff1f31 Testing: Fix the wallet filler code. 2016-06-24 17:13:27 +02:00
Andrius Dagys
aaeb99ac25 Validating notary: check for missing signatures. The notary can only sign if all other signatures are present
Please enter the commit message for your changes. Lines starting
2016-06-23 16:15:14 +01:00
Ross Nicoll
d24ec06b40 Add netting support structures
Add NetType enum for use in contracts which deal with netting
Add BilateralNettingState interface
Add support for more complex issued things
2016-06-22 14:30:06 +01:00
Mike Hearn
7ee6bd05ce Refactor the wallet code:
- Rename NodeWalletService to InMemoryWalletService and move into the core module where it's available for unit testing.
- Make a new NodeWalletService that just inherits from InMemoryWalletService and doesn't customise it at all, for now.
- Take the cash specific functionality out of Wallet and into an extension property in the Cash contract (this compiles as CashKt.getCashBalance(wallet) for java users).
- Return the generated states in the fillWalletWithTestCash function.
2016-06-22 14:49:52 +02:00
Mike Hearn
f3d4639059 Testing: make the WalletFiller code a file-level singleton and fillTestWithCash an extension method. For Java users not much changes, the class is still called WalletFiller and the signature remains the same. Re-order some arguments to make it easier to use when accepting the defaults. 2016-06-22 14:49:52 +02:00
Mike Hearn
cdb3e2f126 Minor: move WalletFiller from node.testing to contracts.testing 2016-06-22 14:49:52 +02:00
Mike Hearn
a16ae677ed Minor: fix some inspector warnings in IRSTests 2016-06-22 13:46:57 +02:00
Mike Hearn
749949669f Minor: Make a few class field names and constructor layouts more consistent. 2016-06-22 13:46:57 +02:00
Mike Hearn
5a3c9caffd Minor: Remove some unused parameters in a unit test utility method 2016-06-22 13:46:57 +02:00
Richard Green
6b80530ac6 Changed DateOffset to be an integer instead of enum. Usages and examples also changed. Also renamed to fixingPeriodOffset
Renamed fixingPeriod -> fixingPeriodOffset in the .json files
2016-06-21 18:17:39 +01:00
Ross Nicoll
723e610dfc Rename verifyMoveCommand()
Rename verifyMoveCommands() to verifyMoveCommand() to represent that move commands must
be singular within a transaction.
2016-06-20 16:08:16 +01:00
Ross Nicoll
af53a52b06 Add common Issue and Move commands
* Add common Issue command to encourage presence of a nonce value when issuing state objects.
* Add common Move command for contracts which support being moved in order to fulfil other contracts.
2016-06-20 16:08:16 +01:00
Andras Slemmer
a2e6e78b16 contracts: Remove warnings 2016-06-20 14:16:13 +01:00
Andras Slemmer
c9cb024bb5 Merged in use-urandom-2 (pull request #166)
Use urandom 3
2016-06-20 14:15:03 +01:00
Andras Slemmer
a7419b116d Add newSecureRandom() that uses a non-blocking SecureRandom provider on Linux 2016-06-20 14:11:03 +01:00
Andrius Dagys
30ca340b6e Refactored NotaryChangeProtocol and tests: moved the proposal verification step into the protocol.
Added another proposal verification step in the NotaryChangeProtocol.
Added the cause exception message to the 'notary change refused' error.
2016-06-17 15:05:35 +01:00
Andrius Dagys
0a5b7ace35 Made TransactionBuilder abstract. Every transaction type now needs to implement and provide its own Builder. This is required since for specific types we need to run different logic when adding new items to the transaction. For example, when adding a new input state to a transaction of type NotaryChange we need to add all of the states participants to the signers list. 2016-06-17 15:05:35 +01:00
Andrius Dagys
9958b5c603 Added 'signers' property to the transaction data models. Signers holds the list of all public keys that need to be signed for (command keys and additional ones such as notary).
Removed Notary & ChangeNotary commands, keys to be signed for are added to the signers list during transaction build phase.
2016-06-17 15:05:35 +01:00
Andrius Dagys
70495a021e Introduce TransactionState, which wraps ContractState and holds the notary pointer.
Remove notary from ContractState.
Introduce TransactionType, which specifies custom validation logic for a transaction.
2016-06-17 15:05:35 +01:00
Andrius Dagys
3b1e020082 Extended the data model so that every state has to define a set of 'participants' - parties that are able to consume that state in a valid transaction.
Added protocol for changing the notary for a state, which requires signatures from all participants
2016-06-17 15:05:35 +01:00
Andras Slemmer
0c325c31a2 Revert "Merged in use-urandom-2 (pull request #159)"
This reverts commit 1a1ed3b9e6, reversing
changes made to 09e2e49d44.
2016-06-17 14:12:19 +01:00
Andras Slemmer
1a1ed3b9e6 Merged in use-urandom-2 (pull request #159)
Use /dev/urandom try no.2
2016-06-17 13:36:23 +01:00
Andras Slemmer
9ec1ec786f contracts: remove TODO 2016-06-17 13:27:35 +01:00
Andras Slemmer
a72bab0fb7 contracts: make test compile 2016-06-17 13:27:35 +01:00
Andras Slemmer
906c100c29 contracts: use newSecureRandom() instead of SecureRandom.getInstanceStrong() 2016-06-17 13:07:25 +01:00
Ross Nicoll
ad72f3e48f Add issuer to cash amounts
Add issuer of a cash when referring to amounts of cash (except for the very few cases where
the issuer is not important, such as when referring to aggregated totals across a set of
issuers). Replaces CommonCashState with TokenDefinition, as a more accurate reflection of
what the class represents.
2016-06-16 15:05:49 +01:00
Ross Nicoll
eae3efdf02 Minor: Edit reference after copying amount
Edit reference after copying amount in cash tests, so that when the amount includes
a reference, the copying doesn't replace the changed reference.
2016-06-16 15:04:33 +01:00
Shams Asari
860353c4d4 Initial checkpoint when protocol is first added 2016-06-16 09:54:49 +01:00
Ross Nicoll
f831ffdf3d Add tests for TransactionGraphSearch 2016-06-15 16:21:53 +01:00
Clinton Alexander
7e15445ee9 Removed the CrowdFund contract since it is written in a style that is not typical of Corda contracts. 2016-06-15 12:32:36 +01:00