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

Algod: support state proofs recoverability #4803

Merged
merged 125 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 113 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
598705d
Persist StateProof builders on disk (#4553)
Aharonee Oct 23, 2022
fae555c
State Proof Recoverability: state proof verification tracking (#4570)
almog-t Oct 23, 2022
9ebdbce
fix tests: use better function for waiting
Oct 23, 2022
7f11ab3
Algod: state-proof key deletion safety (#4601)
algonathan Oct 26, 2022
3bac343
merged with avm box changes to master
Nov 2, 2022
e734ed7
fixed tracker db version
Nov 2, 2022
dc631d2
fixed lint error
Nov 2, 2022
194b7ac
updated msgp_gen
Nov 2, 2022
7d55071
built with latest dev tools
Nov 2, 2022
13c0fb4
fixed comment typo
Nov 2, 2022
311bc30
added missing dot
Nov 2, 2022
e569879
Merge pull request #4735 from almog-t/merge-recoverability-master
id-ms Nov 2, 2022
0bd34b8
StateProofs: Use stateproof tracker (#4733)
id-ms Nov 6, 2022
2005611
CR: shorter names for verification data in dcc
Nov 7, 2022
8845eb4
CR: renamed non db insert to append
Nov 7, 2022
a4dae19
renamed mutex
Nov 7, 2022
ec8dda1
CR: now using db queries pointer
Nov 7, 2022
788b50f
CR: using nested struct in tracker.go
Nov 7, 2022
02edfdf
renamed TargetRound to LastAttestedRound
Nov 7, 2022
f9cc17f
fixed potential segfault
Nov 7, 2022
4e01f81
renamed stateProofVerificationData to SPVerificationContext
Nov 8, 2022
2a6bc73
renamed internal stateproofverification struct to spVerification
Nov 8, 2022
30dd781
another rename for stateproofverificationcontext
Nov 8, 2022
e70d7d8
refactored deletion data usage
Nov 8, 2022
f000773
full renamed of stateproofverificationdata to stateproofverificationc…
Nov 8, 2022
eefc0f9
ran msgp again
Nov 8, 2022
f4456ef
stateproofround -> lastattestedround
Nov 9, 2022
c9dd1af
more stateproofround -> lastattestedroun
Nov 9, 2022
478d94c
CR: various renamings
Nov 9, 2022
687258f
StateProofs: Sp verification-tracker last lookup cache (#4780)
algonathan Nov 10, 2022
af27896
merged and renamed relevant variables in feature branch
Nov 10, 2022
f6959af
CR: shortened dcc variables
Nov 13, 2022
e0432f4
Merge pull request #4769 from almog-t/spv-tracking-cr-fixes
almog-t Nov 13, 2022
30de42d
Merge branch 'master' into merge-sp-recovery-with-master
Nov 15, 2022
056719b
Merge pull request #4793 from algoidan/merge-sp-recovery-with-master
id-ms Nov 15, 2022
8180823
StateProofs: Limit builders memory usage and reduce StateProofs signa…
Aharonee Nov 16, 2022
7409b73
Merge branch 'master' into merge-sp-recovery-with-master
Nov 16, 2022
7a2c94d
Merge pull request #4801 from algoidan/merge-sp-recovery-with-master
id-ms Nov 16, 2022
e6ed9eb
make state proof unit-tests synced
Nov 20, 2022
6dd8f40
remove printf
Nov 20, 2022
a85fcda
fix state proof message tests
Nov 20, 2022
75f6ac5
test cache limit on sig handler.
Nov 21, 2022
3a6982e
remove panic from test
Nov 21, 2022
1722455
fix race problem
Nov 21, 2022
d65a96b
refactor AllSigs test
Nov 21, 2022
50f009f
reduce log spamming
Nov 21, 2022
c9bd815
add signature broadcast test
Nov 21, 2022
9c7bf73
Revert "reduce log spamming"
Nov 21, 2022
1b35e37
handling mem issue
Nov 21, 2022
ae2b236
fix Broadcast test
Nov 21, 2022
4726d1d
reduce memory consumption in tests
Nov 22, 2022
d337e8a
CR fixed
Nov 23, 2022
7b9b68e
test builder cache context
Dec 4, 2022
7c8bce1
Merge pull request #4817 from algoidan/sp-recovery-test-refactor
id-ms Dec 4, 2022
d661705
Stateproof Recoverability: verification tracking catchpoint support (…
almog-t Dec 5, 2022
88d857e
fix merge issues
Dec 5, 2022
eab1fff
moving stateproofverification tracker's sql function into a file.
Dec 5, 2022
1e4544d
some refactoring
Dec 6, 2022
2ba5c97
refactoring
Dec 6, 2022
43a72f0
Merge pull request #4863 from algoidan/merge-sp-recoverability-from-m…
id-ms Dec 6, 2022
e5d48e4
merge with master
Dec 11, 2022
ebc6ef2
Merge pull request #4888 from algoidan/merge-sp-recoverability-from-m…
id-ms Dec 11, 2022
3c004a5
Fix catchup stateproof race (#4887)
almog-t Dec 27, 2022
0f58463
merge changes from master
Dec 27, 2022
b1905b4
Merge pull request #4950 from algoidan/merge-sp-recvoery-with-master
id-ms Dec 27, 2022
fe354d8
Apply StateProof transactions on catchup (#4949)
Aharonee Dec 29, 2022
8278b53
StateProofs: Fix CR comments (#4958)
id-ms Jan 1, 2023
42caa30
merge with master
Jan 2, 2023
b3fc3f5
Merge pull request #4959 from algoidan/merge-sp-recoverability-with-m…
id-ms Jan 2, 2023
c1ad50c
Fix flaky unit test
Aharonee Jan 2, 2023
40f1168
Merge branch 'master' into merge-sp-recoverbility-with-master
Jan 15, 2023
9f18d39
Merge pull request #5020 from algoidan/merge-sp-recoverbility-with-ma…
id-ms Jan 15, 2023
7e6d874
Add recoverability catchpoint e2e (#4961)
almog-t Jan 16, 2023
98d5a4f
Refactor insertSigToBuilder and handleSig, avoid unused allocations (…
Aharonee Jan 18, 2023
cd7c667
StateProof Recoverability: Fix CR comments (#5030)
id-ms Jan 19, 2023
816449f
change sp interval in short tests (#5081)
id-ms Jan 31, 2023
ede87b2
fix broken nightly tests
Jan 31, 2023
96d9c3b
merge with master
Jan 31, 2023
57ba79b
refactor sp tracker to support new store
Feb 1, 2023
2272129
use prepare statement
Feb 1, 2023
5b899b6
Merge pull request #5086 from algoidan/merge-sp-recvoerability-with-m…
id-ms Feb 1, 2023
4be1ecb
changed RLock to Lock to properly protect lastFlushTime writes (#5092)
almog-t Feb 1, 2023
1c25270
ledger: eternalData trackers concept
algorandskiy Feb 1, 2023
0ad0943
stateproof: e2e flakey-test AttestorsChange (#5101)
algonathan Feb 2, 2023
827365e
StateProof recoverability CR fixes (#5085)
id-ms Feb 2, 2023
4a2f579
CR fixes
algorandskiy Feb 2, 2023
295177c
Merge remote-tracking branch 'upstream/feature/stateproofs-recoverabi…
algorandskiy Feb 2, 2023
493a5f8
Merge pull request #5099 from algorandskiy/pavel/sp-recov
almog-t Feb 2, 2023
62b0c02
Revert "ledger: eternalData trackers concept" (#5104)
algorandskiy Feb 2, 2023
618736a
Fix metrics test
algorandskiy Feb 2, 2023
c90be81
Merge pull request #5106 from algorandskiy/pavel/sp-recov-test
almog-t Feb 2, 2023
8f8f6f1
Remove unused function to fetch message from db and small refactor
Aharonee Feb 5, 2023
d8ccde8
Fix errors tests log (#5117)
almog-t Feb 6, 2023
e331404
Inline sigExists and builderExists methods
Aharonee Jan 18, 2023
760c231
Stop stateproof worker on catchpoint cathcup and restart when done. (…
Aharonee Feb 16, 2023
f97766a
Merge branch 'master' into spr-merge-with-master
Feb 16, 2023
28c1313
Merge pull request #5144 from algoidan/spr-merge-with-master
id-ms Feb 16, 2023
4b8854b
StateProofRecoverability: fix comments (#5143)
id-ms Feb 16, 2023
f5e16e8
Merge remote-tracking branch 'upstream/master' into feature/stateproo…
algorandskiy Feb 17, 2023
6e2f233
post merge fixes:
algorandskiy Feb 17, 2023
9efe32c
fix lint
algorandskiy Feb 17, 2023
22b3125
Fix exceed partitiontest call
algorandskiy Feb 18, 2023
ecbcc8e
fix flaky test
Feb 19, 2023
ab7a68b
code review: fix interface names as suggested
algorandskiy Feb 21, 2023
8201750
Merge pull master (#5148)
algorandskiy Feb 21, 2023
da1d70f
fix linter in ledger_test.go
algorandskiy Feb 21, 2023
f19a285
StateProof Recvoerability: CR fixes (#5153)
id-ms Feb 24, 2023
52c8bcb
Merge remote-tracking branch 'upstream/master' into feature/stateproo…
algorandskiy Feb 27, 2023
d229775
merge master into feature/stateproofs-recoverability
algorandskiy Feb 27, 2023
0d0697a
Do not stop stateproof service in fast catchup mode (#5170)
algorandskiy Mar 1, 2023
0bc8014
Merge branch 'master' into merge-spr-with-master
Mar 7, 2023
7a2714f
Merge pull request #5179 from algoidan/merge-spr-with-master
id-ms Mar 7, 2023
3d303b0
fix flaky test
Mar 8, 2023
3c831df
CR fixes (#5176)
id-ms Mar 13, 2023
8d31459
Merge remote-tracking branch 'upstream/master' into pavel/stateproofs…
algorandskiy Mar 13, 2023
56cd05b
Merge remote-tracking branch 'upstream/master' into pavel/stateproofs…
algorandskiy Mar 13, 2023
389b8ac
Linter fixes
algorandskiy Mar 13, 2023
4f12cb6
Merge master (#5199)
algorandskiy Mar 13, 2023
c659a1d
Update log message
Aharonee Mar 16, 2023
6e4b414
Add a second mutex to stateproof.Worker to allow more granular locking.
Aharonee Mar 20, 2023
150efa2
convert to rw lock and fix linter error.
Mar 20, 2023
30da8b6
update comments.
Mar 23, 2023
8bf459b
using verification ctx from tracker when creating stats
Mar 29, 2023
fdbe4e5
Merge branch 'master' into merge-sp-recoverability-from-master
Mar 30, 2023
cd7dbcc
Merge pull request #5241 from algoidan/merge-sp-recoverability-from-m…
id-ms Mar 30, 2023
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
4 changes: 2 additions & 2 deletions catchup/catchpointService.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"sync"
"time"

"github.com/algorand/go-algorand/stateproof"

"github.com/algorand/go-deadlock"

"github.com/algorand/go-algorand/config"
Expand All @@ -33,6 +31,7 @@ import (
"github.com/algorand/go-algorand/ledger/ledgercore"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/network"
"github.com/algorand/go-algorand/stateproof"
)

const (
Expand Down Expand Up @@ -259,6 +258,7 @@ func (cs *CatchpointCatchupService) processStageInactive() (err error) {
if err != nil {
return cs.abort(fmt.Errorf("processStageInactive failed to set a catchpoint label : %v", err))
}

err = cs.updateStage(ledger.CatchpointCatchupStateLedgerDownload)
if err != nil {
return cs.abort(fmt.Errorf("processStageInactive failed to update stage : %v", err))
Expand Down
55 changes: 55 additions & 0 deletions cmd/catchpointdump/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package main

import (
"bufio"
"context"
"database/sql"
"fmt"
Expand Down Expand Up @@ -63,6 +64,13 @@ var databaseCmd = &cobra.Command{
}
defer outFile.Close()
}

var version uint64
version, err = getVersion(ledgerTrackerFilename, ledgerTrackerStaging)
if err != nil {
reportErrorf("Unable to read version : %v", err)
}
printDbVersion(ledgerTrackerStaging, version, outFile)
err = printAccountsDatabase(ledgerTrackerFilename, ledgerTrackerStaging, ledger.CatchpointFileHeader{}, outFile, nil)
if err != nil {
reportErrorf("Unable to print account database : %v", err)
Expand All @@ -71,9 +79,56 @@ var databaseCmd = &cobra.Command{
if err != nil {
reportErrorf("Unable to print key value store : %v", err)
}
// state proof verification can be found on tracker db version >= 10 or
// catchpoint file version >= 7 (i.e staging tables)
if !ledgerTrackerStaging && version < 10 || ledgerTrackerStaging && version < ledger.CatchpointFileVersionV7 {
return
}
err = printStateProofVerificationContext(ledgerTrackerFilename, ledgerTrackerStaging, outFile)
if err != nil {
reportErrorf("Unable to print state proof verification database : %v", err)
}
},
}

func printDbVersion(staging bool, version uint64, outFile *os.File) {
fileWriter := bufio.NewWriterSize(outFile, 1024*1024)
defer fileWriter.Flush()

if staging {
fmt.Fprintf(outFile, "Catchpoint version: %d \n", version)
} else {
fmt.Fprintf(outFile, "Ledger db version: %d \n", version)
}
}

func getVersion(filename string, staging bool) (uint64, error) {
dbAccessor, err := db.MakeAccessor(filename, true, false)
if err != nil || dbAccessor.Handle == nil {
return 0, err
}
defer dbAccessor.Close()
var version uint64
err = dbAccessor.Atomic(func(ctx context.Context, tx *sql.Tx) (err error) {
if staging {
// writing the version of the catchpoint file start only on ver >= CatchpointFileVersionV7.
// in case the catchpoint version does not exists ReadCatchpointStateUint64 returns 0
cw := sqlitedriver.NewCatchpointSQLReaderWriter(tx)
version, err = cw.ReadCatchpointStateUint64(ctx, trackerdb.CatchpointStateCatchupVersion)
return err
}

versionAsInt32, err := db.GetUserVersion(ctx, tx)
version = uint64(versionAsInt32)
return err
})
if err != nil {
return 0, err
}

return version, nil
}

var checkCmd = &cobra.Command{
Use: "check",
Short: "Performs a consistency checking on the accounts merkle trie",
Expand Down
43 changes: 41 additions & 2 deletions cmd/catchpointdump/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (

var catchpointFile string
var outFileName string
var excludedFields *cmdutil.CobraStringSliceValue = cmdutil.MakeCobraStringSliceValue(nil, []string{"version", "catchpoint"})
var excludedFields = cmdutil.MakeCobraStringSliceValue(nil, []string{"version", "catchpoint"})

func init() {
fileCmd.Flags().StringVarP(&catchpointFile, "tar", "t", "", "Specify the catchpoint file (either .tar or .tar.gz) to process")
Expand Down Expand Up @@ -127,7 +127,6 @@ var fileCmd = &cobra.Command{
}
defer outFile.Close()
}

err = printAccountsDatabase("./ledger.tracker.sqlite", true, fileHeader, outFile, excludedFields.GetSlice())
if err != nil {
reportErrorf("Unable to print account database : %v", err)
Expand All @@ -136,6 +135,10 @@ var fileCmd = &cobra.Command{
if err != nil {
reportErrorf("Unable to print key value store : %v", err)
}
err = printStateProofVerificationContext("./ledger.tracker.sqlite", true, outFile)
if err != nil {
reportErrorf("Unable to print state proof verification database : %v", err)
}
}
},
}
Expand Down Expand Up @@ -434,6 +437,42 @@ func printAccountsDatabase(databaseName string, stagingTables bool, fileHeader l
})
}

func printStateProofVerificationContext(databaseName string, stagingTables bool, outFile *os.File) error {
fileWriter := bufio.NewWriterSize(outFile, 1024*1024)
defer fileWriter.Flush()

dbAccessor, err := db.MakeAccessor(databaseName, true, false)
if err != nil || dbAccessor.Handle == nil {
return err
}
defer dbAccessor.Close()

var stateProofVerificationContext []ledgercore.StateProofVerificationContext
err = dbAccessor.Atomic(func(ctx context.Context, tx *sql.Tx) (err error) {
if stagingTables {
stateProofVerificationContext, err = sqlitedriver.MakeStateProofVerificationReader(tx).GetAllSPContextsFromCatchpointTbl(ctx)
} else {
stateProofVerificationContext, err = sqlitedriver.MakeStateProofVerificationReader(tx).GetAllSPContexts(ctx)
}
return err
})

if err != nil {
return err
}

fmt.Fprintf(fileWriter, "State Proof Verification Data:\n")
for _, ctx := range stateProofVerificationContext {
jsonData, err := json.Marshal(ctx)
if err != nil {
return err
}
fmt.Fprintf(fileWriter, "%d : %s\n", ctx.LastAttestedRound, string(jsonData))
}

return nil
}

func printKeyValue(writer *bufio.Writer, key, value []byte) {
var pretty string
ai, rest, err := apps.SplitBoxKey(string(key))
Expand Down
4 changes: 4 additions & 0 deletions cmd/catchpointdump/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ func loadAndDump(addr string, tarFile string, genesisInitState ledgercore.InitSt
if err != nil {
return err
}
err = printStateProofVerificationContext("./ledger.tracker.sqlite", true, outFile)
if err != nil {
return err
}

}
return nil
Expand Down
4 changes: 4 additions & 0 deletions cmd/tealdbg/localLedger.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ func (l *localLedger) BlockHdrCached(basics.Round) (bookkeeping.BlockHeader, err
return bookkeeping.BlockHeader{}, nil
}

func (l *localLedger) GetStateProofVerificationContext(_ basics.Round) (*ledgercore.StateProofVerificationContext, error) {
return nil, fmt.Errorf("localLedger: GetStateProofVerificationContext, needed for state proof verification, is not implemented in debugger")
}

func (l *localLedger) CheckDup(config.ConsensusParams, basics.Round, basics.Round, basics.Round, transactions.Txid, ledgercore.Txlease) error {
return nil
}
Expand Down
11 changes: 11 additions & 0 deletions config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,14 @@ type ConsensusParams struct {
// EnablePrecheckECDSACurve means that ecdsa_verify opcode will bail early,
// returning false, if pubkey is not on the curve.
EnablePrecheckECDSACurve bool

// StateProofUseTrackerVerification specifies whether the node will use data from state proof verification tracker
// in order to verify state proofs.
StateProofUseTrackerVerification bool

// EnableCatchpointsWithSPContexts specifies when to re-enable version 7 catchpoints.
// Version 7 includes state proof verification contexts
EnableCatchpointsWithSPContexts bool
}

// PaysetCommitType enumerates possible ways for the block header to commit to
Expand Down Expand Up @@ -1255,6 +1263,9 @@ func initConsensusProtocols() {
vFuture.LogicSigVersion = 9 // When moving this to a release, put a new higher LogicSigVersion here
vFuture.EnablePrecheckECDSACurve = true

vFuture.StateProofUseTrackerVerification = true
vFuture.EnableCatchpointsWithSPContexts = true

Consensus[protocol.ConsensusFuture] = vFuture

// vAlphaX versions are an separate series of consensus parameters and versions for alphanet
Expand Down
Loading