From 8626ffbd0595b154a118c9f43a5700b957d55313 Mon Sep 17 00:00:00 2001 From: Leo Lara Date: Wed, 23 Mar 2022 16:40:58 +0100 Subject: [PATCH 1/2] core/aggsigdb: integrate into dependency injection the new Memory based aggSigDB --- app/app.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index eac8c19af..3fde47435 100644 --- a/app/app.go +++ b/app/app.go @@ -295,7 +295,7 @@ func wireSimNetCoreWorkflow(life *lifecycle.Manager, conf Config, manifest Manif sigAgg := sigagg.New(threshold) - aggSigDB := aggsigdb.Stub{} + aggSigDB := aggsigdb.NewMemDB() broadcaster, err := bcast.New(bmock) if err != nil { @@ -315,6 +315,7 @@ func wireSimNetCoreWorkflow(life *lifecycle.Manager, conf Config, manifest Manif life.RegisterStart(lifecycle.AsyncAppCtx, lifecycle.StartLeaderCast, lifecycle.HookFunc(consensus.Run)) life.RegisterStart(lifecycle.AsyncBackground, lifecycle.StartScheduler, lifecycle.HookFuncErr(sched.Run)) + life.RegisterStart(lifecycle.AsyncAppCtx, lifecycle.StartScheduler, lifecycle.HookFuncCtx(aggSigDB.Run)) life.RegisterStop(lifecycle.StopScheduler, lifecycle.HookFuncMin(sched.Stop)) return nil From 2af6fd0a9c50a14f66de31b42d4bb07e31e485f3 Mon Sep 17 00:00:00 2001 From: Leo Lara Date: Mon, 28 Mar 2022 23:15:15 +0200 Subject: [PATCH 2/2] Add new app lifecicle order --- app/app.go | 2 +- app/lifecycle/order.go | 3 ++- app/lifecycle/orderstart_string.go | 17 +++++++++-------- app/lifecycle/orderstop_string.go | 18 +++++++++--------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/app/app.go b/app/app.go index 3fde47435..5835ababd 100644 --- a/app/app.go +++ b/app/app.go @@ -315,7 +315,7 @@ func wireSimNetCoreWorkflow(life *lifecycle.Manager, conf Config, manifest Manif life.RegisterStart(lifecycle.AsyncAppCtx, lifecycle.StartLeaderCast, lifecycle.HookFunc(consensus.Run)) life.RegisterStart(lifecycle.AsyncBackground, lifecycle.StartScheduler, lifecycle.HookFuncErr(sched.Run)) - life.RegisterStart(lifecycle.AsyncAppCtx, lifecycle.StartScheduler, lifecycle.HookFuncCtx(aggSigDB.Run)) + life.RegisterStart(lifecycle.AsyncAppCtx, lifecycle.StartAggSigDB, lifecycle.HookFuncCtx(aggSigDB.Run)) life.RegisterStop(lifecycle.StopScheduler, lifecycle.HookFuncMin(sched.Stop)) return nil diff --git a/app/lifecycle/order.go b/app/lifecycle/order.go index 75a9faaf7..c32efa8ec 100644 --- a/app/lifecycle/order.go +++ b/app/lifecycle/order.go @@ -25,7 +25,8 @@ type OrderStop int // Global ordering of start and stop hooks. const ( - StartMonitoringAPI OrderStart = iota + StartAggSigDB OrderStart = iota + StartMonitoringAPI StartValidatorAPI StartP2PPing StartLeaderCast diff --git a/app/lifecycle/orderstart_string.go b/app/lifecycle/orderstart_string.go index 2b703f3b8..fbfe210af 100644 --- a/app/lifecycle/orderstart_string.go +++ b/app/lifecycle/orderstart_string.go @@ -22,17 +22,18 @@ func _() { // An "invalid array index" compiler error signifies that the constant values have changed. // Re-run the stringer command to generate them again. var x [1]struct{} - _ = x[StartMonitoringAPI-0] - _ = x[StartValidatorAPI-1] - _ = x[StartP2PPing-2] - _ = x[StartLeaderCast-3] - _ = x[StartSimulator-4] - _ = x[StartScheduler-5] + _ = x[StartAggSigDB-0] + _ = x[StartMonitoringAPI-1] + _ = x[StartValidatorAPI-2] + _ = x[StartP2PPing-3] + _ = x[StartLeaderCast-4] + _ = x[StartSimulator-5] + _ = x[StartScheduler-6] } -const _OrderStart_name = "MonitoringAPIValidatorAPIP2PPingLeaderCastSimulatorScheduler" +const _OrderStart_name = "AggSigDBMonitoringAPIValidatorAPIP2PPingLeaderCastSimulatorScheduler" -var _OrderStart_index = [...]uint8{0, 13, 25, 32, 42, 51, 60} +var _OrderStart_index = [...]uint8{0, 8, 21, 33, 40, 50, 59, 68} func (i OrderStart) String() string { if i < 0 || i >= OrderStart(len(_OrderStart_index)-1) { diff --git a/app/lifecycle/orderstop_string.go b/app/lifecycle/orderstop_string.go index 23da88958..6fef45ab8 100644 --- a/app/lifecycle/orderstop_string.go +++ b/app/lifecycle/orderstop_string.go @@ -22,13 +22,13 @@ func _() { // An "invalid array index" compiler error signifies that the constant values have changed. // Re-run the stringer command to generate them again. var x [1]struct{} - _ = x[StopTracing-6] - _ = x[StopScheduler-7] - _ = x[StopP2PPeerDB-8] - _ = x[StopP2PTCPNode-9] - _ = x[StopP2PUDPNode-10] - _ = x[StopMonitoringAPI-11] - _ = x[StopValidatorAPI-12] + _ = x[StopTracing-7] + _ = x[StopScheduler-8] + _ = x[StopP2PPeerDB-9] + _ = x[StopP2PTCPNode-10] + _ = x[StopP2PUDPNode-11] + _ = x[StopMonitoringAPI-12] + _ = x[StopValidatorAPI-13] } const _OrderStop_name = "TracingSchedulerP2PPeerDBP2PTCPNodeP2PUDPNodeMonitoringAPIValidatorAPI" @@ -36,9 +36,9 @@ const _OrderStop_name = "TracingSchedulerP2PPeerDBP2PTCPNodeP2PUDPNodeMonitoring var _OrderStop_index = [...]uint8{0, 7, 16, 25, 35, 45, 58, 70} func (i OrderStop) String() string { - i -= 6 + i -= 7 if i < 0 || i >= OrderStop(len(_OrderStop_index)-1) { - return "OrderStop(" + strconv.FormatInt(int64(i+6), 10) + ")" + return "OrderStop(" + strconv.FormatInt(int64(i+7), 10) + ")" } return _OrderStop_name[_OrderStop_index[i]:_OrderStop_index[i+1]] }