code.vegaprotocol.io/vega@v0.79.0/core/snapshot/providers.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package snapshot
    17  
    18  import (
    19  	"code.vegaprotocol.io/vega/core/types"
    20  )
    21  
    22  // providersInCallOrder holds the providers namespace in the order in which
    23  // they must be called.
    24  var providersInCallOrder = []types.SnapshotNamespace{
    25  	types.TxCacheSnapshot,
    26  	types.EpochSnapshot,
    27  	types.AssetsSnapshot,  // Needs to happen before banking.
    28  	types.WitnessSnapshot, // Needs to happen before banking and governance.
    29  	types.NetParamsSnapshot,
    30  	types.GovernanceSnapshot,
    31  	types.BankingSnapshot,
    32  	types.CollateralSnapshot,
    33  	types.TopologySnapshot,
    34  	types.NotarySnapshot,
    35  	types.CheckpointSnapshot,
    36  	types.DelegationSnapshot,
    37  	types.FloatingPointConsensusSnapshot, // Shouldn't matter but maybe best before the markets are restored.
    38  	types.ExecutionSnapshot,              // Creates the markets, returns matching and positions engines for state providers.
    39  	types.PositionsSnapshot,              // Requires markets.
    40  	types.MatchingSnapshot,               // Requires markets, and positions so that AMM's evaluate properly
    41  	types.SettlementSnapshot,             // Requires markets.
    42  	types.LiquidationSnapshot,            // Requires markets.
    43  	types.HoldingAccountTrackerSnapshot,
    44  	types.EthereumOracleVerifierSnapshot,
    45  	types.L2EthereumOraclesSnapshot,
    46  	types.LiquiditySnapshot,
    47  	types.LiquidityV2Snapshot,
    48  	types.LiquidityTargetSnapshot,
    49  	types.StakingSnapshot,
    50  	types.StakeVerifierSnapshot,
    51  	types.SpamSnapshot,
    52  	types.LimitSnapshot,
    53  	types.RewardSnapshot,
    54  	types.EventForwarderSnapshot,
    55  	types.MarketActivityTrackerSnapshot,
    56  	types.ERC20MultiSigTopologySnapshot,
    57  	types.EVMMultiSigTopologiesSnapshot,
    58  	types.EVMMultiSigTopologiesSnapshot,
    59  	types.PoWSnapshot,
    60  	types.ProtocolUpgradeSnapshot,
    61  	types.TeamsSnapshot,
    62  	types.VestingSnapshot,
    63  	types.ReferralProgramSnapshot,
    64  	types.ActivityStreakSnapshot,
    65  	types.VolumeDiscountProgramSnapshot,
    66  	types.PartiesSnapshot,
    67  	types.EVMHeartbeatSnapshot,
    68  	types.VolumeRebateProgramSnapshot,
    69  }
    70  
    71  func groupPayloadsPerNamespace(payloads []*types.Payload) map[types.SnapshotNamespace][]*types.Payload {
    72  	payloadsPerNamespace := make(map[types.SnapshotNamespace][]*types.Payload, len(providersInCallOrder))
    73  	for _, payload := range payloads {
    74  		providerNamespace := payload.Namespace()
    75  		if _, ok := payloadsPerNamespace[providerNamespace]; !ok {
    76  			payloadsPerNamespace[providerNamespace] = []*types.Payload{}
    77  		}
    78  		payloadsPerNamespace[providerNamespace] = append(payloadsPerNamespace[providerNamespace], payload)
    79  	}
    80  	return payloadsPerNamespace
    81  }