Skip to content

Commit

Permalink
fixup! feat(db): Add Epoch and Snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Aug 9, 2024
1 parent fae1d6d commit 0e93cbd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion internal/evmreader/evmreader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ func newMockRepository() *MockRepository {
Index: 0,
FirstBlock: 0,
LastBlock: math.MaxUint64,
Status: model.EpochStatusReceivingInputs,
Status: model.EpochStatusOpen,
AppAddress: common.HexToAddress("0x2E663fe9aE92275242406A185AA4fC8174339D3E"),
ClaimHash: nil,
TransactionHash: nil,
Expand Down
12 changes: 6 additions & 6 deletions internal/node/model/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ const (
)

const (
EpochStatusReceivingInputs EpochStatus = "RECEIVING_INPUTS"
EpochStatusReceivedLastInput EpochStatus = "RECEIVED_LAST_INPUT"
EpochStatusOpen EpochStatus = "OPEN"
EpochStatusClosed EpochStatus = "CLOSED"
EpochStatusProcessedAllInputs EpochStatus = "PROCESSED_ALL_INPUTS"
EpochStatusCalculatedClaim EpochStatus = "CALCULATED_CLAIM"
EpochStatusSubmittedClaim EpochStatus = "SUBMITTED_CLAIM"
EpochStatusAcceptedClaim EpochStatus = "ACCEPTED_CLAIM"
EpochStatusRejectedClaim EpochStatus = "REJECTED_CLAIM"
EpochStatusClaimComputed EpochStatus = "CLAIM_COMPUTED"
EpochStatusClaimSubmitted EpochStatus = "CLAIM_SUBMITTED"
EpochStatusClaimAccepted EpochStatus = "CLAIM_ACCEPTED"
EpochStatusClaimRejected EpochStatus = "CLAIM_REJECTED"
)

type NodePersistentConfig struct {
Expand Down
10 changes: 5 additions & 5 deletions internal/repository/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *RepositorySuite) SetupDatabase() {
AppAddress: app.ContractAddress,
ClaimHash: nil,
TransactionHash: nil,
Status: EpochStatusReceivingInputs,
Status: EpochStatusOpen,
}

_, err = s.database.InsertEpoch(s.ctx, &epoch1)
Expand All @@ -113,7 +113,7 @@ func (s *RepositorySuite) SetupDatabase() {
AppAddress: app.ContractAddress,
ClaimHash: nil,
TransactionHash: nil,
Status: EpochStatusReceivingInputs,
Status: EpochStatusOpen,
}

_, err = s.database.InsertEpoch(s.ctx, &epoch2)
Expand Down Expand Up @@ -403,7 +403,7 @@ func (s *RepositorySuite) TestEpochExists() {

epoch := Epoch{
Id: 1,
Status: EpochStatusReceivingInputs,
Status: EpochStatusOpen,
Index: 0,
FirstBlock: 0,
LastBlock: (math.MaxUint64 / 2),
Expand All @@ -425,7 +425,7 @@ func (s *RepositorySuite) TestEpochDoesntExist() {

func (s *RepositorySuite) TestEpochFailsDuplicateRow() {
epoch := Epoch{
Status: EpochStatusReceivingInputs,
Status: EpochStatusOpen,
Index: 0,
FirstBlock: 0,
LastBlock: math.MaxUint64,
Expand All @@ -441,7 +441,7 @@ func (s *RepositorySuite) TestEpochFailsDuplicateRow() {
func (s *RepositorySuite) TestEpochFailsApplicationDoesntExist() {
hash := common.HexToHash("deadbeef")
epoch := Epoch{
Status: EpochStatusReceivingInputs,
Status: EpochStatusOpen,
Index: 2,
FirstBlock: 0,
LastBlock: math.MaxUint64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TYPE "InputCompletionStatus" AS ENUM ('NONE', 'ACCEPTED', 'REJECTED', 'EX

CREATE TYPE "DefaultBlock" AS ENUM ('FINALIZED', 'LATEST', 'PENDING', 'SAFE');

CREATE TYPE "EpochStatus" AS ENUM ('RECEIVING_INPUTS', 'RECEIVED_LAST_INPUT', 'PROCESSED_ALL_INPUTS', 'CALCULATED_CLAIM', 'SUBMITTED_CLAIM', 'ACCEPTED_CLAIM', 'REJECTED_CLAIM');
CREATE TYPE "EpochStatus" AS ENUM ('OPEN', 'CLOSED', 'PROCESSED_ALL_INPUTS', 'CLAIM_COMPUTED', 'CLAIM_SUBMITTED', 'CLAIM_ACCEPTED', 'CLAIM_REJECTED');

CREATE FUNCTION public.f_maxuint64()
RETURNS NUMERIC(20,0)
Expand Down
2 changes: 1 addition & 1 deletion internal/repository/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (pg *Database) SetEpochClaimAndInsertProofsTransaction(
args := pgx.NamedArgs{
"id": epoch.Id,
"claimHash": epoch.ClaimHash,
"status": EpochStatusCalculatedClaim,
"status": EpochStatusClaimComputed,
}

tx, err := pg.db.Begin(ctx)
Expand Down
6 changes: 3 additions & 3 deletions internal/repository/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ func (s *RepositorySuite) TestSetEpochClaimAndInsertProofsTransaction() {
s.Require().Nil(err)

expectedEpoch.ClaimHash = &hash
expectedEpoch.Status = EpochStatusCalculatedClaim
expectedEpoch.Status = EpochStatusClaimComputed

epoch, err := s.database.GetEpoch(s.ctx, 0, common.HexToAddress("deadbeef"))
s.Require().Nil(err)

epoch.ClaimHash = &hash
epoch.Status = EpochStatusCalculatedClaim
epoch.Status = EpochStatusClaimComputed

var outputs []Output
outputs = append(outputs, output)
Expand Down Expand Up @@ -110,7 +110,7 @@ func (s *RepositorySuite) TestSetEpochClaimAndInsertProofsTransactionRollback()
s.Require().Nil(err)

epoch.ClaimHash = &hash
epoch.Status = EpochStatusCalculatedClaim
epoch.Status = EpochStatusClaimComputed

expectedEpoch, err := s.database.GetEpoch(s.ctx, epoch.Index, common.HexToAddress("deadbeef"))
s.Require().Nil(err)
Expand Down

0 comments on commit 0e93cbd

Please sign in to comment.