github.com/baptiste-b-pegasys/quorum/v22@v22.4.2/light/lightchain.go (about) 1 // Copyright 2016 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 // Package light implements on-demand retrieval capable state and chain objects 18 // for the Ethereum Light Client. 19 package light 20 21 import ( 22 "context" 23 "errors" 24 "math/big" 25 "sync" 26 "sync/atomic" 27 "time" 28 29 "github.com/jpmorganchase/quorum-security-plugin-sdk-go/proto" 30 31 "github.com/ethereum/go-ethereum/common" 32 "github.com/ethereum/go-ethereum/consensus" 33 "github.com/ethereum/go-ethereum/core" 34 "github.com/ethereum/go-ethereum/core/mps" 35 "github.com/ethereum/go-ethereum/core/rawdb" 36 "github.com/ethereum/go-ethereum/core/state" 37 "github.com/ethereum/go-ethereum/core/types" 38 "github.com/ethereum/go-ethereum/ethdb" 39 "github.com/ethereum/go-ethereum/event" 40 "github.com/ethereum/go-ethereum/log" 41 "github.com/ethereum/go-ethereum/params" 42 "github.com/ethereum/go-ethereum/rlp" 43 lru "github.com/hashicorp/golang-lru" 44 ) 45 46 var ( 47 bodyCacheLimit = 256 48 blockCacheLimit = 256 49 ) 50 51 // LightChain represents a canonical chain that by default only handles block 52 // headers, downloading block bodies and receipts on demand through an ODR 53 // interface. It only does header validation during chain insertion. 54 type LightChain struct { 55 hc *core.HeaderChain 56 indexerConfig *IndexerConfig 57 chainDb ethdb.Database 58 engine consensus.Engine 59 odr OdrBackend 60 chainFeed event.Feed 61 chainSideFeed event.Feed 62 chainHeadFeed event.Feed 63 scope event.SubscriptionScope 64 genesisBlock *types.Block 65 66 bodyCache *lru.Cache // Cache for the most recent block bodies 67 bodyRLPCache *lru.Cache // Cache for the most recent block bodies in RLP encoded format 68 blockCache *lru.Cache // Cache for the most recent entire blocks 69 70 chainmu sync.RWMutex // protects header inserts 71 quit chan struct{} 72 wg sync.WaitGroup 73 74 // Atomic boolean switches: 75 running int32 // whether LightChain is running or stopped 76 procInterrupt int32 // interrupts chain insert 77 disableCheckFreq int32 // disables header verification 78 79 // Quorum 80 isMultitenant bool 81 } 82 83 // NewLightChain returns a fully initialised light chain using information 84 // available in the database. It initialises the default Ethereum header 85 // validator. 86 func NewLightChain(odr OdrBackend, config *params.ChainConfig, engine consensus.Engine, checkpoint *params.TrustedCheckpoint) (*LightChain, error) { 87 bodyCache, _ := lru.New(bodyCacheLimit) 88 bodyRLPCache, _ := lru.New(bodyCacheLimit) 89 blockCache, _ := lru.New(blockCacheLimit) 90 91 bc := &LightChain{ 92 chainDb: odr.Database(), 93 indexerConfig: odr.IndexerConfig(), 94 odr: odr, 95 quit: make(chan struct{}), 96 bodyCache: bodyCache, 97 bodyRLPCache: bodyRLPCache, 98 blockCache: blockCache, 99 engine: engine, 100 } 101 var err error 102 bc.hc, err = core.NewHeaderChain(odr.Database(), config, bc.engine, bc.getProcInterrupt) 103 if err != nil { 104 return nil, err 105 } 106 bc.genesisBlock, _ = bc.GetBlockByNumber(NoOdr, 0) 107 if bc.genesisBlock == nil { 108 return nil, core.ErrNoGenesis 109 } 110 if checkpoint != nil { 111 bc.AddTrustedCheckpoint(checkpoint) 112 } 113 if err := bc.loadLastState(); err != nil { 114 return nil, err 115 } 116 // Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain 117 for hash := range core.BadHashes { 118 if header := bc.GetHeaderByHash(hash); header != nil { 119 log.Error("Found bad hash, rewinding chain", "number", header.Number, "hash", header.ParentHash) 120 bc.SetHead(header.Number.Uint64() - 1) 121 log.Info("Chain rewind was successful, resuming normal operation") 122 } 123 } 124 return bc, nil 125 } 126 127 func NewMultitenantLightChain(odr OdrBackend, config *params.ChainConfig, engine consensus.Engine, checkpoint *params.TrustedCheckpoint) (*LightChain, error) { 128 bc, err := NewLightChain(odr, config, engine, checkpoint) 129 if err != nil { 130 return nil, err 131 } 132 bc.isMultitenant = true 133 return bc, nil 134 } 135 136 // AddTrustedCheckpoint adds a trusted checkpoint to the blockchain 137 func (lc *LightChain) AddTrustedCheckpoint(cp *params.TrustedCheckpoint) { 138 if lc.odr.ChtIndexer() != nil { 139 StoreChtRoot(lc.chainDb, cp.SectionIndex, cp.SectionHead, cp.CHTRoot) 140 lc.odr.ChtIndexer().AddCheckpoint(cp.SectionIndex, cp.SectionHead) 141 } 142 if lc.odr.BloomTrieIndexer() != nil { 143 StoreBloomTrieRoot(lc.chainDb, cp.SectionIndex, cp.SectionHead, cp.BloomRoot) 144 lc.odr.BloomTrieIndexer().AddCheckpoint(cp.SectionIndex, cp.SectionHead) 145 } 146 if lc.odr.BloomIndexer() != nil { 147 lc.odr.BloomIndexer().AddCheckpoint(cp.SectionIndex, cp.SectionHead) 148 } 149 log.Info("Added trusted checkpoint", "block", (cp.SectionIndex+1)*lc.indexerConfig.ChtSize-1, "hash", cp.SectionHead) 150 } 151 152 func (lc *LightChain) getProcInterrupt() bool { 153 return atomic.LoadInt32(&lc.procInterrupt) == 1 154 } 155 156 // Odr returns the ODR backend of the chain 157 func (lc *LightChain) Odr() OdrBackend { 158 return lc.odr 159 } 160 161 // HeaderChain returns the underlying header chain. 162 func (lc *LightChain) HeaderChain() *core.HeaderChain { 163 return lc.hc 164 } 165 166 // loadLastState loads the last known chain state from the database. This method 167 // assumes that the chain manager mutex is held. 168 func (lc *LightChain) loadLastState() error { 169 if head := rawdb.ReadHeadHeaderHash(lc.chainDb); head == (common.Hash{}) { 170 // Corrupt or empty database, init from scratch 171 lc.Reset() 172 } else { 173 header := lc.GetHeaderByHash(head) 174 if header == nil { 175 // Corrupt or empty database, init from scratch 176 lc.Reset() 177 } else { 178 lc.hc.SetCurrentHeader(header) 179 } 180 } 181 // Issue a status log and return 182 header := lc.hc.CurrentHeader() 183 headerTd := lc.GetTd(header.Hash(), header.Number.Uint64()) 184 log.Info("Loaded most recent local header", "number", header.Number, "hash", header.Hash(), "td", headerTd, "age", common.PrettyAge(time.Unix(int64(header.Time), 0))) 185 return nil 186 } 187 188 // SetHead rewinds the local chain to a new head. Everything above the new 189 // head will be deleted and the new one set. 190 func (lc *LightChain) SetHead(head uint64) error { 191 lc.chainmu.Lock() 192 defer lc.chainmu.Unlock() 193 194 lc.hc.SetHead(head, nil, nil) 195 return lc.loadLastState() 196 } 197 198 // GasLimit returns the gas limit of the current HEAD block. 199 func (lc *LightChain) GasLimit() uint64 { 200 return lc.hc.CurrentHeader().GasLimit 201 } 202 203 // Reset purges the entire blockchain, restoring it to its genesis state. 204 func (lc *LightChain) Reset() { 205 lc.ResetWithGenesisBlock(lc.genesisBlock) 206 } 207 208 // ResetWithGenesisBlock purges the entire blockchain, restoring it to the 209 // specified genesis state. 210 func (lc *LightChain) ResetWithGenesisBlock(genesis *types.Block) { 211 // Dump the entire block chain and purge the caches 212 lc.SetHead(0) 213 214 lc.chainmu.Lock() 215 defer lc.chainmu.Unlock() 216 217 // Prepare the genesis block and reinitialise the chain 218 batch := lc.chainDb.NewBatch() 219 rawdb.WriteTd(batch, genesis.Hash(), genesis.NumberU64(), genesis.Difficulty()) 220 rawdb.WriteBlock(batch, genesis) 221 rawdb.WriteHeadHeaderHash(batch, genesis.Hash()) 222 if err := batch.Write(); err != nil { 223 log.Crit("Failed to reset genesis block", "err", err) 224 } 225 lc.genesisBlock = genesis 226 lc.hc.SetGenesis(lc.genesisBlock.Header()) 227 lc.hc.SetCurrentHeader(lc.genesisBlock.Header()) 228 } 229 230 // Accessors 231 232 // Engine retrieves the light chain's consensus engine. 233 func (lc *LightChain) Engine() consensus.Engine { return lc.engine } 234 235 // Genesis returns the genesis block 236 func (lc *LightChain) Genesis() *types.Block { 237 return lc.genesisBlock 238 } 239 240 func (lc *LightChain) StateCache() state.Database { 241 panic("not implemented") 242 } 243 244 // GetBody retrieves a block body (transactions and uncles) from the database 245 // or ODR service by hash, caching it if found. 246 func (lc *LightChain) GetBody(ctx context.Context, hash common.Hash) (*types.Body, error) { 247 // Short circuit if the body's already in the cache, retrieve otherwise 248 if cached, ok := lc.bodyCache.Get(hash); ok { 249 body := cached.(*types.Body) 250 return body, nil 251 } 252 number := lc.hc.GetBlockNumber(hash) 253 if number == nil { 254 return nil, errors.New("unknown block") 255 } 256 body, err := GetBody(ctx, lc.odr, hash, *number) 257 if err != nil { 258 return nil, err 259 } 260 // Cache the found body for next time and return 261 lc.bodyCache.Add(hash, body) 262 return body, nil 263 } 264 265 // GetBodyRLP retrieves a block body in RLP encoding from the database or 266 // ODR service by hash, caching it if found. 267 func (lc *LightChain) GetBodyRLP(ctx context.Context, hash common.Hash) (rlp.RawValue, error) { 268 // Short circuit if the body's already in the cache, retrieve otherwise 269 if cached, ok := lc.bodyRLPCache.Get(hash); ok { 270 return cached.(rlp.RawValue), nil 271 } 272 number := lc.hc.GetBlockNumber(hash) 273 if number == nil { 274 return nil, errors.New("unknown block") 275 } 276 body, err := GetBodyRLP(ctx, lc.odr, hash, *number) 277 if err != nil { 278 return nil, err 279 } 280 // Cache the found body for next time and return 281 lc.bodyRLPCache.Add(hash, body) 282 return body, nil 283 } 284 285 // HasBlock checks if a block is fully present in the database or not, caching 286 // it if present. 287 func (lc *LightChain) HasBlock(hash common.Hash, number uint64) bool { 288 blk, _ := lc.GetBlock(NoOdr, hash, number) 289 return blk != nil 290 } 291 292 // GetBlock retrieves a block from the database or ODR service by hash and number, 293 // caching it if found. 294 func (lc *LightChain) GetBlock(ctx context.Context, hash common.Hash, number uint64) (*types.Block, error) { 295 // Short circuit if the block's already in the cache, retrieve otherwise 296 if block, ok := lc.blockCache.Get(hash); ok { 297 return block.(*types.Block), nil 298 } 299 block, err := GetBlock(ctx, lc.odr, hash, number) 300 if err != nil { 301 return nil, err 302 } 303 // Cache the found block for next time and return 304 lc.blockCache.Add(block.Hash(), block) 305 return block, nil 306 } 307 308 // GetBlockByHash retrieves a block from the database or ODR service by hash, 309 // caching it if found. 310 func (lc *LightChain) GetBlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) { 311 number := lc.hc.GetBlockNumber(hash) 312 if number == nil { 313 return nil, errors.New("unknown block") 314 } 315 return lc.GetBlock(ctx, hash, *number) 316 } 317 318 // GetBlockByNumber retrieves a block from the database or ODR service by 319 // number, caching it (associated with its hash) if found. 320 func (lc *LightChain) GetBlockByNumber(ctx context.Context, number uint64) (*types.Block, error) { 321 hash, err := GetCanonicalHash(ctx, lc.odr, number) 322 if hash == (common.Hash{}) || err != nil { 323 return nil, err 324 } 325 return lc.GetBlock(ctx, hash, number) 326 } 327 328 // Stop stops the blockchain service. If any imports are currently in progress 329 // it will abort them using the procInterrupt. 330 func (lc *LightChain) Stop() { 331 if !atomic.CompareAndSwapInt32(&lc.running, 0, 1) { 332 return 333 } 334 close(lc.quit) 335 lc.StopInsert() 336 lc.wg.Wait() 337 log.Info("Blockchain stopped") 338 } 339 340 // StopInsert interrupts all insertion methods, causing them to return 341 // errInsertionInterrupted as soon as possible. Insertion is permanently disabled after 342 // calling this method. 343 func (lc *LightChain) StopInsert() { 344 atomic.StoreInt32(&lc.procInterrupt, 1) 345 } 346 347 // Rollback is designed to remove a chain of links from the database that aren't 348 // certain enough to be valid. 349 func (lc *LightChain) Rollback(chain []common.Hash) { 350 lc.chainmu.Lock() 351 defer lc.chainmu.Unlock() 352 353 batch := lc.chainDb.NewBatch() 354 for i := len(chain) - 1; i >= 0; i-- { 355 hash := chain[i] 356 357 // Degrade the chain markers if they are explicitly reverted. 358 // In theory we should update all in-memory markers in the 359 // last step, however the direction of rollback is from high 360 // to low, so it's safe the update in-memory markers directly. 361 if head := lc.hc.CurrentHeader(); head.Hash() == hash { 362 rawdb.WriteHeadHeaderHash(batch, head.ParentHash) 363 lc.hc.SetCurrentHeader(lc.GetHeader(head.ParentHash, head.Number.Uint64()-1)) 364 } 365 } 366 if err := batch.Write(); err != nil { 367 log.Crit("Failed to rollback light chain", "error", err) 368 } 369 } 370 371 // postChainEvents iterates over the events generated by a chain insertion and 372 // posts them into the event feed. 373 func (lc *LightChain) postChainEvents(events []interface{}) { 374 for _, event := range events { 375 switch ev := event.(type) { 376 case core.ChainEvent: 377 if lc.CurrentHeader().Hash() == ev.Hash { 378 lc.chainHeadFeed.Send(core.ChainHeadEvent{Block: ev.Block}) 379 } 380 lc.chainFeed.Send(ev) 381 case core.ChainSideEvent: 382 lc.chainSideFeed.Send(ev) 383 } 384 } 385 } 386 387 // InsertHeaderChain attempts to insert the given header chain in to the local 388 // chain, possibly creating a reorg. If an error is returned, it will return the 389 // index number of the failing header as well an error describing what went wrong. 390 // 391 // The verify parameter can be used to fine tune whether nonce verification 392 // should be done or not. The reason behind the optional check is because some 393 // of the header retrieval mechanisms already need to verfy nonces, as well as 394 // because nonces can be verified sparsely, not needing to check each. 395 // 396 // In the case of a light chain, InsertHeaderChain also creates and posts light 397 // chain events when necessary. 398 func (lc *LightChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) { 399 if atomic.LoadInt32(&lc.disableCheckFreq) == 1 { 400 checkFreq = 0 401 } 402 start := time.Now() 403 if i, err := lc.hc.ValidateHeaderChain(chain, checkFreq); err != nil { 404 return i, err 405 } 406 407 // Make sure only one thread manipulates the chain at once 408 lc.chainmu.Lock() 409 defer lc.chainmu.Unlock() 410 411 lc.wg.Add(1) 412 defer lc.wg.Done() 413 414 status, err := lc.hc.InsertHeaderChain(chain, start) 415 if err != nil || len(chain) == 0 { 416 return 0, err 417 } 418 419 // Create chain event for the new head block of this insertion. 420 var ( 421 events = make([]interface{}, 0, 1) 422 lastHeader = chain[len(chain)-1] 423 block = types.NewBlockWithHeader(lastHeader) 424 ) 425 switch status { 426 case core.CanonStatTy: 427 events = append(events, core.ChainEvent{Block: block, Hash: block.Hash()}) 428 case core.SideStatTy: 429 events = append(events, core.ChainSideEvent{Block: block}) 430 } 431 lc.postChainEvents(events) 432 433 return 0, err 434 } 435 436 // CurrentHeader retrieves the current head header of the canonical chain. The 437 // header is retrieved from the HeaderChain's internal cache. 438 func (lc *LightChain) CurrentHeader() *types.Header { 439 return lc.hc.CurrentHeader() 440 } 441 442 // GetTd retrieves a block's total difficulty in the canonical chain from the 443 // database by hash and number, caching it if found. 444 func (lc *LightChain) GetTd(hash common.Hash, number uint64) *big.Int { 445 return lc.hc.GetTd(hash, number) 446 } 447 448 // GetTdByHash retrieves a block's total difficulty in the canonical chain from the 449 // database by hash, caching it if found. 450 func (lc *LightChain) GetTdByHash(hash common.Hash) *big.Int { 451 return lc.hc.GetTdByHash(hash) 452 } 453 454 // GetHeaderByNumberOdr retrieves the total difficult from the database or 455 // network by hash and number, caching it (associated with its hash) if found. 456 func (lc *LightChain) GetTdOdr(ctx context.Context, hash common.Hash, number uint64) *big.Int { 457 td := lc.GetTd(hash, number) 458 if td != nil { 459 return td 460 } 461 td, _ = GetTd(ctx, lc.odr, hash, number) 462 return td 463 } 464 465 // GetHeader retrieves a block header from the database by hash and number, 466 // caching it if found. 467 func (lc *LightChain) GetHeader(hash common.Hash, number uint64) *types.Header { 468 return lc.hc.GetHeader(hash, number) 469 } 470 471 // GetHeaderByHash retrieves a block header from the database by hash, caching it if 472 // found. 473 func (lc *LightChain) GetHeaderByHash(hash common.Hash) *types.Header { 474 return lc.hc.GetHeaderByHash(hash) 475 } 476 477 // HasHeader checks if a block header is present in the database or not, caching 478 // it if present. 479 func (lc *LightChain) HasHeader(hash common.Hash, number uint64) bool { 480 return lc.hc.HasHeader(hash, number) 481 } 482 483 // GetCanonicalHash returns the canonical hash for a given block number 484 func (bc *LightChain) GetCanonicalHash(number uint64) common.Hash { 485 return bc.hc.GetCanonicalHash(number) 486 } 487 488 // GetBlockHashesFromHash retrieves a number of block hashes starting at a given 489 // hash, fetching towards the genesis block. 490 func (lc *LightChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash { 491 return lc.hc.GetBlockHashesFromHash(hash, max) 492 } 493 494 // GetAncestor retrieves the Nth ancestor of a given block. It assumes that either the given block or 495 // a close ancestor of it is canonical. maxNonCanonical points to a downwards counter limiting the 496 // number of blocks to be individually checked before we reach the canonical chain. 497 // 498 // Note: ancestor == 0 returns the same block, 1 returns its parent and so on. 499 func (lc *LightChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) { 500 return lc.hc.GetAncestor(hash, number, ancestor, maxNonCanonical) 501 } 502 503 // GetHeaderByNumber retrieves a block header from the database by number, 504 // caching it (associated with its hash) if found. 505 func (lc *LightChain) GetHeaderByNumber(number uint64) *types.Header { 506 return lc.hc.GetHeaderByNumber(number) 507 } 508 509 // GetHeaderByNumberOdr retrieves a block header from the database or network 510 // by number, caching it (associated with its hash) if found. 511 func (lc *LightChain) GetHeaderByNumberOdr(ctx context.Context, number uint64) (*types.Header, error) { 512 if header := lc.hc.GetHeaderByNumber(number); header != nil { 513 return header, nil 514 } 515 return GetHeaderByNumber(ctx, lc.odr, number) 516 } 517 518 // Config retrieves the header chain's chain configuration. 519 func (lc *LightChain) Config() *params.ChainConfig { return lc.hc.Config() } 520 521 // SyncCheckpoint fetches the checkpoint point block header according to 522 // the checkpoint provided by the remote peer. 523 // 524 // Note if we are running the clique, fetches the last epoch snapshot header 525 // which covered by checkpoint. 526 func (lc *LightChain) SyncCheckpoint(ctx context.Context, checkpoint *params.TrustedCheckpoint) bool { 527 // Ensure the remote checkpoint head is ahead of us 528 head := lc.CurrentHeader().Number.Uint64() 529 530 latest := (checkpoint.SectionIndex+1)*lc.indexerConfig.ChtSize - 1 531 if clique := lc.hc.Config().Clique; clique != nil { 532 latest -= latest % clique.Epoch // epoch snapshot for clique 533 } 534 if head >= latest { 535 return true 536 } 537 // Retrieve the latest useful header and update to it 538 if header, err := GetHeaderByNumber(ctx, lc.odr, latest); header != nil && err == nil { 539 lc.chainmu.Lock() 540 defer lc.chainmu.Unlock() 541 542 // Ensure the chain didn't move past the latest block while retrieving it 543 if lc.hc.CurrentHeader().Number.Uint64() < header.Number.Uint64() { 544 log.Info("Updated latest header based on CHT", "number", header.Number, "hash", header.Hash(), "age", common.PrettyAge(time.Unix(int64(header.Time), 0))) 545 rawdb.WriteHeadHeaderHash(lc.chainDb, header.Hash()) 546 lc.hc.SetCurrentHeader(header) 547 } 548 return true 549 } 550 return false 551 } 552 553 // LockChain locks the chain mutex for reading so that multiple canonical hashes can be 554 // retrieved while it is guaranteed that they belong to the same version of the chain 555 func (lc *LightChain) LockChain() { 556 lc.chainmu.RLock() 557 } 558 559 // UnlockChain unlocks the chain mutex 560 func (lc *LightChain) UnlockChain() { 561 lc.chainmu.RUnlock() 562 } 563 564 // SubscribeChainEvent registers a subscription of ChainEvent. 565 func (lc *LightChain) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription { 566 return lc.scope.Track(lc.chainFeed.Subscribe(ch)) 567 } 568 569 // SubscribeChainHeadEvent registers a subscription of ChainHeadEvent. 570 func (lc *LightChain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription { 571 return lc.scope.Track(lc.chainHeadFeed.Subscribe(ch)) 572 } 573 574 // SubscribeChainSideEvent registers a subscription of ChainSideEvent. 575 func (lc *LightChain) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription { 576 return lc.scope.Track(lc.chainSideFeed.Subscribe(ch)) 577 } 578 579 // SubscribeLogsEvent implements the interface of filters.Backend 580 // LightChain does not send logs events, so return an empty subscription. 581 func (lc *LightChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription { 582 return lc.scope.Track(new(event.Feed).Subscribe(ch)) 583 } 584 585 // SubscribeRemovedLogsEvent implements the interface of filters.Backend 586 // LightChain does not send core.RemovedLogsEvent, so return an empty subscription. 587 func (lc *LightChain) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription { 588 return lc.scope.Track(new(event.Feed).Subscribe(ch)) 589 } 590 591 // DisableCheckFreq disables header validation. This is used for ultralight mode. 592 func (lc *LightChain) DisableCheckFreq() { 593 atomic.StoreInt32(&lc.disableCheckFreq, 1) 594 } 595 596 // EnableCheckFreq enables header validation. 597 func (lc *LightChain) EnableCheckFreq() { 598 atomic.StoreInt32(&lc.disableCheckFreq, 0) 599 } 600 601 func (lc *LightChain) SupportsMultitenancy(context.Context) (*proto.PreAuthenticatedAuthenticationToken, bool) { 602 return nil, lc.isMultitenant 603 } 604 605 // QuorumConfig retrieves the Quorum chain's configuration 606 func (lc *LightChain) QuorumConfig() *core.QuorumChainConfig { return &core.QuorumChainConfig{} } 607 608 // PrivateStateManager returns the private state manager 609 func (lc *LightChain) PrivateStateManager() mps.PrivateStateManager { return nil } 610 611 // CheckAndSetPrivateState updates the private state as a part contract state extension 612 func (lc *LightChain) CheckAndSetPrivateState(txLogs []*types.Log, privateState *state.StateDB, psi types.PrivateStateIdentifier) { 613 }