diff --git a/.gitignore b/.gitignore index 05c143bd4e..136b5da90f 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ awscpu .idea/ *logs/ +!*customlogs/ .vscode* diff --git a/RELEASES.md b/RELEASES.md index 1130bc2fa8..6e8f0558b1 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -5,6 +5,7 @@ - Major refactor to use [`libevm`](https://github.com/ava-labs/libevm) for EVM execution, database access, types & chain configuration. This improves maintainability and enables keeping up with upstream changes more easily. - Add metrics for ACP-176 - Removed the `"price-options-max-base-fee"` config flag +- Removed extra type support in "ethclient.BlockByHash", "ethclient.BlockByNumber". ## [v0.15.0](https://github.com/ava-labs/coreth/releases/tag/v0.15.0) diff --git a/core/blockchain.go b/core/blockchain.go index 83e1277927..566573a1e2 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -45,6 +45,7 @@ import ( "github.com/ava-labs/coreth/core/state/snapshot" "github.com/ava-labs/coreth/internal/version" "github.com/ava-labs/coreth/params" + "github.com/ava-labs/coreth/plugin/evm/customlogs" "github.com/ava-labs/coreth/plugin/evm/customrawdb" "github.com/ava-labs/coreth/plugin/evm/customtypes" "github.com/ava-labs/coreth/plugin/evm/upgrade/acp176" @@ -594,7 +595,7 @@ func (bc *BlockChain) startAcceptor() { bc.acceptorTipLock.Unlock() // Update accepted feeds - flattenedLogs := customtypes.FlattenLogs(logs) + flattenedLogs := customlogs.FlattenLogs(logs) bc.chainAcceptedFeed.Send(ChainEvent{Block: next, Hash: next.Hash(), Logs: flattenedLogs}) if len(flattenedLogs) > 0 { bc.logsAcceptedFeed.Send(flattenedLogs) @@ -1447,7 +1448,7 @@ func (bc *BlockChain) collectUnflattenedLogs(b *types.Block, removed bool) [][]* // the processing of a block. These logs are later announced as deleted or reborn. func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log { unflattenedLogs := bc.collectUnflattenedLogs(b, removed) - return customtypes.FlattenLogs(unflattenedLogs) + return customlogs.FlattenLogs(unflattenedLogs) } // reorg takes two blocks, an old chain and a new chain and will reconstruct the diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 6239101806..1d037cb37e 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -33,7 +33,7 @@ import ( "math/big" "github.com/ava-labs/coreth/core/bloombits" - "github.com/ava-labs/coreth/plugin/evm/customtypes" + "github.com/ava-labs/coreth/plugin/evm/customlogs" "github.com/ava-labs/coreth/rpc" "github.com/ava-labs/libevm/common" "github.com/ava-labs/libevm/core/types" @@ -342,7 +342,7 @@ func (f *Filter) checkMatches(ctx context.Context, header *types.Header) ([]*typ return nil, err } - unfiltered := customtypes.FlattenLogs(logsList) + unfiltered := customlogs.FlattenLogs(logsList) logs := filterLogs(unfiltered, nil, nil, f.addresses, f.topics) if len(logs) == 0 { return nil, nil diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 3470ea4d1d..54ec673e6d 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -36,7 +36,6 @@ import ( "github.com/ava-labs/coreth/accounts/abi/bind" "github.com/ava-labs/coreth/interfaces" - "github.com/ava-labs/coreth/plugin/evm/customtypes" "github.com/ava-labs/coreth/rpc" ethereum "github.com/ava-labs/libevm" "github.com/ava-labs/libevm/common" @@ -194,11 +193,9 @@ func (ec *client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb } type rpcBlock struct { - Hash common.Hash `json:"hash"` - Transactions []rpcTransaction `json:"transactions"` - UncleHashes []common.Hash `json:"uncles"` - Version uint32 `json:"version"` - BlockExtraData *hexutil.Bytes `json:"blockExtraData"` + Hash common.Hash `json:"hash"` + Transactions []rpcTransaction `json:"transactions"` + UncleHashes []common.Hash `json:"uncles"` } func (ec *client) getBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) { @@ -267,18 +264,10 @@ func (ec *client) getBlock(ctx context.Context, method string, args ...interface } txs[i] = tx.tx } - - block := types.NewBlockWithHeader(head).WithBody( - types.Body{ - Transactions: txs, - Uncles: uncles, - }) - extra := &customtypes.BlockBodyExtra{ - Version: body.Version, - ExtData: (*[]byte)(body.BlockExtraData), - } - customtypes.SetBlockExtra(block, extra) - return block, nil + return types.NewBlockWithHeader(head).WithBody(types.Body{ + Transactions: txs, + Uncles: uncles, + }), nil } // HeaderByHash returns the block header with the given hash. diff --git a/plugin/evm/customtypes/log_ext.go b/plugin/evm/customlogs/log_ext.go similarity index 95% rename from plugin/evm/customtypes/log_ext.go rename to plugin/evm/customlogs/log_ext.go index 25fab842e0..49cbff2e61 100644 --- a/plugin/evm/customtypes/log_ext.go +++ b/plugin/evm/customlogs/log_ext.go @@ -1,6 +1,6 @@ // (c) 2019-2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package customtypes +package customlogs import ethtypes "github.com/ava-labs/libevm/core/types" diff --git a/plugin/evm/imports_test.go b/plugin/evm/imports_test.go index 5089605493..a7ee04daa3 100644 --- a/plugin/evm/imports_test.go +++ b/plugin/evm/imports_test.go @@ -15,7 +15,7 @@ import ( // its recursive package imports (including itself) in the same format. func getDependencies(packageName string) (map[string]struct{}, error) { // Configure the load mode to include dependencies - cfg := &packages.Config{Mode: packages.NeedDeps | packages.NeedImports | packages.NeedName | packages.NeedModule} + cfg := &packages.Config{Mode: packages.NeedImports | packages.NeedName} pkgs, err := packages.Load(cfg, packageName) if err != nil { return nil, fmt.Errorf("failed to load package: %v", err) @@ -38,7 +38,9 @@ func getDependencies(packageName string) (map[string]struct{}, error) { } // Start collecting dependencies - collectDeps(pkgs[0]) + for _, pkg := range pkgs { + collectDeps(pkg) + } return deps, nil } @@ -54,10 +56,12 @@ func TestMustNotImport(t *testing.T) { // Importing these packages configures libevm globally and it is not // possible to do so for both coreth and subnet-evm, where the client may // wish to connect to multiple chains. - "plugin/evm/atomic": {"core", "core/vm", "params"}, - "plugin/evm/client": {"core", "core/vm", "params"}, - "plugin/evm/config": {"core", "core/vm", "params"}, + "plugin/evm/atomic": {"core", "plugin/evm/customtypes", "params"}, + "plugin/evm/client": {"core", "plugin/evm/customtypes", "params"}, + "plugin/evm/config": {"core", "params", "plugin/evm/customtypes"}, "plugin/evm/header": {"core", "core/vm", "params"}, + "ethclient": {"plugin/evm/customtypes", "params"}, + "warp": {"plugin/evm/customtypes", "params"}, } for packageName, forbiddenImports := range mustNotImport {