Skip to content

Commit

Permalink
genesis: remove useless hardcoded StateSyncParams
Browse files Browse the repository at this point in the history
  • Loading branch information
altergui committed May 8, 2024
1 parent 5368067 commit 95afb48
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 38 deletions.
18 changes: 0 additions & 18 deletions vochain/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ var Genesis = map[string]Vochain{
SeedNodes: []string{
"[email protected]:26656",
},
StateSync: map[string]StateSyncParams{
"vocdoni/DEV/32": {
TrustHeight: 10000,
TrustHash: types.HexStringToHexBytes("0x2b430478c7867dc078c0380b81838d75358db7c8b65bfaf84ade85448a0abd54"),
},
},
Genesis: &devGenesis,
},

Expand All @@ -29,12 +23,6 @@ var Genesis = map[string]Vochain{
SeedNodes: []string{
"[email protected]:26656",
},
StateSync: map[string]StateSyncParams{
"Vocdoni/STAGE/11": {
TrustHeight: 150000,
TrustHash: types.HexStringToHexBytes("0xd964cd5ec4704d3b3e1864c174edd1331044926bb2e6d3fe0b239b1c59329ff2"),
},
},
Genesis: &stageGenesis,
},

Expand All @@ -45,12 +33,6 @@ var Genesis = map[string]Vochain{
"[email protected]:26656",
"[email protected]:26656",
},
StateSync: map[string]StateSyncParams{
"Vocdoni/LTS/1.2": {
TrustHeight: 1000000,
TrustHash: types.HexStringToHexBytes("0xd782c4a8e889a12fb326dd7f098336756f4238169a603501ae4a2b2f88c19db9"),
},
},
Genesis: &ltsGenesis,
},
}
Expand Down
6 changes: 0 additions & 6 deletions vochain/genesis/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ type AppStateValidators struct {
KeyIndex uint8 `json:"key_index"`
}

// StateSyncParams define the parameters used by StateSync
type StateSyncParams struct {
TrustHeight int64
TrustHash types.HexBytes
}

// StringifiedInt64 is a wrapper around int64 that marshals/unmarshals as a string.
// This is a dirty non-sense workaround. Blame Tendermint not me.
// For some (unknown) reason Tendermint requires the integer values to be strings in
Expand Down
16 changes: 2 additions & 14 deletions vochain/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func newTendermint(app *BaseApplication,
tconfig.StateSync.TrustHeight = localConfig.StateSyncTrustHeight
tconfig.StateSync.TrustHash = localConfig.StateSyncTrustHash

// If StateSync is enabled but parameters are empty, try our best to populate them
// first try to fetch params from remote API endpoint
// If StateSync is enabled but parameters are empty, populate them
// fetching params from remote API endpoint
if localConfig.StateSyncFetchParamsFromRPC &&
tconfig.StateSync.TrustHeight == 0 && tconfig.StateSync.TrustHash == "" {
tconfig.StateSync.TrustHeight, tconfig.StateSync.TrustHash = func() (int64, string) {
Expand Down Expand Up @@ -196,18 +196,6 @@ func newTendermint(app *BaseApplication,
return status.SyncInfo.LatestBlockHeight, status.SyncInfo.LatestBlockHash.String()
}()
}

// if still empty, fallback to hardcoded params, if defined for the current network & chainID
if tconfig.StateSync.TrustHeight == 0 && tconfig.StateSync.TrustHash == "" {
if g, ok := vocdoniGenesis.Genesis[localConfig.Network]; ok {
if statesync, ok := g.StateSync[g.Genesis.ChainID]; ok {
tconfig.StateSync.TrustHeight = statesync.TrustHeight
tconfig.StateSync.TrustHash = statesync.TrustHash.String()
log.Infow("using hardcoded statesync params",
"height", tconfig.StateSync.TrustHeight, "hash", tconfig.StateSync.TrustHash)
}
}
}
}
tconfig.RPC.ListenAddress = "tcp://0.0.0.0:26657"

Expand Down

0 comments on commit 95afb48

Please sign in to comment.