-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #294 from /issues/279
Issues/279 - BlockV2
- Loading branch information
Showing
34 changed files
with
704 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/usr/bin/env bash | ||
# run the cspr-nctl container in docker | ||
docker run --rm -it --name cspr-nctl -d -p 25101:25101 -p 11101:11101 -p 14101:14101 -p 18101:18101 stormeye2000/cspr-nctl:linux-1.5.5 | ||
docker run --rm -it --name cspr-nctl-condor -d -p 25101:25101 -p 11101:11101 -p 14101:14101 -p 18101:18101 casper-nctl:feat-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,5 +51,4 @@ public class AuctionState { | |
*/ | ||
@JsonProperty("state_root_hash") | ||
private String stateRootHash; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.casper.sdk.model.block; | ||
|
||
import com.casper.sdk.model.common.Digest; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
/** | ||
* Abstract base class for all block versions. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = BlockV1.class, name = "Version1"), | ||
@JsonSubTypes.Type(value = BlockV2.class, name = "Version2")}) | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
public abstract class Block<HeaderT extends BlockHeader, BodyT extends BlockBody> { | ||
|
||
@JsonProperty("hash") | ||
private Digest hash; | ||
|
||
public abstract HeaderT getHeader(); | ||
|
||
public abstract BodyT getBody(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.casper.sdk.model.block; | ||
|
||
import com.casper.sdk.model.common.Digest; | ||
import com.casper.sdk.model.key.PublicKey; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** | ||
* Abstract class for block body. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@Setter | ||
public abstract class BlockBody { | ||
|
||
/** @see PublicKey */ | ||
@JsonProperty("proposer") | ||
private PublicKey proposer; | ||
|
||
/** The body's hash. */ | ||
@JsonProperty("hash") | ||
private Digest hash; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.casper.sdk.model.block; | ||
|
||
import com.casper.sdk.model.common.Digest; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A JSON-friendly representation of `Body` | ||
* | ||
* @author Alexandre Carvalho | ||
* @author Andre Bertolace | ||
* @see BlockV1 | ||
* @since 0.0.1 | ||
*/ | ||
@Getter | ||
@Setter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class BlockBodyV1 extends BlockBody { | ||
|
||
/** List of Hex-encoded hash digest */ | ||
@JsonProperty("deploy_hashes") | ||
private List<Digest> deployHashes; | ||
|
||
/** List of Hex-encoded hash digest */ | ||
@JsonProperty("transfer_hashes") | ||
private List<Digest> transferHashes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.casper.sdk.model.block; | ||
|
||
import com.casper.sdk.model.common.Digest; | ||
import com.casper.sdk.model.transaction.TransactionCategory; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* V2 of the block body | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@Setter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class BlockBodyV2 extends BlockBody { | ||
|
||
/** List of Hex-encoded hash digest */ | ||
@JsonProperty("deploy_hashes") | ||
private List<Digest> deployHashes; | ||
|
||
/** List of Hex-encoded hash digest */ | ||
@JsonProperty("transfer_hashes") | ||
private List<Digest> transferHashes; | ||
|
||
@JsonProperty("rewarded_signatures") | ||
private List<List<Long>> rewardedSignatures; | ||
|
||
@JsonProperty("transactions") | ||
private Map<TransactionCategory, List<Digest>> transactions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.casper.sdk.model.block; | ||
|
||
import com.casper.sdk.model.common.Digest; | ||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* Abstract class for block header. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@Setter | ||
public abstract class BlockHeader { | ||
|
||
@JsonProperty("parent_hash") | ||
private Digest parentHash; | ||
|
||
@JsonProperty("state_root_hash") | ||
private Digest stateRootHash; | ||
|
||
@JsonProperty("body_hash") | ||
private Digest bodyHash; | ||
|
||
@JsonProperty("random_bit") | ||
private boolean randomBit; | ||
|
||
@JsonProperty("height") | ||
private long height; | ||
|
||
@JsonProperty("accumulated_seed") | ||
private Digest accumulatedSeed; | ||
|
||
/** Era ID newtype */ | ||
@JsonProperty("era_id") | ||
private long eraId; | ||
|
||
/** Timestamp formatted as per RFC 3339 */ | ||
@JsonProperty("timestamp") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") | ||
private Date timeStamp; | ||
|
||
/** Casper Platform protocol version */ | ||
@JsonProperty("protocol_version") | ||
private String protocolVersion; | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
src/main/java/com/casper/sdk/model/block/BlockHeaderV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.casper.sdk.model.block; | ||
|
||
import com.casper.sdk.model.common.Digest; | ||
import com.casper.sdk.model.era.EraEndV2; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
|
||
/** | ||
* V2 Block header. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@Setter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class BlockHeaderV2 extends BlockHeader { | ||
|
||
@JsonProperty("era_end") | ||
private EraEndV2 eraEnd; | ||
|
||
@JsonProperty("proposer") | ||
private Digest proposer; | ||
|
||
@JsonProperty("current_gas_price") | ||
private long currentGasPrice; | ||
|
||
@JsonProperty("last_switch_block_hash") | ||
private Digest lastSwitchBlockHash; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.casper.sdk.model.block; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
|
||
/** | ||
* V2 Block | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@Setter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class BlockV2 extends Block<BlockHeaderV2, BlockBodyV2> { | ||
|
||
@JsonProperty("header") | ||
private BlockHeaderV2 header; | ||
|
||
@JsonProperty("body") | ||
private BlockBodyV2 body; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/casper/sdk/model/block/BlockWithSignatures.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.casper.sdk.model.block; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.*; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Block and its associated signatures. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@Getter | ||
@Setter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class BlockWithSignatures { | ||
|
||
@JsonProperty("block") | ||
private Block<?, ?> block; | ||
|
||
@JsonProperty("proofs") | ||
private List<JsonProof> proofs; | ||
|
||
public <BlockT extends Block<?, ?>> BlockT getBlock() { | ||
//noinspection unchecked | ||
return (BlockT) block; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/casper/sdk/model/block/ChainGetBlockResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.casper.sdk.model.block; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* The response for a V2 chain_get_block RPC request. | ||
* | ||
* @author [email protected] | ||
*/ | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
public class ChainGetBlockResponse { | ||
|
||
@JsonProperty("api_version") | ||
private String apiVersion; | ||
|
||
@JsonProperty("block_with_signatures") | ||
private BlockWithSignatures blockWithSignatures; | ||
} |
Oops, something went wrong.