-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove config.EVMNetworkID() #3460
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3460 +/- ##
==========================================
- Coverage 75.12% 0 -75.13%
==========================================
Files 243 0 -243
Lines 22514 0 -22514
==========================================
- Hits 16914 0 -16914
+ Misses 4677 0 -4677
+ Partials 923 0 -923 Continue to review full report at Codecov.
|
blockchain/block/blockstore.go
Outdated
func (in *Store) FromProto(pb *iotextypes.BlockStore) error { | ||
// TODO: pass the correct EVM network ID at the time of newFileDAOv2() | ||
blk, err := (&Deserializer{}).SetEvmNetworkID(config.EVMNetworkID()).FromBlockProto(pb.Block) | ||
func (in *Store) FromProto(evmNetworkID uint32, pb *iotextypes.BlockStore) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a store only contains the data of the same evmNetworkID
, then the value should be stored in Store
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,added EVMNetworkID
to Store
blockchain/block/blockstore.go
Outdated
// TODO: pass the correct EVM network ID at the time of newFileDAOv2() | ||
blk, err := (&Deserializer{}).SetEvmNetworkID(config.EVMNetworkID()).FromBlockProto(pb.Block) | ||
func (in *Store) FromProto(evmNetworkID uint32, pb *iotextypes.BlockStore) error { | ||
blk, err := (&Deserializer{}).SetEvmNetworkID(evmNetworkID).FromBlockProto(pb.Block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moreover, I don't see the value of creating a new Deserializer
in each function call
blockchain/filedao/filedao_v2.go
Outdated
} | ||
) | ||
|
||
// newFileDAOv2 creates a new v2 file | ||
func newFileDAOv2(bottom uint64, cfg db.Config) (*fileDAOv2, error) { | ||
func newFileDAOv2(bottom uint64, cfg ModuleConfig) (*fileDAOv2, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get the deserializer from chainbuilder when a new filedao is created .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can have an offline discussion if you have a better solution here
blockchain/filedao/staging_buffer.go
Outdated
@@ -40,7 +40,7 @@ func (s *stagingBuffer) Put(pos uint64, blkBytes []byte) (bool, error) { | |||
return false, ErrNotSupported | |||
} | |||
blk := &block.Store{} | |||
if err := blk.Deserialize(blkBytes); err != nil { | |||
if err := blk.Deserialize(0, blkBytes); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@millken My last comment about store
is wrong. Sorry about that.
blockchain/block/blockstore.go
Outdated
// NewStore creates a new Store | ||
func NewStore(evmNetworkID uint32) *Store { | ||
return &Store{ | ||
EVMNetworkID: evmNetworkID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry about my last comment. I was mislead by the BAD naming.
How could it be named as store
?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean it should be renamed to a more understandable name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's leave the Store
as it is. Do not change anything else in blockdao
and block
. Let's focus on deleting config.EVMNetworkID
in this PR.
So, ignore my previous comments, your implementation is fine.
func extractBlockStore(pbStores *iotextypes.BlockStores, height uint64) (*block.Store, error) { | ||
info := &block.Store{} | ||
func extractBlockStore(evmNetworkID uint32, pbStores *iotextypes.BlockStores, height uint64) (*block.Store, error) { | ||
info := block.NewStore(evmNetworkID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a common deserializer into fileDAOv2
, and here:
info, err := fd.deser.FromBlockStoreProto(v)
chainservice/builder.go
Outdated
@@ -251,8 +251,8 @@ func (builder *Builder) buildBlockDAO(forTest bool) error { | |||
dbConfig := builder.cfg.DB | |||
dbConfig.DbPath = builder.cfg.Chain.ChainDBPath | |||
dbConfig.CompressLegacy = builder.cfg.Chain.CompressBlock | |||
|
|||
builder.cs.blockdao = blockdao.NewBlockDAO(indexers, dbConfig) | |||
blockDAOConfig, _ := blockdao.CreateBlockdaoConfig(dbConfig, blockdao.EVMNetworkIDOption(builder.cfg.Chain.EVMNetworkID)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In product, EVMNetworkID
will always be assigned to initialize blockdao
. Therefore, it is not an option, but a parameter. Accordingly, we may define
blockdao.NewBlockDAO(indexers, evmNetworkID, dbConfig)
and the data structs XXXConfig
are useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
receipt.ConvertFromReceiptPb(receiptPb) | ||
in.Receipts = append(in.Receipts, receipt) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the others look fine
blockchain/filedao/filedao.go
Outdated
// NewFileDAO creates an instance of FileDAO | ||
func NewFileDAO(cfg db.Config) (FileDAO, error) { | ||
func NewFileDAO(cfg Config) (FileDAO, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to blockdao, filedao's config may not be essential.
blockchain/filedao/filedao_legacy.go
Outdated
@@ -51,7 +50,7 @@ type ( | |||
fileDAOLegacy struct { | |||
compressBlock bool | |||
lifecycle lifecycle.Lifecycle | |||
cfg db.Config | |||
cfg Config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
blockchain/filedao/filedao_v2.go
Outdated
} | ||
) | ||
|
||
// newFileDAOv2 creates a new v2 file | ||
func newFileDAOv2(bottom uint64, cfg db.Config) (*fileDAOv2, error) { | ||
func newFileDAOv2(bottom uint64, cfg Config) (*fileDAOv2, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
@@ -42,7 +42,6 @@ func (in *Store) ToProto() *iotextypes.BlockStore { | |||
|
|||
// FromProto converts from proto message | |||
func (in *Store) FromProto(pb *iotextypes.BlockStore) error { | |||
// TODO: pass the correct EVM network ID at the time of newFileDAOv2() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert
blockchain/block/blockstore.go
Outdated
@@ -42,7 +42,6 @@ func (in *Store) ToProto() *iotextypes.BlockStore { | |||
|
|||
// FromProto converts from proto message | |||
func (in *Store) FromProto(pb *iotextypes.BlockStore) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are this function and the deserialize function still in use? if not, we can delete them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
blockchain/block/blockstore.go
Outdated
@@ -42,7 +42,6 @@ func (in *Store) ToProto() *iotextypes.BlockStore { | |||
|
|||
// FromProto converts from proto message | |||
func (in *Store) FromProto(pb *iotextypes.BlockStore) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still need to make it FromProto(pb *iotextypes.BlockStore, evmid uint32)
so we can remove the config.EVMNetworkID()
in line 45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or like @CoderZhi commented, remove it (and fix test)
@@ -61,11 +60,11 @@ type ( | |||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to filedao_v2
, add deser *Deserializer
here
return &fileDAOLegacy{ | ||
compressBlock: cfg.CompressLegacy, | ||
cfg: cfg, | ||
kvStore: db.NewBoltDB(cfg), | ||
kvStore: db.NewBoltDB(cfg.Config), | ||
kvStores: cache.NewThreadSafeLruCache(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and initialize deser
here
blockchain/filedao/filedao_legacy.go
Outdated
@@ -263,8 +262,7 @@ func (fd *fileDAOLegacy) body(h hash.Hash256) (*block.Body, error) { | |||
// block body could be empty | |||
return &block.Body{}, nil | |||
} | |||
// TODO: pass the correct EVM network ID at the time of newFileDAOLegacy() | |||
return (&block.Deserializer{}).SetEvmNetworkID(config.EVMNetworkID()).DeserializeBody(value) | |||
return (&block.Deserializer{}).SetEvmNetworkID(fd.cfg.evmNetworkID).DeserializeBody(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so here just fd.deser.DeserializeBody()
blockchain/filedao/filedao_v2.go
Outdated
@@ -48,11 +48,13 @@ type ( | |||
hashStore db.CountingIndex // store block hash | |||
blkStore db.CountingIndex // store raw blocks | |||
sysStore db.CountingIndex // store transaction log | |||
cfg Config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to add cfg
into the struct? the only new thing needed should be deser *block.Deserializer
below
blockchain/filedao/staging_buffer.go
Outdated
buffer []*block.Store | ||
evmNetworkID uint32 | ||
size uint64 | ||
buffer []*block.Store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to filedao_v2
, add deser *block.Deserializer
blockchain/filedao/staging_buffer.go
Outdated
buffer: make([]*block.Store, size), | ||
evmNetworkID: evmNetworkID, | ||
size: size, | ||
buffer: make([]*block.Store, size), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and initialize deser
here
blockchain/filedao/staging_buffer.go
Outdated
blk := &block.Store{} | ||
if err := blk.Deserialize(blkBytes); err != nil { | ||
deser := (&block.Deserializer{}).SetEvmNetworkID(s.evmNetworkID) | ||
blk, err := deser.DeserializeBlockStore(blkBytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and s.deser.DeserializeBlockStore()
here
} | ||
return info, nil | ||
func extractBlockStore(deser *block.Deserializer, pbStores *iotextypes.BlockStores, height uint64) (*block.Store, error) { | ||
return deser.FromBlockStoreProto(pbStores.BlockStores[height]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove this func, b/c it is just 1 line code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
blockchain/filedao/filedao.go
Outdated
currFd BaseFileDAO | ||
legacyFd FileDAO | ||
v2Fd *FileV2Manager // a collection of v2 db files | ||
deser *block.Deserializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not initialized? if so, is it in use? if yes, why the unit test doesn't cover it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, can remove, added a quick patch to fix it
blockchain/blockchain.go
Outdated
bc.dao = blockdao.NewBlockDAO(indexers, cfg.DB) | ||
bc.dao = blockdao.NewBlockDAO(indexers, cfg.Chain.EVMNetworkID, cfg.DB) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems EVMNetworkID is only for deserializer
, therefore, we may just pass deserializer
into dao in next PR.
fix unit test |
blockchain/filedao/filedao.go
Outdated
currFd BaseFileDAO | ||
legacyFd FileDAO | ||
v2Fd *FileV2Manager // a collection of v2 db files | ||
deser *block.Deserializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deser -> blockDeserializer
* upstream/master: (24 commits) account type with zero init nonce (iotexproject#3387) [api] Separate Server and Server Handler (iotexproject#3485) [ioctl] Build hdwallet derive command line into new ioctl (iotexproject#3418) [ioctl] Build hdwallet create command line into new ioctl (iotexproject#3470) [makefile] add go mod tidy (iotexproject#3471) [api] update chain metrics (iotexproject#3484) remove config.EVMNetworkID() (iotexproject#3460) [filedao] remove checkMasterChainDBFile() (iotexproject#3463) [api] add crashlog (iotexproject#3456) [api] Move generateBlockMeta to grpcserver.go (iotexproject#3303) [ioctl] Build action hash command line into new ioctl (iotexproject#3425) [ioctl] Build hdwallet export command line into new ioctl (iotexproject#3423) [ioctl] Refactor nodereward command in new ioctl (iotexproject#3416) [ioctl] Cleanup TestNewNodeDelegateCmd (iotexproject#3421) [blockchain] Remove BoltDBDaoOption (iotexproject#3465) remove InMemDaoOption (iotexproject#3464) [action] add evm london test (iotexproject#3402) [ioctl] create main for ioctl/newcmd (iotexproject#3296) [ioctl] Build block bucket command line into new ioctl (iotexproject#3386) [ioctl] Build hdwallet import command line into new ioctl (iotexproject#3419) ...
Description
Fixes #3452
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: