backend.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. // Copyright 2014 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. // Package eth implements the Ethereum protocol.
  17. package eth
  18. import (
  19. "errors"
  20. "fmt"
  21. "math/big"
  22. "runtime"
  23. "sync"
  24. "sync/atomic"
  25. "time"
  26. "github.com/ethereum/go-ethereum/accounts"
  27. "github.com/ethereum/go-ethereum/common"
  28. "github.com/ethereum/go-ethereum/common/hexutil"
  29. "github.com/ethereum/go-ethereum/consensus"
  30. "github.com/ethereum/go-ethereum/consensus/clique"
  31. "github.com/ethereum/go-ethereum/core"
  32. "github.com/ethereum/go-ethereum/core/bloombits"
  33. "github.com/ethereum/go-ethereum/core/rawdb"
  34. "github.com/ethereum/go-ethereum/core/types"
  35. "github.com/ethereum/go-ethereum/core/vm"
  36. "github.com/ethereum/go-ethereum/eth/downloader"
  37. "github.com/ethereum/go-ethereum/eth/ethconfig"
  38. "github.com/ethereum/go-ethereum/eth/filters"
  39. "github.com/ethereum/go-ethereum/eth/gasprice"
  40. "github.com/ethereum/go-ethereum/eth/protocols/eth"
  41. "github.com/ethereum/go-ethereum/eth/protocols/snap"
  42. "github.com/ethereum/go-ethereum/ethdb"
  43. "github.com/ethereum/go-ethereum/event"
  44. "github.com/ethereum/go-ethereum/internal/ethapi"
  45. "github.com/ethereum/go-ethereum/log"
  46. "github.com/ethereum/go-ethereum/miner"
  47. "github.com/ethereum/go-ethereum/node"
  48. "github.com/ethereum/go-ethereum/p2p"
  49. "github.com/ethereum/go-ethereum/p2p/enode"
  50. "github.com/ethereum/go-ethereum/params"
  51. "github.com/ethereum/go-ethereum/rlp"
  52. "github.com/ethereum/go-ethereum/rpc"
  53. )
  54. // Config contains the configuration options of the ETH protocol.
  55. // Deprecated: use ethconfig.Config instead.
  56. type Config = ethconfig.Config
  57. // Ethereum implements the Ethereum full node service.
  58. type Ethereum struct {
  59. config *ethconfig.Config
  60. // Handlers
  61. txPool *core.TxPool
  62. blockchain *core.BlockChain
  63. handler *handler
  64. ethDialCandidates enode.Iterator
  65. snapDialCandidates enode.Iterator
  66. // DB interfaces
  67. chainDb ethdb.Database // Block chain database
  68. eventMux *event.TypeMux
  69. engine consensus.Engine
  70. accountManager *accounts.Manager
  71. bloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests
  72. bloomIndexer *core.ChainIndexer // Bloom indexer operating during block imports
  73. closeBloomHandler chan struct{}
  74. APIBackend *EthAPIBackend
  75. miner *miner.Miner
  76. gasPrice *big.Int
  77. etherbase common.Address
  78. networkID uint64
  79. netRPCService *ethapi.PublicNetAPI
  80. p2pServer *p2p.Server
  81. lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
  82. }
  83. // New creates a new Ethereum object (including the
  84. // initialisation of the common Ethereum object)
  85. func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
  86. // Ensure configuration values are compatible and sane
  87. if config.SyncMode == downloader.LightSync {
  88. return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum")
  89. }
  90. if !config.SyncMode.IsValid() {
  91. return nil, fmt.Errorf("invalid sync mode %d", config.SyncMode)
  92. }
  93. if config.Miner.GasPrice == nil || config.Miner.GasPrice.Cmp(common.Big0) <= 0 {
  94. log.Warn("Sanitizing invalid miner gas price", "provided", config.Miner.GasPrice, "updated", ethconfig.Defaults.Miner.GasPrice)
  95. config.Miner.GasPrice = new(big.Int).Set(ethconfig.Defaults.Miner.GasPrice)
  96. }
  97. if config.NoPruning && config.TrieDirtyCache > 0 {
  98. if config.SnapshotCache > 0 {
  99. config.TrieCleanCache += config.TrieDirtyCache * 3 / 5
  100. config.SnapshotCache += config.TrieDirtyCache * 2 / 5
  101. } else {
  102. config.TrieCleanCache += config.TrieDirtyCache
  103. }
  104. config.TrieDirtyCache = 0
  105. }
  106. log.Info("Allocated trie memory caches", "clean", common.StorageSize(config.TrieCleanCache)*1024*1024, "dirty", common.StorageSize(config.TrieDirtyCache)*1024*1024)
  107. // Assemble the Ethereum object
  108. chainDb, err := stack.OpenDatabaseWithFreezer("chaindata", config.DatabaseCache, config.DatabaseHandles, config.DatabaseFreezer, "eth/db/chaindata/")
  109. if err != nil {
  110. return nil, err
  111. }
  112. chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis)
  113. if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
  114. return nil, genesisErr
  115. }
  116. log.Info("Initialised chain configuration", "config", chainConfig)
  117. eth := &Ethereum{
  118. config: config,
  119. chainDb: chainDb,
  120. eventMux: stack.EventMux(),
  121. accountManager: stack.AccountManager(),
  122. engine: ethconfig.CreateConsensusEngine(stack, chainConfig, &config.Ethash, config.Miner.Notify, config.Miner.Noverify, chainDb),
  123. closeBloomHandler: make(chan struct{}),
  124. networkID: config.NetworkId,
  125. gasPrice: config.Miner.GasPrice,
  126. etherbase: config.Miner.Etherbase,
  127. bloomRequests: make(chan chan *bloombits.Retrieval),
  128. bloomIndexer: core.NewBloomIndexer(chainDb, params.BloomBitsBlocks, params.BloomConfirms),
  129. p2pServer: stack.Server(),
  130. }
  131. bcVersion := rawdb.ReadDatabaseVersion(chainDb)
  132. var dbVer = "<nil>"
  133. if bcVersion != nil {
  134. dbVer = fmt.Sprintf("%d", *bcVersion)
  135. }
  136. log.Info("Initialising Ethereum protocol", "network", config.NetworkId, "dbversion", dbVer)
  137. if !config.SkipBcVersionCheck {
  138. if bcVersion != nil && *bcVersion > core.BlockChainVersion {
  139. return nil, fmt.Errorf("database version is v%d, Geth %s only supports v%d", *bcVersion, params.VersionWithMeta, core.BlockChainVersion)
  140. } else if bcVersion == nil || *bcVersion < core.BlockChainVersion {
  141. log.Warn("Upgrade blockchain database version", "from", dbVer, "to", core.BlockChainVersion)
  142. rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion)
  143. }
  144. }
  145. var (
  146. vmConfig = vm.Config{
  147. EnablePreimageRecording: config.EnablePreimageRecording,
  148. EWASMInterpreter: config.EWASMInterpreter,
  149. EVMInterpreter: config.EVMInterpreter,
  150. }
  151. cacheConfig = &core.CacheConfig{
  152. TrieCleanLimit: config.TrieCleanCache,
  153. TrieCleanJournal: stack.ResolvePath(config.TrieCleanCacheJournal),
  154. TrieCleanRejournal: config.TrieCleanCacheRejournal,
  155. TrieCleanNoPrefetch: config.NoPrefetch,
  156. TrieDirtyLimit: config.TrieDirtyCache,
  157. TrieDirtyDisabled: config.NoPruning,
  158. TrieTimeLimit: config.TrieTimeout,
  159. SnapshotLimit: config.SnapshotCache,
  160. Preimages: config.Preimages,
  161. }
  162. )
  163. eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, chainConfig, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit)
  164. if err != nil {
  165. return nil, err
  166. }
  167. // Rewind the chain in case of an incompatible config upgrade.
  168. if compat, ok := genesisErr.(*params.ConfigCompatError); ok {
  169. log.Warn("Rewinding chain to upgrade configuration", "err", compat)
  170. eth.blockchain.SetHead(compat.RewindTo)
  171. rawdb.WriteChainConfig(chainDb, genesisHash, chainConfig)
  172. }
  173. eth.bloomIndexer.Start(eth.blockchain)
  174. if config.TxPool.Journal != "" {
  175. config.TxPool.Journal = stack.ResolvePath(config.TxPool.Journal)
  176. }
  177. eth.txPool = core.NewTxPool(config.TxPool, chainConfig, eth.blockchain)
  178. // Permit the downloader to use the trie cache allowance during fast sync
  179. cacheLimit := cacheConfig.TrieCleanLimit + cacheConfig.TrieDirtyLimit + cacheConfig.SnapshotLimit
  180. checkpoint := config.Checkpoint
  181. if checkpoint == nil {
  182. checkpoint = params.TrustedCheckpoints[genesisHash]
  183. }
  184. if eth.handler, err = newHandler(&handlerConfig{
  185. Database: chainDb,
  186. Chain: eth.blockchain,
  187. TxPool: eth.txPool,
  188. Network: config.NetworkId,
  189. Sync: config.SyncMode,
  190. BloomCache: uint64(cacheLimit),
  191. EventMux: eth.eventMux,
  192. Checkpoint: checkpoint,
  193. Whitelist: config.Whitelist,
  194. }); err != nil {
  195. return nil, err
  196. }
  197. eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock)
  198. eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
  199. eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), eth, nil}
  200. gpoParams := config.GPO
  201. if gpoParams.Default == nil {
  202. gpoParams.Default = config.Miner.GasPrice
  203. }
  204. eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
  205. eth.ethDialCandidates, err = setupDiscovery(eth.config.EthDiscoveryURLs)
  206. if err != nil {
  207. return nil, err
  208. }
  209. eth.snapDialCandidates, err = setupDiscovery(eth.config.SnapDiscoveryURLs)
  210. if err != nil {
  211. return nil, err
  212. }
  213. // Start the RPC service
  214. eth.netRPCService = ethapi.NewPublicNetAPI(eth.p2pServer, config.NetworkId)
  215. // Register the backend on the node
  216. stack.RegisterAPIs(eth.APIs())
  217. stack.RegisterProtocols(eth.Protocols())
  218. stack.RegisterLifecycle(eth)
  219. // Check for unclean shutdown
  220. if uncleanShutdowns, discards, err := rawdb.PushUncleanShutdownMarker(chainDb); err != nil {
  221. log.Error("Could not update unclean-shutdown-marker list", "error", err)
  222. } else {
  223. if discards > 0 {
  224. log.Warn("Old unclean shutdowns found", "count", discards)
  225. }
  226. for _, tstamp := range uncleanShutdowns {
  227. t := time.Unix(int64(tstamp), 0)
  228. log.Warn("Unclean shutdown detected", "booted", t,
  229. "age", common.PrettyAge(t))
  230. }
  231. }
  232. return eth, nil
  233. }
  234. func makeExtraData(extra []byte) []byte {
  235. if len(extra) == 0 {
  236. // create default extradata
  237. extra, _ = rlp.EncodeToBytes([]interface{}{
  238. uint(params.VersionMajor<<16 | params.VersionMinor<<8 | params.VersionPatch),
  239. "geth",
  240. runtime.Version(),
  241. runtime.GOOS,
  242. })
  243. }
  244. if uint64(len(extra)) > params.MaximumExtraDataSize {
  245. log.Warn("Miner extra data exceed limit", "extra", hexutil.Bytes(extra), "limit", params.MaximumExtraDataSize)
  246. extra = nil
  247. }
  248. return extra
  249. }
  250. // APIs return the collection of RPC services the ethereum package offers.
  251. // NOTE, some of these services probably need to be moved to somewhere else.
  252. func (s *Ethereum) APIs() []rpc.API {
  253. apis := ethapi.GetAPIs(s.APIBackend)
  254. // Append any APIs exposed explicitly by the consensus engine
  255. apis = append(apis, s.engine.APIs(s.BlockChain())...)
  256. // Append all the local APIs and return
  257. return append(apis, []rpc.API{
  258. {
  259. Namespace: "eth",
  260. Version: "1.0",
  261. Service: NewPublicEthereumAPI(s),
  262. Public: true,
  263. }, {
  264. Namespace: "eth",
  265. Version: "1.0",
  266. Service: NewPublicMinerAPI(s),
  267. Public: true,
  268. }, {
  269. Namespace: "eth",
  270. Version: "1.0",
  271. Service: downloader.NewPublicDownloaderAPI(s.handler.downloader, s.eventMux),
  272. Public: true,
  273. }, {
  274. Namespace: "miner",
  275. Version: "1.0",
  276. Service: NewPrivateMinerAPI(s),
  277. Public: false,
  278. }, {
  279. Namespace: "eth",
  280. Version: "1.0",
  281. Service: filters.NewPublicFilterAPI(s.APIBackend, false, 5*time.Minute),
  282. Public: true,
  283. }, {
  284. Namespace: "admin",
  285. Version: "1.0",
  286. Service: NewPrivateAdminAPI(s),
  287. }, {
  288. Namespace: "debug",
  289. Version: "1.0",
  290. Service: NewPublicDebugAPI(s),
  291. Public: true,
  292. }, {
  293. Namespace: "debug",
  294. Version: "1.0",
  295. Service: NewPrivateDebugAPI(s),
  296. }, {
  297. Namespace: "net",
  298. Version: "1.0",
  299. Service: s.netRPCService,
  300. Public: true,
  301. },
  302. }...)
  303. }
  304. func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) {
  305. s.blockchain.ResetWithGenesisBlock(gb)
  306. }
  307. func (s *Ethereum) Etherbase() (eb common.Address, err error) {
  308. s.lock.RLock()
  309. etherbase := s.etherbase
  310. s.lock.RUnlock()
  311. if etherbase != (common.Address{}) {
  312. return etherbase, nil
  313. }
  314. if wallets := s.AccountManager().Wallets(); len(wallets) > 0 {
  315. if accounts := wallets[0].Accounts(); len(accounts) > 0 {
  316. etherbase := accounts[0].Address
  317. s.lock.Lock()
  318. s.etherbase = etherbase
  319. s.lock.Unlock()
  320. log.Info("Etherbase automatically configured", "address", etherbase)
  321. return etherbase, nil
  322. }
  323. }
  324. return common.Address{}, fmt.Errorf("etherbase must be explicitly specified")
  325. }
  326. // isLocalBlock checks whether the specified block is mined
  327. // by local miner accounts.
  328. //
  329. // We regard two types of accounts as local miner account: etherbase
  330. // and accounts specified via `txpool.locals` flag.
  331. func (s *Ethereum) isLocalBlock(block *types.Block) bool {
  332. author, err := s.engine.Author(block.Header())
  333. if err != nil {
  334. log.Warn("Failed to retrieve block author", "number", block.NumberU64(), "hash", block.Hash(), "err", err)
  335. return false
  336. }
  337. // Check whether the given address is etherbase.
  338. s.lock.RLock()
  339. etherbase := s.etherbase
  340. s.lock.RUnlock()
  341. if author == etherbase {
  342. return true
  343. }
  344. // Check whether the given address is specified by `txpool.local`
  345. // CLI flag.
  346. for _, account := range s.config.TxPool.Locals {
  347. if account == author {
  348. return true
  349. }
  350. }
  351. return false
  352. }
  353. // shouldPreserve checks whether we should preserve the given block
  354. // during the chain reorg depending on whether the author of block
  355. // is a local account.
  356. func (s *Ethereum) shouldPreserve(block *types.Block) bool {
  357. // The reason we need to disable the self-reorg preserving for clique
  358. // is it can be probable to introduce a deadlock.
  359. //
  360. // e.g. If there are 7 available signers
  361. //
  362. // r1 A
  363. // r2 B
  364. // r3 C
  365. // r4 D
  366. // r5 A [X] F G
  367. // r6 [X]
  368. //
  369. // In the round5, the inturn signer E is offline, so the worst case
  370. // is A, F and G sign the block of round5 and reject the block of opponents
  371. // and in the round6, the last available signer B is offline, the whole
  372. // network is stuck.
  373. if _, ok := s.engine.(*clique.Clique); ok {
  374. return false
  375. }
  376. return s.isLocalBlock(block)
  377. }
  378. // SetEtherbase sets the mining reward address.
  379. func (s *Ethereum) SetEtherbase(etherbase common.Address) {
  380. s.lock.Lock()
  381. s.etherbase = etherbase
  382. s.lock.Unlock()
  383. s.miner.SetEtherbase(etherbase)
  384. }
  385. // StartMining starts the miner with the given number of CPU threads. If mining
  386. // is already running, this method adjust the number of threads allowed to use
  387. // and updates the minimum price required by the transaction pool.
  388. func (s *Ethereum) StartMining(threads int) error {
  389. // Update the thread count within the consensus engine
  390. type threaded interface {
  391. SetThreads(threads int)
  392. }
  393. if th, ok := s.engine.(threaded); ok {
  394. log.Info("Updated mining threads", "threads", threads)
  395. if threads == 0 {
  396. threads = -1 // Disable the miner from within
  397. }
  398. th.SetThreads(threads)
  399. }
  400. // If the miner was not running, initialize it
  401. if !s.IsMining() {
  402. // Propagate the initial price point to the transaction pool
  403. s.lock.RLock()
  404. price := s.gasPrice
  405. s.lock.RUnlock()
  406. s.txPool.SetGasPrice(price)
  407. // Configure the local mining address
  408. eb, err := s.Etherbase()
  409. if err != nil {
  410. log.Error("Cannot start mining without etherbase", "err", err)
  411. return fmt.Errorf("etherbase missing: %v", err)
  412. }
  413. if clique, ok := s.engine.(*clique.Clique); ok {
  414. wallet, err := s.accountManager.Find(accounts.Account{Address: eb})
  415. if wallet == nil || err != nil {
  416. log.Error("Etherbase account unavailable locally", "err", err)
  417. return fmt.Errorf("signer missing: %v", err)
  418. }
  419. clique.Authorize(eb, wallet.SignData)
  420. }
  421. // If mining is started, we can disable the transaction rejection mechanism
  422. // introduced to speed sync times.
  423. atomic.StoreUint32(&s.handler.acceptTxs, 1)
  424. go s.miner.Start(eb)
  425. }
  426. return nil
  427. }
  428. // StopMining terminates the miner, both at the consensus engine level as well as
  429. // at the block creation level.
  430. func (s *Ethereum) StopMining() {
  431. // Update the thread count within the consensus engine
  432. type threaded interface {
  433. SetThreads(threads int)
  434. }
  435. if th, ok := s.engine.(threaded); ok {
  436. th.SetThreads(-1)
  437. }
  438. // Stop the block creating itself
  439. s.miner.Stop()
  440. }
  441. func (s *Ethereum) IsMining() bool { return s.miner.Mining() }
  442. func (s *Ethereum) Miner() *miner.Miner { return s.miner }
  443. func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager }
  444. func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain }
  445. func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
  446. func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux }
  447. func (s *Ethereum) Engine() consensus.Engine { return s.engine }
  448. func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
  449. func (s *Ethereum) IsListening() bool { return true } // Always listening
  450. func (s *Ethereum) Downloader() *downloader.Downloader { return s.handler.downloader }
  451. func (s *Ethereum) Synced() bool { return atomic.LoadUint32(&s.handler.acceptTxs) == 1 }
  452. func (s *Ethereum) ArchiveMode() bool { return s.config.NoPruning }
  453. func (s *Ethereum) BloomIndexer() *core.ChainIndexer { return s.bloomIndexer }
  454. // Protocols returns all the currently configured
  455. // network protocols to start.
  456. func (s *Ethereum) Protocols() []p2p.Protocol {
  457. protos := eth.MakeProtocols((*ethHandler)(s.handler), s.networkID, s.ethDialCandidates)
  458. if s.config.SnapshotCache > 0 {
  459. protos = append(protos, snap.MakeProtocols((*snapHandler)(s.handler), s.snapDialCandidates)...)
  460. }
  461. return protos
  462. }
  463. // Start implements node.Lifecycle, starting all internal goroutines needed by the
  464. // Ethereum protocol implementation.
  465. func (s *Ethereum) Start() error {
  466. eth.StartENRUpdater(s.blockchain, s.p2pServer.LocalNode())
  467. // Start the bloom bits servicing goroutines
  468. s.startBloomHandlers(params.BloomBitsBlocks)
  469. // Figure out a max peers count based on the server limits
  470. maxPeers := s.p2pServer.MaxPeers
  471. if s.config.LightServ > 0 {
  472. if s.config.LightPeers >= s.p2pServer.MaxPeers {
  473. return fmt.Errorf("invalid peer config: light peer count (%d) >= total peer count (%d)", s.config.LightPeers, s.p2pServer.MaxPeers)
  474. }
  475. maxPeers -= s.config.LightPeers
  476. }
  477. // Start the networking layer and the light server if requested
  478. s.handler.Start(maxPeers)
  479. return nil
  480. }
  481. // Stop implements node.Lifecycle, terminating all internal goroutines used by the
  482. // Ethereum protocol.
  483. func (s *Ethereum) Stop() error {
  484. // Stop all the peer-related stuff first.
  485. s.handler.Stop()
  486. // Then stop everything else.
  487. s.bloomIndexer.Close()
  488. close(s.closeBloomHandler)
  489. s.txPool.Stop()
  490. s.miner.Stop()
  491. s.blockchain.Stop()
  492. s.engine.Close()
  493. rawdb.PopUncleanShutdownMarker(s.chainDb)
  494. s.chainDb.Close()
  495. s.eventMux.Stop()
  496. return nil
  497. }