Skip to content

Commit

Permalink
stashing
Browse files Browse the repository at this point in the history
  • Loading branch information
badgersrus committed Mar 7, 2024
1 parent 64f11bc commit 7009263
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
3 changes: 0 additions & 3 deletions go/common/storage/database/migration/db_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ func CommonDBMigration(db *sql.DB, sqlFiles embed.FS, logger gethlog.Logger) err
return err
}

println("Migration files ", migrationFiles)
maxMigration := int64(len(migrationFiles))

var maxDB int64
config, err := database.FetchConfig(db, currentMigrationVersionKey)
println("config ", config)
if err != nil {
// first time there is no entry, so 001 was executed already ( triggered at launch/manifest time )
if errors.Is(err, errutil.ErrNotFound) {
Expand Down Expand Up @@ -84,7 +82,6 @@ func readMigrationFiles(sqlFiles embed.FS) ([]fs.DirEntry, error) {
return nil, err
}

println("HERE")
// sort the migrationFiles based on the prefix (before "_")
sort.Slice(migrationFiles, func(i, j int) bool {
// Extract the number prefix and compare
Expand Down
2 changes: 1 addition & 1 deletion go/host/enclave/guardian.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ func (g *Guardian) processL1BlockTransactions(block *common.L1Block) {
g.logger.Error("Could not fetch rollup metadata from enclave.", log.ErrKey, err)
}
err = hostdb.AddRollupHeader(g.db, r, metaData, block)
println("ROLLUP DATA start time", metaData.StartTime)
println("ROLLUP DATA First batch", metaData.FirstBatchSequence.String())
println("ROLLUP DATA Last batch", r.Header.LastBatchSeqNo)
//FIXME need to store this data?
//err = hostdb.AddBlock(g.db, block, r.Header.Hash())
if err != nil {
Expand Down
16 changes: 10 additions & 6 deletions go/host/storage/hostdb/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ const (

// AddBatch adds a batch and its header to the DB
func AddBatch(db *sql.DB, batch *common.ExtBatch) error {
// Start a transaction
tx, err := db.Begin()
if err != nil {
return err
}
// Check if the Batch is already stored
_, err := GetBatchBySequenceNumber(db, batch.Header.SequencerOrderNo.Uint64())
_, err = GetBatchBySequenceNumber(db, batch.Header.SequencerOrderNo.Uint64())
if err == nil {
println("DUPLICATE BATCH SEQ", batch.Header.SequencerOrderNo.String())
return errutil.ErrAlreadyExists
}
// Encode batch data
println("[SQL] Adding batch with seq number: ", batch.SeqNo().Uint64())
batchBodyID := batch.SeqNo().Uint64()
body, err := rlp.EncodeToBytes(batch.EncryptedTxBlob)
if err != nil {
Expand All @@ -57,10 +60,9 @@ func AddBatch(db *sql.DB, batch *common.ExtBatch) error {

_, err = GetBatchBodyBySequenceNumber(db, batch.Header.SequencerOrderNo.Uint64())
if err == nil {
println("DUPLICATE BATCH BODY", batch.Header.SequencerOrderNo.String())
return errutil.ErrAlreadyExists
}
_, err = db.Exec(insertBatchBody, batchBodyID, body)
_, err = tx.Exec(insertBatchBody, batchBodyID, body)
if err != nil {
return fmt.Errorf("failed to insert body: %w", err)
}
Expand Down Expand Up @@ -317,7 +319,9 @@ func fetchPublicBatch(db *sql.DB, whereQuery string, args ...any) (*common.Publi
// Fetch batch_body from the database
var encryptedTxBlob common.EncryptedTransactions
encryptedTxBlob, err = fetchBatchBody(db, bodyID)
if err != nil { return nil, fmt.Errorf("failed to fetch batch body: %w", err) }
if err != nil {
return nil, fmt.Errorf("failed to fetch batch body: %w", err)
}

// Construct the batch
batch := &common.PublicBatch{
Expand Down
2 changes: 1 addition & 1 deletion integration/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func PrefundWallets(ctx context.Context, faucetWallet wallet.Wallet, faucetClien
txHashes := make([]gethcommon.Hash, len(wallets))
for idx, w := range wallets {
destAddr := w.Address()
fmt.Printf("L2 prefund: %s\n", destAddr.Hex())
fmt.Printf("L2 prefund: %s\n", destAddr.String())
txData := &types.LegacyTx{
Nonce: startingNonce + uint64(idx),
Value: alloc,
Expand Down
2 changes: 0 additions & 2 deletions integration/noderunner/in_memory_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ func (d *InMemNode) Start() error {

err := d.startEnclave()
if err != nil {
println("ENCLAVE ERROR")
return err
}

err = d.startHost()
if err != nil {
println("HOST ERROR")
return err
}

Expand Down

0 comments on commit 7009263

Please sign in to comment.