Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove init-genesis-state command #5504

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/horizon/cmd/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ var ingestBuildStateCmd = &cobra.Command{
}

mngr := historyarchive.NewCheckpointManager(globalConfig.CheckpointFrequency)
if !mngr.IsCheckpoint(ingestBuildStateSequence) && ingestBuildStateSequence != 1 {
if !mngr.IsCheckpoint(ingestBuildStateSequence) {
return fmt.Errorf("`--sequence` must be a checkpoint ledger")
}

Expand Down
3 changes: 0 additions & 3 deletions services/horizon/internal/ingest/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ func (b buildState) run(s *system) (transition, error) {

// We don't need to prepare range for genesis checkpoint because we don't
// perform protocol version and bucket list hash checks.
karthikiyer56 marked this conversation as resolved.
Show resolved Hide resolved
// In the long term we should probably create artificial xdr.LedgerCloseMeta
// for ledger #1 instead of using `ingest.GenesisChange` reader in
// ProcessorRunner.RunHistoryArchiveIngestion().
// We can also skip preparing range if `skipChecks` is `true` because we
// won't need bucket list hash and protocol version.
karthikiyer56 marked this conversation as resolved.
Show resolved Hide resolved
var protocolVersion uint32
Expand Down
41 changes: 37 additions & 4 deletions services/horizon/internal/ingest/processor_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ingest
import (
"context"
"fmt"
"github.com/stellar/go/amount"
"io"
"reflect"
"testing"
Expand All @@ -29,14 +30,33 @@ func TestProcessorRunnerRunHistoryArchiveIngestionHistoryArchive(t *testing.T) {
q := &mockDBQ{}
defer mock.AssertExpectationsForObjects(t, q)
historyAdapter := &mockHistoryArchiveAdapter{}
defer mock.AssertExpectationsForObjects(t, historyAdapter)
defer mock.AssertExpectationsForObjects(t, historyAdapter) // this will fail

m := &ingest.MockChangeReader{}
m.On("Read").Return(ingest.Change{}, io.EOF).Once()
m.On("Close").Return(nil).Once()
bucketListHash := xdr.Hash([32]byte{0, 1, 2})
m.On("VerifyBucketList", bucketListHash).Return(nil).Once()

changeEntry := ingest.Change{
Type: xdr.LedgerEntryTypeAccount,
Post: &xdr.LedgerEntry{
LastModifiedLedgerSeq: 1,
Data: xdr.LedgerEntryData{
Type: xdr.LedgerEntryTypeAccount,
Account: &xdr.AccountEntry{
// Master account address from Ledger 1
AccountId: xdr.MustAddress("GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7"),
// 100B
Balance: amount.MustParse("100000000000"),
SeqNum: 0,
Thresholds: xdr.Thresholds{1, 0, 0, 0},
},
},
},
}
m.On("Read").Return(changeEntry, nil).Once()
m.On("Read").Return(ingest.Change{}, io.EOF).Once()

historyAdapter.
On("GetState", ctx, uint32(63)).
Return(
Expand All @@ -45,10 +65,23 @@ func TestProcessorRunnerRunHistoryArchiveIngestionHistoryArchive(t *testing.T) {
).Once()

batchBuilders := mockChangeProcessorBatchBuilders(q, ctx, true)
defer mock.AssertExpectationsForObjects(t, batchBuilders...)
defer mock.AssertExpectationsForObjects(t, batchBuilders...) // currently failing

assert.IsType(t, &history.MockAccountSignersBatchInsertBuilder{}, batchBuilders[0])
assert.IsType(t, &history.MockAccountsBatchInsertBuilder{}, batchBuilders[1])
batchBuilders[1].(*history.MockAccountsBatchInsertBuilder).On("Add", history.AccountEntry{
LastModifiedLedger: 1,
AccountID: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7",
Balance: int64(1000000000000000000),
SequenceNumber: 0,
MasterWeight: 1,
}).Return(nil).Once()

assert.IsType(t, &history.MockAccountSignersBatchInsertBuilder{}, batchBuilders[0])
batchBuilders[0].(*history.MockAccountSignersBatchInsertBuilder).On("Add", history.AccountSigner{
Account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7",
Signer: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7",
Weight: 1,
}).Return(nil).Once()

q.MockQAssetStats.On("InsertAssetStats", ctx, []history.ExpAssetStat{}, 100000).
Return(nil)
Expand Down
Loading