Skip to content

Commit

Permalink
all: remove ProcessArchive support
Browse files Browse the repository at this point in the history
  • Loading branch information
altergui authored and p4u committed Jun 16, 2024
1 parent 0696d74 commit 8db2a08
Show file tree
Hide file tree
Showing 23 changed files with 19 additions and 809 deletions.
32 changes: 9 additions & 23 deletions api/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,41 +160,27 @@ func (a *API) accountHandler(_ *apirest.APIdata, ctx *httprouter.HTTPContext) er
}
return accMetadata
}

if acc == nil {
return ErrAccountNotFound.With(addr.Hex())
}

accMetadata := getAccountMetadata()

// take the last word of the URL path to determine the type of request
// if the last word is "metadata" then return only the account metadata
// otherwise return the full account information
if strings.HasSuffix(ctx.Request.URL.Path, "/metadata") {
// If the account does not exist in state, try to retrieve it from the indexer.
// This is a fallback for the case where the account is not in state but it is in the process archive.
// We only return this information if the query is for the "metadata" endpoint.
var data []byte
if acc == nil {
indexerEntities := a.indexer.EntityList(1, 0, hex.EncodeToString(addr.Bytes()))
if len(indexerEntities) == 0 {
return ErrAccountNotFound.With(addr.Hex())
}
if data, err = json.Marshal(AccountMetadata{
Name: LanguageString{"default": addr.Hex()},
}); err != nil {
return err
}
return ctx.Send(data, apirest.HTTPstatusOK)
}
accMetadata := getAccountMetadata()
if accMetadata == nil {
return ErrAccountNotFound.With(addr.Hex())
}
if data, err = json.Marshal(accMetadata); err != nil {
data, err := json.Marshal(accMetadata)
if err != nil {
return err
}
return ctx.Send(data, apirest.HTTPstatusOK)
}

if acc == nil {
return ErrAccountNotFound.With(addr.Hex())
}
accMetadata := getAccountMetadata()

sik, err := a.vocapp.State.SIKFromAddress(addr)
if err != nil && !errors.Is(err, state.ErrSIKNotFound) {
log.Warnf("unknown error getting SIK: %v", err)
Expand Down
1 change: 0 additions & 1 deletion api/api_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type ElectionSummary struct {
FinalResults bool `json:"finalResults"`
Results [][]*types.BigInt `json:"result,omitempty"`
ManuallyEnded bool `json:"manuallyEnded"`
FromArchive bool `json:"fromArchive"`
ChainID string `json:"chainId"`
}

Expand Down
1 change: 0 additions & 1 deletion api/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func (a *API) electionSummary(pi *indexertypes.Process) ElectionSummary {
VoteCount: pi.VoteCount,
ManuallyEnded: pi.ManuallyEnded,
ChainID: pi.ChainID,
FromArchive: pi.FromArchive,
}
}

Expand Down
25 changes: 1 addition & 24 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ func deprecatedFlagsFunc(_ *flag.FlagSet, name string) flag.NormalizedName {
return "vochainMinerTargetBlockTimeSeconds"
case "skipPreviousOffchainData":
return "vochainSkipPreviousOffchainData"
case "processArchive":
return "vochainProcessArchive"
case "processArchiveKey":
return "vochainProcessArchiveKey"
case "offChainDataDownload":
return "vochainOffChainDataDownload"
case "pprof":
Expand Down Expand Up @@ -163,7 +159,6 @@ func loadConfig() *config.Config {
"enable IPFS group synchronization using the given secret key")
flag.StringSlice("ipfsConnectPeers", []string{},
"use custom ipfsconnect peers/bootnodes for accessing the DHT (comma-separated)")
flag.String("archiveURL", types.ArchiveURL, "enable archive retrival from the given IPNS url (set \"none\" to disable)")

// vochain
flag.String("vochainP2PListen", "0.0.0.0:26656",
Expand Down Expand Up @@ -213,10 +208,6 @@ func loadConfig() *config.Config {
"vochain consensus block time target (in seconds)")
flag.Bool("vochainSkipPreviousOffchainData", false,
"if enabled the census downloader will import all existing census")
flag.Bool("vochainProcessArchive", false,
"enables the process archiver component")
flag.String("vochainProcessArchiveKey", "",
"IPFS base64 encoded private key for process archive IPNS")
flag.Bool("vochainOffChainDataDownload", true,
"enables the off-chain data downloader component")
flag.StringVar(&flagVochainCreateGenesis, "vochainCreateGenesis", "",
Expand Down Expand Up @@ -270,9 +261,6 @@ func loadConfig() *config.Config {
if viper.GetString("vochain.DataDir") == "" {
viper.Set("vochain.DataDir", filepath.Join(conf.DataDir, "vochain"))
}
if viper.GetString("vochain.ProcessArchiveDataDir") == "" {
viper.Set("vochain.ProcessArchiveDataDir", filepath.Join(conf.DataDir, "archive"))
}

// propagate some keys to the vochain category
viper.Set("vochain.dbType", viper.GetString("dbType"))
Expand Down Expand Up @@ -302,9 +290,8 @@ func loadConfig() *config.Config {
log.Fatalf("cannot unmarshal loaded config file: %s", err)
}
// Note that these Config.Vochain fields aren't bound via viper.
// We could do that if we rename the flags, e.g. vochainIndexerArchiveURL.
// We could do that if we rename the flags.
conf.Vochain.Indexer.Enabled = !viper.GetBool("vochainIndexerDisabled")
conf.Vochain.Indexer.ArchiveURL = viper.GetString("archiveURL")
conf.Vochain.Network = viper.GetString("chain")

if conf.SigningKey == "" {
Expand Down Expand Up @@ -487,20 +474,10 @@ func main() {
}
// create the indexer service
if conf.Vochain.Indexer.Enabled {
// disable archive if process archive mode is enabled
if conf.Vochain.ProcessArchive {
conf.Vochain.Indexer.ArchiveURL = ""
}
if err := srv.VochainIndexer(); err != nil {
log.Fatal(err)
}
}
// create the process archiver service
if conf.Vochain.ProcessArchive {
if err := srv.ProcessArchiver(); err != nil {
log.Fatal(err)
}
}
// start the service and block until finish sync:
// StateSync (if enabled) happens first, and then fastsync in all cases
if err := srv.Start(); err != nil {
Expand Down
8 changes: 0 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ type VochainCfg struct {
TendermintMetrics bool
// Target block time in seconds (only for miners)
MinerTargetBlockTimeSeconds int
// Enables the process archiver component
ProcessArchive bool
// Base64 IPFS private key for using with the process archive
ProcessArchiveKey string
// Data directory for storing the process archive
ProcessArchiveDataDir string
// Indexer holds the configuration regarding the indexer component
Indexer IndexerCfg
// IsSeedNode specifies if the node is configured to act as a seed node
Expand Down Expand Up @@ -158,8 +152,6 @@ type IndexerCfg struct {
Enabled bool
// Disables live results computation on indexer
IgnoreLiveResults bool
// ArchiveURL is the URL where the archive is retrieved from (usually IPNS)
ArchiveURL string
}

// MetricsCfg initializes the metrics config
Expand Down
1 change: 0 additions & 1 deletion dockerfiles/testsuite/env.gateway0
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ VOCDONI_VOCHAIN_NOWAITSYNC=True
VOCDONI_METRICS_ENABLED=True
VOCDONI_METRICS_REFRESHINTERVAL=5
VOCDONI_SIGNINGKEY=e0f1412b86d6ca9f2b318f1d243ef50be23d315a2e6c1c3035bc72d44c8b2f90 # 0x88a499cEf9D1330111b41360173967c9C1bf703f
VOCDONI_ARCHIVEURL=none
VOCDONI_VOCHAIN_STATESYNCENABLED=false
VOCDONI_VOCHAIN_SNAPSHOTINTERVAL=3
VOCDONI_VOCHAIN_STATESYNCCHUNKSIZE=2000
1 change: 0 additions & 1 deletion dockerfiles/testsuite/env.gatewaySync
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ VOCDONI_VOCHAIN_NOWAITSYNC=True
VOCDONI_METRICS_ENABLED=True
VOCDONI_METRICS_REFRESHINTERVAL=5
VOCDONI_SIGNINGKEY=f50be23d315a2e6c1c30e0f1412b86d6ca9f2b318f1d243e35bc72d44c8b2f90
VOCDONI_ARCHIVEURL=none
VOCDONI_VOCHAIN_SNAPSHOTINTERVAL=3
3 changes: 0 additions & 3 deletions dockerfiles/vocdoninode/env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ VOCDONI_ENABLEAPI=True
VOCDONI_ENABLERPC=False
VOCDONI_LISTENHOST=0.0.0.0
VOCDONI_LISTENPORT=9090
VOCDONI_ARCHIVEURL=/ipns/k2k4r8otxrf176h1i08txap0ep6ynr1jac0vymozi068eedml7gk1595
#VOCDONI_TLS_DIRCERT=
#VOCDONI_TLS_DOMAIN=
#VOCDONI_ADMINTOKEN=
Expand All @@ -35,7 +34,5 @@ VOCDONI_ARCHIVEURL=/ipns/k2k4r8otxrf176h1i08txap0ep6ynr1jac0vymozi068eedml7gk159
#VOCDONI_VOCHAIN_MINERTARGETBLOCKTIMESECONDS=10
#VOCDONI_VOCHAIN_KEYKEEPERINDEX=
#VOCDONI_VOCHAIN_IMPORTPREVIOUSCENSUS=False
#VOCDONI_VOCHAIN_PROCESSARCHIVE=False
#VOCDONI_VOCHAIN_PROCESSARCHIVEKEY=
#VOCDONI_METRICS_ENABLED=False
#VOCDONI_METRICS_REFRESHINTERVAL=5
5 changes: 0 additions & 5 deletions service/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,5 @@ func (vs *VocdoniService) VochainIndexer() error {
return nil
})

if vs.Config.Indexer.ArchiveURL != "" && vs.Config.Indexer.ArchiveURL != "none" {
log.Infow("starting archive retrieval", "path", vs.Config.Indexer.ArchiveURL)
go vs.Indexer.StartArchiveRetrieval(vs.DataDownloader, vs.Config.Indexer.ArchiveURL)
}

return nil
}
28 changes: 0 additions & 28 deletions service/processarchiver.go

This file was deleted.

3 changes: 0 additions & 3 deletions types/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const (
// EntityIDsize is the size of an entity id (ethereum address).
EntityIDsize = EthereumAddressSize

// ArchiveURL is the default URL where the archive is retrieved from.
ArchiveURL = "/ipns/k2k4r8otxrf176h1i08txap0ep6ynr1jac0vymozi068eedml7gk1595"

// DefaultBlockTime is the default block time in seconds.
DefaultBlockTime = 10 * time.Second

Expand Down
Loading

0 comments on commit 8db2a08

Please sign in to comment.