Skip to content

Commit

Permalink
feat(database): Add Epoch and Snapshot tables
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Aug 1, 2024
1 parent 511af30 commit 42f5266
Show file tree
Hide file tree
Showing 11 changed files with 324 additions and 282 deletions.
11 changes: 0 additions & 11 deletions cmd/cartesi-rollups-cli/root/app/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var (
templateHash string
inputBoxDeploymentBlockNumber uint64
snapshotUri string
epochLength uint64
status string
)

Expand Down Expand Up @@ -72,14 +71,6 @@ func init() {
"Application snapshot URI",
)

Cmd.Flags().Uint64VarP(
&epochLength,
"epoch-length",
"e",
1,
"Application epoch length in blocks",
)

Cmd.Flags().StringVarP(
&status,
"status",
Expand Down Expand Up @@ -113,8 +104,6 @@ func run(cmd *cobra.Command, args []string) {
ContractAddress: common.HexToAddress(applicationAddress),
TemplateHash: common.HexToHash(templateHash),
LastProcessedBlock: inputBoxDeploymentBlockNumber,
SnapshotURI: snapshotUri,
EpochLength: epochLength,
Status: applicationStatus,
}

Expand Down
54 changes: 38 additions & 16 deletions internal/node/model/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ type (
Hash = common.Hash
Address = common.Address
InputCompletionStatus string
ClaimStatus string
ApplicationStatus string
DefaultBlock string
EpochStatus string
// ClaimStatus string
ApplicationStatus string
DefaultBlock string
)

const (
Expand All @@ -29,11 +30,21 @@ const (
)

const (
ClaimStatusPending ClaimStatus = "PENDING"
ClaimStatusSubmitted ClaimStatus = "SUBMITTED"
ClaimStatusFinalized ClaimStatus = "FINALIZED"
EpochStatusReceivingInputs EpochStatus = "RECEIVING_INPUTS"
EpochStatusReceivedLastInput EpochStatus = "RECEIVED_LAST_INPUT"
EpochStatusProcessedAllInputs EpochStatus = "PROCESSED_ALL_INPUTS"
EpochStatusCalculatedClaim EpochStatus = "CALCULATED_CLAIM"
EpochStatusSubmittedClaim EpochStatus = "SUBMITTED_CLAIM"
EpochStatusAcceptedClaim EpochStatus = "ACCEPTED_CLAIM"
EpochStatusRejectedClaim EpochStatus = "REJECTED_CLAIM"
)

// const (
// ClaimStatusPending ClaimStatus = "PENDING"
// ClaimStatusSubmitted ClaimStatus = "SUBMITTED"
// ClaimStatusFinalized ClaimStatus = "FINALIZED"
// )

const (
ApplicationStatusRunning ApplicationStatus = "RUNNING"
ApplicationStatusNotRunning ApplicationStatus = "NOT RUNNING"
Expand All @@ -52,18 +63,28 @@ type NodePersistentConfig struct {
InputBoxAddress Address
ChainId uint64
IConsensusAddress Address
EpochLength uint64
}

type Application struct {
Id uint64
ContractAddress Address
TemplateHash Hash
SnapshotURI string
LastProcessedBlock uint64
EpochLength uint64
Status ApplicationStatus
}

type Epoch struct {
Id uint64
AppAddress Address
Index uint64
FirstBlock uint64
LastBlock uint64
ClaimHash *Hash
TransactionHash *Hash
Status EpochStatus
}

type Input struct {
Id uint64
Index uint64
Expand All @@ -73,6 +94,7 @@ type Input struct {
MachineHash *Hash
OutputsHash *Hash
AppAddress Address
EpochId uint64
}

type Output struct {
Expand All @@ -91,11 +113,11 @@ type Report struct {
InputId uint64
}

type Claim struct {
Id uint64
Index uint64
Status ClaimStatus
OutputMerkleRootHash Hash
TransactionHash *Hash
AppAddress Address
}
// type Claim struct {
// Id uint64
// Index uint64
// Status ClaimStatus
// OutputMerkleRootHash Hash
// TransactionHash *Hash
// AppAddress Address
// }
Loading

0 comments on commit 42f5266

Please sign in to comment.