Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 24 additions & 0 deletions solana/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func (node *Node) bootObserver(ctx context.Context, version string) {
panic(err)
}

node.fixFailedCall(ctx)

go node.initializeUsersLoop(ctx)
go node.deployOrConfirmAssetsLoop(ctx)

Expand All @@ -72,6 +74,28 @@ func (node *Node) bootObserver(ctx context.Context, version string) {
go node.notificationLoop(ctx)
}

func (node *Node) fixFailedCall(ctx context.Context) {
logger.Printf("observer.fixFailedCall()")
callId := "035d4b18-451d-336c-abf1-ee9909f4e931"
hash := "2BwfEFLQBv9QUXVNRRCKUTx69nM8jpzt2WR4JssMHjFvGt2tHtAzktZXi74T8vWNULF3gkDdcAoMi2xonxUTC5zN"
call, err := node.store.ReadSystemCallByRequestId(ctx, callId, 0)
if err != nil || call == nil {
panic(fmt.Errorf("store.ReadSystemCallByRequestId(%s) => %v %v", callId, call, err))
}
rpcTx, err := node.RPCGetTransaction(ctx, hash)
if err != nil || rpcTx == nil {
panic(fmt.Errorf("solana.RPCGetTransaction(%s) => %v %v", hash, rpcTx, err))
}
tx, err := rpcTx.Transaction.GetTransaction()
if err != nil {
panic(err)
}
err = node.processSuccessedCall(ctx, call, tx, rpcTx.Meta, []solana.Signature{solana.MustSignatureFromBase58(hash)})
if err != nil {
panic(err)
}
}

func (node *Node) initMPCKeys(ctx context.Context) error {
for {
count, err := node.store.CountKeys(ctx)
Expand Down
10 changes: 6 additions & 4 deletions store/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package store
import (
"context"
"database/sql"
"fmt"
"time"

"github.com/MixinNetwork/safe/common"
Expand All @@ -18,19 +19,20 @@ func (s *SQLite3Store) Migrate(ctx context.Context) error {
}
defer common.Rollback(tx)

key, val := "SCHEMA:VERSION:REFUND_TRACES", ""
key, val := "SCHEMA:VERSION:FAILED_BURN", ""
row := tx.QueryRowContext(ctx, "SELECT value FROM properties WHERE key=?", key)
err = row.Scan(&val)
if err == nil || err != sql.ErrNoRows {
return err
}
now := time.Now().UTC()

query := "ALTER TABLE system_calls ADD COLUMN refund_traces VARCHAR;"
_, err = tx.ExecContext(ctx, query)
query := "UPDATE system_calls SET state=?, WHERE id=? AND state=?"
_, err = tx.ExecContext(ctx, query, common.RequestStatePending, "035d4b18-451d-336c-abf1-ee9909f4e931", common.RequestStateFailed)
if err != nil {
return err
return fmt.Errorf("SQLite3Store UPDATE system_calls %v", err)
}

_, err = tx.ExecContext(ctx, "INSERT INTO properties (key, value, created_at, updated_at) VALUES (?, ?, ?, ?)", key, query, now, now)
if err != nil {
return err
Expand Down
Loading