Skip to content
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

add some logs #1

Open
wants to merge 1 commit into
base: dev-wenhao
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/geth-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: GethPublisher
on:
workflow_dispatch:
push:
branches: [ dev-wenhao ]
branches: [ dev-hanwang-log ]

env:
# Use docker.io for Docker Hub if empty
Expand Down
20 changes: 18 additions & 2 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ package core

import (
"fmt"
"math/big"
"strconv"
"strings"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc"
Expand All @@ -26,7 +31,6 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"math/big"
)

// StateProcessor is a basic Processor, which takes care of transitioning
Expand Down Expand Up @@ -56,6 +60,10 @@ func NewStateProcessor(config *params.ChainConfig, bc *BlockChain, engine consen
// returns the amount of gas that was used in the process. If any of the
// transactions failed to execute due to insufficient gas it will return an error.
func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, uint64, error) {
start_process := "->->"
start_process_repeat := strings.Repeat(start_process, 20)
fmt.Printf("%v Start state_process\n", start_process_repeat)
startT := time.Now()
var (
receipts types.Receipts
usedGas = new(uint64)
Expand Down Expand Up @@ -98,6 +106,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
blockContext := NewEVMBlockContext(header, p.bc, nil)
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
// Iterate over and process the individual transactions
start_block_transactions := time.Now()
for i, tx := range block.Transactions() {
parityLogContext.TxPos = i
parityLogContext.TxHash = tx.Hash()
Expand All @@ -117,10 +126,17 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
receipts = append(receipts, receipt)
allLogs = append(allLogs, receipt.Logs...)
}
end_block_transactions := time.Since(start_block_transactions)
fmt.Printf("block_transactions, block_number = %v ,cost time = %v\n", strconv.FormatUint(block.NumberU64(), 10), end_block_transactions)

// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles())
vm.ReceiptDumpLogger(block.NumberU64(), 10000, 100, receipts)

tc := time.Since(startT)
fmt.Printf("Execution state_process, block_number = %v ,cost time = %v\n", strconv.FormatUint(block.NumberU64(), 10), tc)
end_process := "^^^^"
end_process_repeat := strings.Repeat(end_process, 20)
fmt.Printf("%v End state_process\n", end_process_repeat)
return receipts, allLogs, *usedGas, nil
}

Expand Down
7 changes: 6 additions & 1 deletion core/vm/dump_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func (l *ParityLogger) CaptureExit(output []byte, gasUsed uint64, err error) {
}

func ReceiptDumpLogger(blockNumber uint64, perFolder, perFile uint64, receipts types.Receipts) error {
startT := time.Now()
file, err := getFile("receipts", blockNumber, perFolder, perFile)
if err != nil {
return err
Expand All @@ -247,6 +248,8 @@ func ReceiptDumpLogger(blockNumber uint64, perFolder, perFile uint64, receipts t
}
}
}
tc := time.Since(startT)
fmt.Printf("Dump receipt, block_number = %v ,cost time = %v\n", strconv.FormatUint(blockNumber, 10), tc)
return nil
}

Expand Down Expand Up @@ -315,6 +318,7 @@ func (t *TxLogger) Close() error {
}

func BlockDumpLogger(block *types.Block, perFolder, perFile uint64) error {
startT := time.Now()
file, err := getFile("blocks", block.NumberU64(), perFolder, perFile)
if err != nil {
return err
Expand All @@ -337,6 +341,7 @@ func BlockDumpLogger(block *types.Block, perFolder, perFile uint64) error {
if err := encoder.Encode(entry); err != nil {
return fmt.Errorf("failed to encode transaction entry %w", err)
}

tc := time.Since(startT)
fmt.Printf("Dump blocks, block_number = %v ,cost time = %v\n", strconv.FormatUint(block.NumberU64(), 10), tc)
return nil
}