github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/integration/presets.go (about)

     1  package integration
     2  
     3  import (
     4  	"github.com/syndtr/goleveldb/leveldb/opt"
     5  	"github.com/unicornultrafoundation/go-helios/u2udb/multidb"
     6  )
     7  
     8  var DefaultDBsConfig = PblLegacyDBsConfig
     9  var DefaultDBsConfigName = "legacy-pebble"
    10  
    11  /*
    12   * pbl-1 config
    13   */
    14  
    15  func Pbl1DBsConfig(scale func(uint64) uint64, fdlimit uint64) DBsConfig {
    16  	return DBsConfig{
    17  		Routing:      Pbl1RoutingConfig(),
    18  		RuntimeCache: Pbl1RuntimeDBsCacheConfig(scale, fdlimit),
    19  		GenesisCache: Pbl1GenesisDBsCacheConfig(scale, fdlimit),
    20  	}
    21  }
    22  
    23  func Pbl1RoutingConfig() RoutingConfig {
    24  	return RoutingConfig{
    25  		Table: map[string]multidb.Route{
    26  			"": {
    27  				Type: "pebble-fsh",
    28  			},
    29  			"hashgraph": {
    30  				Type:  "pebble-fsh",
    31  				Name:  "main",
    32  				Table: "C",
    33  			},
    34  			"gossip": {
    35  				Type: "pebble-fsh",
    36  				Name: "main",
    37  			},
    38  			"evm": {
    39  				Type: "pebble-fsh",
    40  				Name: "main",
    41  			},
    42  			"gossip/e": {
    43  				Type: "pebble-fsh",
    44  				Name: "events",
    45  			},
    46  			"evm/M": {
    47  				Type: "pebble-drc",
    48  				Name: "evm-data",
    49  			},
    50  			"evm-logs": {
    51  				Type: "pebble-fsh",
    52  				Name: "evm-logs",
    53  			},
    54  			"gossip-%d": {
    55  				Type:  "leveldb-fsh",
    56  				Name:  "epoch-%d",
    57  				Table: "G",
    58  			},
    59  			"hashgraph-%d": {
    60  				Type:   "leveldb-fsh",
    61  				Name:   "epoch-%d",
    62  				Table:  "L",
    63  				NoDrop: true,
    64  			},
    65  		},
    66  	}
    67  }
    68  
    69  func Pbl1RuntimeDBsCacheConfig(scale func(uint64) uint64, fdlimit uint64) DBsCacheConfig {
    70  	return DBsCacheConfig{
    71  		Table: map[string]DBCacheConfig{
    72  			"evm-data": {
    73  				Cache:   scale(480 * opt.MiB),
    74  				Fdlimit: fdlimit*480/1400 + 1,
    75  			},
    76  			"evm-logs": {
    77  				Cache:   scale(260 * opt.MiB),
    78  				Fdlimit: fdlimit*260/1400 + 1,
    79  			},
    80  			"main": {
    81  				Cache:   scale(320 * opt.MiB),
    82  				Fdlimit: fdlimit*320/1400 + 1,
    83  			},
    84  			"events": {
    85  				Cache:   scale(240 * opt.MiB),
    86  				Fdlimit: fdlimit*240/1400 + 1,
    87  			},
    88  			"epoch-%d": {
    89  				Cache:   scale(100 * opt.MiB),
    90  				Fdlimit: fdlimit*100/1400 + 1,
    91  			},
    92  			"": {
    93  				Cache:   64 * opt.MiB,
    94  				Fdlimit: fdlimit/100 + 1,
    95  			},
    96  		},
    97  	}
    98  }
    99  
   100  func Pbl1GenesisDBsCacheConfig(scale func(uint64) uint64, fdlimit uint64) DBsCacheConfig {
   101  	return DBsCacheConfig{
   102  		Table: map[string]DBCacheConfig{
   103  			"main": {
   104  				Cache:   scale(1000 * opt.MiB),
   105  				Fdlimit: fdlimit*1000/3000 + 1,
   106  			},
   107  			"evm-data": {
   108  				Cache:   scale(1000 * opt.MiB),
   109  				Fdlimit: fdlimit*1000/3000 + 1,
   110  			},
   111  			"evm-logs": {
   112  				Cache:   scale(1000 * opt.MiB),
   113  				Fdlimit: fdlimit*1000/3000 + 1,
   114  			},
   115  			"events": {
   116  				Cache:   scale(1 * opt.MiB),
   117  				Fdlimit: fdlimit*1/3000 + 1,
   118  			},
   119  			"epoch-%d": {
   120  				Cache:   scale(1 * opt.MiB),
   121  				Fdlimit: fdlimit*1/3000 + 1,
   122  			},
   123  			"": {
   124  				Cache:   16 * opt.MiB,
   125  				Fdlimit: fdlimit/100 + 1,
   126  			},
   127  		},
   128  	}
   129  }
   130  
   131  /*
   132   * legacy-pbl config
   133   */
   134  
   135  func PblLegacyDBsConfig(scale func(uint64) uint64, fdlimit uint64) DBsConfig {
   136  	return DBsConfig{
   137  		Routing:      PblLegacyRoutingConfig(),
   138  		RuntimeCache: PblLegacyRuntimeDBsCacheConfig(scale, fdlimit),
   139  		GenesisCache: PblLegacyGenesisDBsCacheConfig(scale, fdlimit),
   140  	}
   141  }
   142  
   143  func PblLegacyRoutingConfig() RoutingConfig {
   144  	return RoutingConfig{
   145  		Table: map[string]multidb.Route{
   146  			"": {
   147  				Type: "pebble-fsh",
   148  			},
   149  			"hashgraph": {
   150  				Type: "pebble-fsh",
   151  				Name: "hashgraph",
   152  			},
   153  			"gossip": {
   154  				Type: "pebble-fsh",
   155  				Name: "main",
   156  			},
   157  
   158  			"gossip/S": {
   159  				Type:  "pebble-fsh",
   160  				Name:  "main",
   161  				Table: "!",
   162  			},
   163  			"gossip/R": {
   164  				Type:  "pebble-fsh",
   165  				Name:  "main",
   166  				Table: "@",
   167  			},
   168  			"gossip/Q": {
   169  				Type:  "pebble-fsh",
   170  				Name:  "main",
   171  				Table: "#",
   172  			},
   173  
   174  			"gossip/T": {
   175  				Type:  "pebble-fsh",
   176  				Name:  "main",
   177  				Table: "$",
   178  			},
   179  			"gossip/J": {
   180  				Type:  "pebble-fsh",
   181  				Name:  "main",
   182  				Table: "%",
   183  			},
   184  			"gossip/E": {
   185  				Type:  "pebble-fsh",
   186  				Name:  "main",
   187  				Table: "^",
   188  			},
   189  
   190  			"gossip/I": {
   191  				Type:  "pebble-fsh",
   192  				Name:  "main",
   193  				Table: "&",
   194  			},
   195  			"gossip/G": {
   196  				Type:  "pebble-fsh",
   197  				Name:  "main",
   198  				Table: "*",
   199  			},
   200  			"gossip/F": {
   201  				Type:  "pebble-fsh",
   202  				Name:  "main",
   203  				Table: "(",
   204  			},
   205  
   206  			"evm": {
   207  				Type: "pebble-fsh",
   208  				Name: "main",
   209  			},
   210  			"evm-logs": {
   211  				Type:  "pebble-fsh",
   212  				Name:  "main",
   213  				Table: "L",
   214  			},
   215  			"gossip-%d": {
   216  				Type: "pebble-fsh",
   217  				Name: "gossip-%d",
   218  			},
   219  			"hashgraph-%d": {
   220  				Type: "pebble-fsh",
   221  				Name: "hashgraph-%d",
   222  			},
   223  		},
   224  	}
   225  }
   226  
   227  func PblLegacyRuntimeDBsCacheConfig(scale func(uint64) uint64, fdlimit uint64) DBsCacheConfig {
   228  	return DBsCacheConfig{
   229  		Table: map[string]DBCacheConfig{
   230  			"main": {
   231  				Cache:   scale(950 * opt.MiB),
   232  				Fdlimit: fdlimit*950/1400 + 1,
   233  			},
   234  			"hashgraph": {
   235  				Cache:   scale(150 * opt.MiB),
   236  				Fdlimit: fdlimit*150/1400 + 1,
   237  			},
   238  			"gossip-%d": {
   239  				Cache:   scale(150 * opt.MiB),
   240  				Fdlimit: fdlimit*150/1400 + 1,
   241  			},
   242  			"hashgraph-%d": {
   243  				Cache:   scale(150 * opt.MiB),
   244  				Fdlimit: fdlimit*150/1400 + 1,
   245  			},
   246  			"": {
   247  				Cache:   64 * opt.MiB,
   248  				Fdlimit: fdlimit/100 + 1,
   249  			},
   250  		},
   251  	}
   252  }
   253  
   254  func PblLegacyGenesisDBsCacheConfig(scale func(uint64) uint64, fdlimit uint64) DBsCacheConfig {
   255  	return DBsCacheConfig{
   256  		Table: map[string]DBCacheConfig{
   257  			"main": {
   258  				Cache:   scale(3000 * opt.MiB),
   259  				Fdlimit: fdlimit,
   260  			},
   261  			"hashgraph": {
   262  				Cache:   scale(1 * opt.MiB),
   263  				Fdlimit: fdlimit*1/3000 + 1,
   264  			},
   265  			"gossip-%d": {
   266  				Cache:   scale(1 * opt.MiB),
   267  				Fdlimit: fdlimit*1/3000 + 1,
   268  			},
   269  			"hashgraph-%d": {
   270  				Cache:   scale(1 * opt.MiB),
   271  				Fdlimit: fdlimit*1/3000 + 1,
   272  			},
   273  			"": {
   274  				Cache:   16 * opt.MiB,
   275  				Fdlimit: fdlimit/100 + 1,
   276  			},
   277  		},
   278  	}
   279  }