Skip to content

Commit

Permalink
feature: Enable cuttlefish (#1011)
Browse files Browse the repository at this point in the history
## Summary
* Enables cuttlefish on testnets
* The Core API won't _panic_, but some of its substate models are still
incomplete.

The following will come in a follow-up PR:
* Fix `BootLoaderModuleFieldTransactionValidationConfiguration` substate
* Add some more Core API tests
* Add whether subintents were nullified to transaction receipts
* Add V2 Transaction Preview
* Add Subintent status

## Testing

Adds tests:
* `CuttlefishProtocolUpdateTest` in Java:
  * `transaction_v2_behaviour_across_cuttlefish`
  * `protocol_update_process_updates_status_summary`
* `TransactionSubmitTest` in Java:
* `test_core_api_can_submit_and_commit_transaction_v2_after_cuttlefish`
  • Loading branch information
dhedey authored Nov 5, 2024
2 parents e918e6f + c0e1920 commit f67e4b5
Show file tree
Hide file tree
Showing 316 changed files with 12,006 additions and 993 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ RUN apt-get update \
wget=${WGET_VERSION} \
software-properties-common=0.99.30-4.1~deb12u1 \
&& apt-get install -y --no-install-recommends \
openjdk-17-jdk=17.0.12+7-2~deb12u1 \
openjdk-17-jdk=17.0.13+11-2~deb12u1 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
import com.radixdlt.sbor.codec.StructCodec;
import java.util.Objects;

public record PreparedIntent(byte[] intentBytes, IntentHash intentHash) {
public record PreparedIntent(byte[] intentBytes, TransactionIntentHash transactionIntentHash) {
public PreparedIntent {
Objects.requireNonNull(intentBytes);
Objects.requireNonNull(intentHash);
Objects.requireNonNull(transactionIntentHash);
}

public static void registerCodec(CodecMap codecMap) {
Expand All @@ -82,7 +82,7 @@ public static void registerCodec(CodecMap codecMap) {

@Override
public int hashCode() {
return Objects.hashCode(intentHash);
return Objects.hashCode(transactionIntentHash);
}

@Override
Expand All @@ -91,11 +91,11 @@ public boolean equals(Object o) {
return false;
}

return Objects.equals(this.intentHash, other.intentHash);
return Objects.equals(this.transactionIntentHash, other.transactionIntentHash);
}

public String hexIntentHash() {
return this.intentHash.hex();
return this.transactionIntentHash.hex();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@

public record PreparedNotarizedTransaction(
RawNotarizedTransaction raw,
IntentHash intentHash,
TransactionIntentHash transactionIntentHash,
SignedIntentHash signedIntentHash,
NotarizedTransactionHash notarizedTransactionHash) {
public PreparedNotarizedTransaction {
Objects.requireNonNull(raw);
Objects.requireNonNull(intentHash);
Objects.requireNonNull(transactionIntentHash);
Objects.requireNonNull(signedIntentHash);
Objects.requireNonNull(notarizedTransactionHash);
}
Expand Down Expand Up @@ -108,7 +108,7 @@ public String toString() {
}

public String hexIntentHash() {
return this.intentHash.hex();
return this.transactionIntentHash.hex();
}

public String hexNotarizedTransactionHash() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@
import java.util.Objects;

public record PreparedSignedIntent(
byte[] signedIntentBytes, IntentHash intentHash, SignedIntentHash signedIntentHash) {
byte[] signedIntentBytes,
TransactionIntentHash transactionIntentHash,
SignedIntentHash signedIntentHash) {
public PreparedSignedIntent {
Objects.requireNonNull(signedIntentBytes);
Objects.requireNonNull(intentHash);
Objects.requireNonNull(transactionIntentHash);
Objects.requireNonNull(signedIntentHash);
}

Expand All @@ -83,7 +85,7 @@ public static void registerCodec(CodecMap codecMap) {
}

public String hexIntentHash() {
return this.intentHash.hex();
return this.transactionIntentHash.hex();
}

public String hexSignedIntentHash() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
*
* radixfoundation.org/licenses/LICENSE-v1
*
* The Licensor hereby grants permission for the Canonical version of the Work to be
* published, distributed and used under or by reference to the Licensor’s trademark
* Radix ® and use of any unregistered trade names, logos or get-up.
*
* The Licensor provides the Work (and each Contributor provides its Contributions) on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
*
* Whilst the Work is capable of being deployed, used and adopted (instantiated) to create
* a distributed ledger it is your responsibility to test and validate the code, together
* with all logic and performance of that code under all foreseeable scenarios.
*
* The Licensor does not make or purport to make and hereby excludes liability for all
* and any representation, warranty or undertaking in any form whatsoever, whether express
* or implied, to any entity or person, including any representation, warranty or
* undertaking, as to the functionality security use, value or other characteristics of
* any distributed ledger nor in respect the functioning or value of any tokens which may
* be created stored or transferred using the Work. The Licensor does not warrant that the
* Work or any use of the Work complies with any law or regulation in any territory where
* it may be implemented or used or that it will be appropriate for any specific purpose.
*
* Neither the licensor nor any current or former employees, officers, directors, partners,
* trustees, representatives, agents, advisors, contractors, or volunteers of the Licensor
* shall be liable for any direct or indirect, special, incidental, consequential or other
* losses of any kind, in tort, contract or otherwise (including but not limited to loss
* of revenue, income or profits, or loss of use or data, or loss of reputation, or loss
* of any economic or other opportunity of whatsoever nature or howsoever arising), arising
* out of or in connection with (without limitation of any use, misuse, of any ledger system
* or use made or its functionality or any performance or operation of any code or protocol
* caused by bugs or programming or logic errors or otherwise);
*
* A. any offer, purchase, holding, use, sale, exchange or transmission of any
* cryptographic keys, tokens or assets created, exchanged, stored or arising from any
* interaction with the Work;
*
* B. any failure in a transmission or loss of any token or assets keys or other digital
* artefacts due to errors in transmission;
*
* C. bugs, hacks, logic errors or faults in the Work or any communication;
*
* D. system software or apparatus including but not limited to losses caused by errors
* in holding or transmitting tokens by any third-party;
*
* E. breaches or failure of security including hacker attacks, loss or disclosure of
* password, loss of private key, unauthorised use or misuse of such passwords or keys;
*
* F. any losses including loss of anticipated savings or other benefits resulting from
* use of the Work or any changes to the Work (however implemented).
*
* You are solely responsible for; testing, validating and evaluation of all operation
* logic, functionality, security and appropriateness of using the Work for any commercial
* or non-commercial purpose and for any reproduction or redistribution by You of the
* Work. You assume all risks associated with Your use of the Work and the exercise of
* permissions under this License.
*/

package com.radixdlt.transactions;

import com.google.common.collect.ImmutableList;
import com.radixdlt.sbor.codec.CodecMap;
import com.radixdlt.sbor.codec.StructCodec;
import java.util.Objects;

public record PreparedTransactionIntentV2(
byte[] transactionIntentBytes,
TransactionIntentHash transactionIntentHash,
ImmutableList<SubintentHash> subintentHashes) {
public PreparedTransactionIntentV2 {
Objects.requireNonNull(transactionIntentBytes);
Objects.requireNonNull(transactionIntentHash);
Objects.requireNonNull(subintentHashes);
}

public static void registerCodec(CodecMap codecMap) {
codecMap.register(
PreparedTransactionIntentV2.class,
codecs -> StructCodec.fromRecordComponents(PreparedTransactionIntentV2.class, codecs));
}

@Override
public int hashCode() {
return Objects.hashCode(transactionIntentHash);
}

@Override
public boolean equals(Object o) {
if (!(o instanceof PreparedTransactionIntentV2 other)) {
return false;
}

return Objects.equals(this.transactionIntentHash, other.transactionIntentHash);
}

public String hexIntentHash() {
return this.transactionIntentHash.hex();
}

@Override
public String toString() {
return String.format(
"%s{intentHash=%s}", this.getClass().getSimpleName(), this.hexIntentHash());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,17 @@
import com.radixdlt.utils.Bytes;
import java.util.Objects;

public record IntentHash(HashCode inner) {
public IntentHash {
public record SubintentHash(HashCode inner) {
public SubintentHash {
Objects.requireNonNull(inner);
}

public static void registerCodec(CodecMap codecMap) {
codecMap.register(
IntentHash.class,
SubintentHash.class,
codecs ->
StructCodec.transparent(IntentHash::new, codecs.of(HashCode.class), IntentHash::inner));
StructCodec.transparent(
SubintentHash::new, codecs.of(HashCode.class), SubintentHash::inner));
}

public String hex() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
*
* radixfoundation.org/licenses/LICENSE-v1
*
* The Licensor hereby grants permission for the Canonical version of the Work to be
* published, distributed and used under or by reference to the Licensor’s trademark
* Radix ® and use of any unregistered trade names, logos or get-up.
*
* The Licensor provides the Work (and each Contributor provides its Contributions) on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
*
* Whilst the Work is capable of being deployed, used and adopted (instantiated) to create
* a distributed ledger it is your responsibility to test and validate the code, together
* with all logic and performance of that code under all foreseeable scenarios.
*
* The Licensor does not make or purport to make and hereby excludes liability for all
* and any representation, warranty or undertaking in any form whatsoever, whether express
* or implied, to any entity or person, including any representation, warranty or
* undertaking, as to the functionality security use, value or other characteristics of
* any distributed ledger nor in respect the functioning or value of any tokens which may
* be created stored or transferred using the Work. The Licensor does not warrant that the
* Work or any use of the Work complies with any law or regulation in any territory where
* it may be implemented or used or that it will be appropriate for any specific purpose.
*
* Neither the licensor nor any current or former employees, officers, directors, partners,
* trustees, representatives, agents, advisors, contractors, or volunteers of the Licensor
* shall be liable for any direct or indirect, special, incidental, consequential or other
* losses of any kind, in tort, contract or otherwise (including but not limited to loss
* of revenue, income or profits, or loss of use or data, or loss of reputation, or loss
* of any economic or other opportunity of whatsoever nature or howsoever arising), arising
* out of or in connection with (without limitation of any use, misuse, of any ledger system
* or use made or its functionality or any performance or operation of any code or protocol
* caused by bugs or programming or logic errors or otherwise);
*
* A. any offer, purchase, holding, use, sale, exchange or transmission of any
* cryptographic keys, tokens or assets created, exchanged, stored or arising from any
* interaction with the Work;
*
* B. any failure in a transmission or loss of any token or assets keys or other digital
* artefacts due to errors in transmission;
*
* C. bugs, hacks, logic errors or faults in the Work or any communication;
*
* D. system software or apparatus including but not limited to losses caused by errors
* in holding or transmitting tokens by any third-party;
*
* E. breaches or failure of security including hacker attacks, loss or disclosure of
* password, loss of private key, unauthorised use or misuse of such passwords or keys;
*
* F. any losses including loss of anticipated savings or other benefits resulting from
* use of the Work or any changes to the Work (however implemented).
*
* You are solely responsible for; testing, validating and evaluation of all operation
* logic, functionality, security and appropriateness of using the Work for any commercial
* or non-commercial purpose and for any reproduction or redistribution by You of the
* Work. You assume all risks associated with Your use of the Work and the exercise of
* permissions under this License.
*/

package com.radixdlt.transactions;

import com.google.common.hash.HashCode;
import com.radixdlt.sbor.codec.CodecMap;
import com.radixdlt.sbor.codec.StructCodec;
import com.radixdlt.utils.Bytes;
import java.util.Objects;

public record TransactionIntentHash(HashCode inner) {
public TransactionIntentHash {
Objects.requireNonNull(inner);
}

public static void registerCodec(CodecMap codecMap) {
codecMap.register(
TransactionIntentHash.class,
codecs ->
StructCodec.transparent(
TransactionIntentHash::new,
codecs.of(HashCode.class),
TransactionIntentHash::inner));
}

public String hex() {
return Bytes.toHexString(this.inner.asBytes());
}

@Override
public String toString() {
return this.hex();
}
}
Loading

0 comments on commit f67e4b5

Please sign in to comment.