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 968c971
Show file tree
Hide file tree
Showing 13 changed files with 360 additions and 298 deletions.
6 changes: 6 additions & 0 deletions call_get_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/bash

curl http://127.0.0.1:8545 \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getCode","params": ["0xA1b8EB1F13d8D5Db976a653BbDF8972cfD14691C", "0x10"],"id":1}'
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
1 change: 0 additions & 1 deletion docs/cli/cartesi-rollups-cli_app_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ cartesi-rollups-cli app add -a 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -n 10

```
-a, --address string Application contract address
-e, --epoch-length uint Application epoch length in blocks (default 1)
-h, --help help for add
-n, --inputbox-block-number uint InputBox deployment block number
-u, --snapshot-uri string Application snapshot URI
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 968c971

Please sign in to comment.