Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/ava-labs/coreth/core/state"
"github.com/ava-labs/coreth/core/state/snapshot"
"github.com/ava-labs/coreth/internal/version"
customlog "github.com/ava-labs/coreth/log"
"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/plugin/evm/customrawdb"
"github.com/ava-labs/coreth/plugin/evm/customtypes"
Expand Down Expand Up @@ -594,7 +595,7 @@ func (bc *BlockChain) startAcceptor() {
bc.acceptorTipLock.Unlock()

// Update accepted feeds
flattenedLogs := customtypes.FlattenLogs(logs)
flattenedLogs := customlog.FlattenLogs(logs)
bc.chainAcceptedFeed.Send(ChainEvent{Block: next, Hash: next.Hash(), Logs: flattenedLogs})
if len(flattenedLogs) > 0 {
bc.logsAcceptedFeed.Send(flattenedLogs)
Expand Down Expand Up @@ -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 customlog.FlattenLogs(unflattenedLogs)
}

// reorg takes two blocks, an old chain and a new chain and will reconstruct the
Expand Down
4 changes: 2 additions & 2 deletions eth/filters/filter.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a nit change on line 380 of filterLogs you missed

var check = 
to
check :=

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"math/big"

"github.com/ava-labs/coreth/core/bloombits"
"github.com/ava-labs/coreth/plugin/evm/customtypes"
customlog "github.com/ava-labs/coreth/log"
"github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/types"
Expand Down Expand Up @@ -342,7 +342,7 @@ func (f *Filter) checkMatches(ctx context.Context, header *types.Header) ([]*typ
return nil, err
}

unfiltered := customtypes.FlattenLogs(logsList)
unfiltered := customlog.FlattenLogs(logsList)
logs := filterLogs(unfiltered, nil, nil, f.addresses, f.topics)
if len(logs) == 0 {
return nil, nil
Expand Down
27 changes: 8 additions & 19 deletions ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -70,7 +69,7 @@ var (
)

// Client defines interface for typed wrappers for the Ethereum RPC API.
type Client interface {
type Client interface { // Q: why do we need this?
Client() *rpc.Client
Close()
ChainID(context.Context) (*big.Int, error)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/customtypes/log_ext.go → log/log_ext.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// (c) 2019-2025, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package customtypes
package log

import ethtypes "github.com/ava-labs/libevm/core/types"

Expand Down
16 changes: 10 additions & 6 deletions plugin/evm/imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand All @@ -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/header": {"core", "core/vm", "params"},
"plugin/evm/atomic": {"plugin/evm/customtypes", "params"},
"plugin/evm/client": {"plugin/evm/customtypes", "params"},
"plugin/evm/config": {"plugin/evm/customtypes", "params"},
"plugin/evm/header": {"core", "core/vm", "params"}, // Q: why do we need this?
"ethclient": {"plugin/evm/customtypes", "params"},
"warp": {"plugin/evm/customtypes", "params"},
}

for packageName, forbiddenImports := range mustNotImport {
Expand Down
Loading