diff options
Diffstat (limited to 'light')
-rw-r--r-- | light/odr_test.go | 8 | ||||
-rw-r--r-- | light/postprocess.go | 23 |
2 files changed, 10 insertions, 21 deletions
diff --git a/light/odr_test.go b/light/odr_test.go index c1762c43e..55725d84e 100644 --- a/light/odr_test.go +++ b/light/odr_test.go @@ -99,7 +99,7 @@ func (odr *testOdr) IndexerConfig() *IndexerConfig { type odrTestFn func(ctx context.Context, db ethdb.Database, bc *core.BlockChain, lc *LightChain, bhash common.Hash) ([]byte, error) -func TestOdrGetBlockLes1(t *testing.T) { testChainOdr(t, 1, odrGetBlock) } +func TestOdrGetBlockLes2(t *testing.T) { testChainOdr(t, 1, odrGetBlock) } func odrGetBlock(ctx context.Context, db ethdb.Database, bc *core.BlockChain, lc *LightChain, bhash common.Hash) ([]byte, error) { var block *types.Block @@ -115,7 +115,7 @@ func odrGetBlock(ctx context.Context, db ethdb.Database, bc *core.BlockChain, lc return rlp, nil } -func TestOdrGetReceiptsLes1(t *testing.T) { testChainOdr(t, 1, odrGetReceipts) } +func TestOdrGetReceiptsLes2(t *testing.T) { testChainOdr(t, 1, odrGetReceipts) } func odrGetReceipts(ctx context.Context, db ethdb.Database, bc *core.BlockChain, lc *LightChain, bhash common.Hash) ([]byte, error) { var receipts types.Receipts @@ -137,7 +137,7 @@ func odrGetReceipts(ctx context.Context, db ethdb.Database, bc *core.BlockChain, return rlp, nil } -func TestOdrAccountsLes1(t *testing.T) { testChainOdr(t, 1, odrAccounts) } +func TestOdrAccountsLes2(t *testing.T) { testChainOdr(t, 1, odrAccounts) } func odrAccounts(ctx context.Context, db ethdb.Database, bc *core.BlockChain, lc *LightChain, bhash common.Hash) ([]byte, error) { dummyAddr := common.HexToAddress("1234567812345678123456781234567812345678") @@ -161,7 +161,7 @@ func odrAccounts(ctx context.Context, db ethdb.Database, bc *core.BlockChain, lc return res, st.Error() } -func TestOdrContractCallLes1(t *testing.T) { testChainOdr(t, 1, odrContractCall) } +func TestOdrContractCallLes2(t *testing.T) { testChainOdr(t, 1, odrContractCall) } type callmsg struct { types.Message diff --git a/light/postprocess.go b/light/postprocess.go index 306de4694..2a837e6c1 100644 --- a/light/postprocess.go +++ b/light/postprocess.go @@ -41,9 +41,6 @@ type IndexerConfig struct { // The block frequency for creating CHTs. ChtSize uint64 - // A special auxiliary field represents client's chtsize for server config, otherwise represents server's chtsize. - PairChtSize uint64 - // The number of confirmations needed to generate/accept a canonical hash help trie. ChtConfirms uint64 @@ -64,8 +61,7 @@ type IndexerConfig struct { var ( // DefaultServerIndexerConfig wraps a set of configs as a default indexer config for server side. DefaultServerIndexerConfig = &IndexerConfig{ - ChtSize: params.CHTFrequencyServer, - PairChtSize: params.CHTFrequencyClient, + ChtSize: params.CHTFrequency, ChtConfirms: params.HelperTrieProcessConfirmations, BloomSize: params.BloomBitsBlocks, BloomConfirms: params.BloomConfirms, @@ -74,8 +70,7 @@ var ( } // DefaultClientIndexerConfig wraps a set of configs as a default indexer config for client side. DefaultClientIndexerConfig = &IndexerConfig{ - ChtSize: params.CHTFrequencyClient, - PairChtSize: params.CHTFrequencyServer, + ChtSize: params.CHTFrequency, ChtConfirms: params.HelperTrieConfirmations, BloomSize: params.BloomBitsBlocksClient, BloomConfirms: params.HelperTrieConfirmations, @@ -84,8 +79,7 @@ var ( } // TestServerIndexerConfig wraps a set of configs as a test indexer config for server side. TestServerIndexerConfig = &IndexerConfig{ - ChtSize: 64, - PairChtSize: 512, + ChtSize: 512, ChtConfirms: 4, BloomSize: 64, BloomConfirms: 4, @@ -95,7 +89,6 @@ var ( // TestClientIndexerConfig wraps a set of configs as a test indexer config for client side. TestClientIndexerConfig = &IndexerConfig{ ChtSize: 512, - PairChtSize: 64, ChtConfirms: 32, BloomSize: 512, BloomConfirms: 32, @@ -116,7 +109,7 @@ var ( ErrNoTrustedCht = errors.New("no trusted canonical hash trie") ErrNoTrustedBloomTrie = errors.New("no trusted bloom trie") ErrNoHeader = errors.New("header not found") - chtPrefix = []byte("chtRoot-") // chtPrefix + chtNum (uint64 big endian) -> trie root hash + chtPrefix = []byte("chtRootV2-") // chtPrefix + chtNum (uint64 big endian) -> trie root hash ChtTablePrefix = "cht-" ) @@ -127,7 +120,6 @@ type ChtNode struct { } // GetChtRoot reads the CHT root associated to the given section from the database -// Note that sectionIdx is specified according to LES/1 CHT section size. func GetChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead common.Hash) common.Hash { var encNumber [8]byte binary.BigEndian.PutUint64(encNumber[:], sectionIdx) @@ -136,7 +128,6 @@ func GetChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead common.Hash) c } // StoreChtRoot writes the CHT root associated to the given section into the database -// Note that sectionIdx is specified according to LES/1 CHT section size. func StoreChtRoot(db ethdb.Database, sectionIdx uint64, sectionHead, root common.Hash) { var encNumber [8]byte binary.BigEndian.PutUint64(encNumber[:], sectionIdx) @@ -163,7 +154,7 @@ func NewChtIndexer(db ethdb.Database, odr OdrBackend, size, confirms uint64) *co triedb: trie.NewDatabaseWithCache(trieTable, 1), // Use a tiny cache only to keep memory down sectionSize: size, } - return core.NewChainIndexer(db, rawdb.NewTable(db, "chtIndex-"), backend, size, confirms, time.Millisecond*100, "cht") + return core.NewChainIndexer(db, rawdb.NewTable(db, "chtIndexV2-"), backend, size, confirms, time.Millisecond*100, "cht") } // fetchMissingNodes tries to retrieve the last entry of the latest trusted CHT from the @@ -235,9 +226,7 @@ func (c *ChtIndexerBackend) Commit() error { } c.triedb.Commit(root, false) - if ((c.section+1)*c.sectionSize)%params.CHTFrequencyClient == 0 { - log.Info("Storing CHT", "section", c.section*c.sectionSize/params.CHTFrequencyClient, "head", fmt.Sprintf("%064x", c.lastHash), "root", fmt.Sprintf("%064x", root)) - } + log.Info("Storing CHT", "section", c.section, "head", fmt.Sprintf("%064x", c.lastHash), "root", fmt.Sprintf("%064x", root)) StoreChtRoot(c.diskdb, c.section, c.lastHash, root) return nil } |