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

Merge v2022.04.05 #2

Merged
merged 44 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
39804f3
block by timestamp for stable (#3617)
enriavil1 Feb 25, 2022
9b593bf
Add timings of forward stages to logs (#3621)
AskAlexSharov Feb 25, 2022
f35b9b2
deleted bor and starknet from doc (#3627)
enriavil1 Feb 26, 2022
5c0e683
add nosqlite tag (#3653)
AskAlexSharov Mar 7, 2022
bde975f
save (#3665)
AskAlexSharov Mar 9, 2022
86680c5
save (#3663)
AskAlexSharov Mar 9, 2022
6fd8f98
linter up (#3672) (#3673)
AskAlexSharov Mar 10, 2022
a52e53a
Revert node DB cache (#3581) (#3674) (#3675)
battlmonstr Mar 10, 2022
461ac47
[stable] Fixes to discovery nodedb (#3691)
AlexeyAkhunov Mar 14, 2022
0fe1dcc
[stable] Fixes for state overrides in RPC (#3693)
AlexeyAkhunov Mar 15, 2022
aca7d9b
new bootnodes (#3591) (#3695)
AlexeyAkhunov Mar 15, 2022
8d4f91b
Update skip analysis and preverified hashes (#3700) (#3704)
AlexeyAkhunov Mar 15, 2022
25a68e0
Update version.go (#3701)
AlexeyAkhunov Mar 15, 2022
7ce2134
rpcdaemon: fix TxContext in traceBlock (#3716)
cannium Mar 16, 2022
785539f
Mdbx: WriteMap fallback on error (#3714)
AskAlexSharov Mar 17, 2022
2071fe9
Pool cost fix (#3725)
AskAlexSharov Mar 17, 2022
c6c02fe
mdbx v0.11.6 (#3771)
AskAlexSharov Mar 25, 2022
a9b09ba
mdbx fix after v0.11.6 (#3775)
AskAlexSharov Mar 27, 2022
c12f898
[stable] Event log subscription (#3773)
AlexeyAkhunov Mar 27, 2022
58f23b8
Update version.go (#3776)
AlexeyAkhunov Mar 27, 2022
997846f
Update Skip analysis and preverified hashes (#3777) (#3778)
AlexeyAkhunov Mar 27, 2022
12173a2
Integration: reset StageFinish also (#3783)
AskAlexSharov Mar 29, 2022
ae9757f
docker hub - fetch git tags before build #3781
AskAlexSharov Mar 29, 2022
73feffa
fix nil pointer in fetch.go (#3802)
AskAlexSharov Apr 1, 2022
59cd45b
Update preverified hashes and skip analysis (#3831) (#3832)
AlexeyAkhunov Apr 5, 2022
e035171
Fix 'all defaults' case for eth_estimateGas (#3790) (#3824)
AlexeyAkhunov Apr 5, 2022
dcf2e32
Update version.go (#3829)
AlexeyAkhunov Apr 5, 2022
3a2319a
Change libmdbx submodule origin (#3894)
AskAlexSharov Apr 15, 2022
3671b58
Update to erigon-lib stable (#3895)
AlexeyAkhunov Apr 15, 2022
e6563fe
Update version.go (#3896)
AlexeyAkhunov Apr 15, 2022
d139c75
Update skip_analysis.go (#3897) (#3898)
AlexeyAkhunov Apr 15, 2022
7b057c0
save (#3904)
AskAlexSharov Apr 17, 2022
ea4f1b4
[stable] Fixes for header download (#3911)
AlexeyAkhunov Apr 19, 2022
d52150b
save (#3916)
AskAlexSharov Apr 19, 2022
b35e87c
Update libmdbx source (#3974)
AndreaLanfranchi Apr 26, 2022
28c62ff
Makefile (#3779): pass docker build arguments (#4239)
battlmonstr May 25, 2022
e920580
save (#4346)
AskAlexSharov Jun 4, 2022
ed142de
Gray Glacier bomb delay (#4444)
yperbasis Jun 14, 2022
a8b92f8
Update version.go on stable branch (#4447)
AlexeyAkhunov Jun 14, 2022
0ddac41
Clean up
Jun 14, 2022
20b3665
in transaction execution, subtract from account balance only after en…
sudeepdino008 Jun 14, 2022
3cc1cc7
Update skip_analysis.go (#4452)
AlexeyAkhunov Jun 14, 2022
5f8c026
Adjust version
Jun 15, 2022
686a782
Merge tag 'v2022.04.05' into erigon1-bce-dev
bgelb Jun 16, 2022
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
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
docker:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: git submodule update --init --recursive --force
- run: docker build .
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0 # fetch git tags for "git describe"
- run: make docker
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
url = https://github.com/ethereum/tests
[submodule "libmdbx"]
path = libmdbx
url = https://github.com/erthink/libmdbx
url = https://github.com/torquem-ch/libmdbx.git
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ EXPOSE 8545 8546 30303 30303/udp 30304 30304/udp 8080 9090 6060
# https://github.com/opencontainers/image-spec/blob/main/annotations.md
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Erigon" \
org.label-schema.description="Erigon Ethereum Client" \
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GOTEST = GODEBUG=cgocheck=0 $(GO) test -tags nosqlite -trimpath ./... -p 2

GIT_COMMIT ?= $(shell git rev-list -1 HEAD)
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
GIT_TAG ?= $(shell git describe --tags `git rev-list --tags="v*" --max-count=1`)
GIT_TAG ?= $(shell git describe --tags '--match=v*')

CGO_CFLAGS := $(shell $(GO) env CGO_CFLAGS) # don't loose default
CGO_CFLAGS += -DMDBX_FORCE_ASSERTIONS=0 # Enable MDBX's asserts by default in 'devel' branch and disable in 'stable'
Expand All @@ -26,7 +26,12 @@ go-version:
fi

docker:
DOCKER_BUILDKIT=1 docker build -t erigon:latest --build-arg git_commit='${GIT_COMMIT}' --build-arg git_branch='${GIT_BRANCH}' --build-arg git_tag='${GIT_TAG}' .
DOCKER_BUILDKIT=1 docker build \
--build-arg "BUILD_DATE=$(shell date -Iseconds)" \
--build-arg VCS_REF=${GIT_COMMIT} \
--build-arg VERSION=${GIT_TAG} \
${DOCKER_FLAGS} \
.

xdg_data_home := ~/.local/share
ifdef XDG_DATA_HOME
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ NB! <code>In-depth links are marked by the microscope sign (🔬) </code>
**Disclaimer: this software is currently a tech preview. We will do our best to keep it stable and make no breaking
changes but we don't guarantee anything. Things can and will break.**

<code>🔬 Alpha/Beta versions difference: [here](https://erigon.substack.com/p/erigon-2-three-upgrades?s=r)</code>

System Requirements
===================
Expand All @@ -45,7 +46,7 @@ folder `<datadir>/etl-tmp` to another disk).

RAM: 16GB, 64-bit architecture, [Golang version >= 1.16](https://golang.org/doc/install)

<code>🔬 more info on disk storage is [here](https://ledgerwatch.github.io/turbo_geth_release.html#Disk-space)) </code>
<code>🔬 more details on disk storage [here](https://erigon.substack.com/p/disk-footprint-changes-in-new-erigon?s=r) and [here](https://ledgerwatch.github.io/turbo_geth_release.html#Disk-space).</code>

Usage
=====
Expand Down
13 changes: 11 additions & 2 deletions cmd/erigon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/ledgerwatch/erigon/common/debug"
"github.com/ledgerwatch/erigon-lib/common/dbg"
"github.com/ledgerwatch/erigon/params"
erigoncli "github.com/ledgerwatch/erigon/turbo/cli"
"github.com/ledgerwatch/erigon/turbo/node"
Expand All @@ -13,7 +13,16 @@ import (
)

func main() {
defer debug.LogPanic()
defer func() {
panicResult := recover()
if panicResult == nil {
return
}

log.Error("catch panic", "err", panicResult, "stack", dbg.Stack())
os.Exit(1)
}()

app := erigoncli.MakeApp(runErigon, erigoncli.DefaultFlags)
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/integration/commands/state_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func syncBySmallSteps(db kv.RwDB, miningConfig params.MiningConfig, ctx context.

stateStages.DisableStages(stages.Headers, stages.BlockHashes, stages.Bodies, stages.Senders,
stages.TxPool, // TODO: enable TxPoolDB stage
stages.Finish)
)

execCfg := stagedsync.StageExecuteBlocksCfg(db, pm, batchSize, changeSetHook, chainConfig, engine, vmConfig, nil, false, tmpDir)

Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type EthAPI interface {

// Sending related (see ./eth_call.go)
Call(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *ethapi.StateOverrides) (hexutil.Bytes, error)
EstimateGas(ctx context.Context, args ethapi.CallArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error)
EstimateGas(ctx context.Context, argsOrNil *ethapi.CallArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error)
SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)
SendTransaction(_ context.Context, txObject interface{}) (common.Hash, error)
Sign(ctx context.Context, _ common.Address, _ hexutil.Bytes) (hexutil.Bytes, error)
Expand Down
8 changes: 7 additions & 1 deletion cmd/rpcdaemon/commands/eth_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ func HeaderByNumberOrHash(ctx context.Context, tx kv.Tx, blockNrOrHash rpc.Block
}

// EstimateGas implements eth_estimateGas. Returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain.
func (api *APIImpl) EstimateGas(ctx context.Context, args ethapi.CallArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) {
func (api *APIImpl) EstimateGas(ctx context.Context, argsOrNil *ethapi.CallArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) {
var args ethapi.CallArgs
// if we actually get CallArgs here, we use them
if argsOrNil != nil {
args = *argsOrNil
}

bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber)
if blockNrOrHash != nil {
bNrOrHash = *blockNrOrHash
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/eth_call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestEstimateGas(t *testing.T) {
api := NewEthAPI(NewBaseApi(nil, stateCache, false), db, nil, nil, nil, 5000000)
var from = common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7")
var to = common.HexToAddress("0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e")
if _, err := api.EstimateGas(context.Background(), ethapi.CallArgs{
if _, err := api.EstimateGas(context.Background(), &ethapi.CallArgs{
From: &from,
To: &to,
}, nil); err != nil {
Expand Down
36 changes: 36 additions & 0 deletions cmd/rpcdaemon/commands/eth_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ledgerwatch/erigon/common/debug"
"github.com/ledgerwatch/erigon/common/hexutil"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/eth/filters"
"github.com/ledgerwatch/erigon/rpc"
"github.com/ledgerwatch/log/v3"
)
Expand Down Expand Up @@ -110,3 +111,38 @@ func (api *APIImpl) NewPendingTransactions(ctx context.Context) (*rpc.Subscripti

return rpcSub, nil
}

// SubscribeLogs send a notification each time a new log appears.
func (api *APIImpl) Logs(ctx context.Context, crit filters.FilterCriteria) (*rpc.Subscription, error) {
if api.filters == nil {
return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported
}
notifier, supported := rpc.NotifierFromContext(ctx)
if !supported {
return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported
}

rpcSub := notifier.CreateSubscription()

go func() {
defer debug.LogPanic()
logs := make(chan *types.Log, 1)
defer close(logs)
id := api.filters.SubscribeLogs(logs, crit)
defer api.filters.UnsubscribeLogs(id)

for {
select {
case h := <-logs:
err := notifier.Notify(rpcSub.ID, h)
if err != nil {
log.Warn("error while notifying subscription", "err", err)
}
case <-rpcSub.Err():
return
}
}
}()

return rpcSub, nil
}
8 changes: 7 additions & 1 deletion cmd/rpcdaemon/commands/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/vm"
"github.com/ledgerwatch/erigon/eth/tracers"
"github.com/ledgerwatch/erigon/ethdb"
"github.com/ledgerwatch/erigon/internal/ethapi"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (api *PrivateDebugAPIImpl) traceBlock(ctx context.Context, blockNrOrHash rp
return rawdb.ReadHeader(tx, hash, number)
}

_, blockCtx, txCtx, ibs, reader, err := transactions.ComputeTxEnv(ctx, block, chainConfig, getHeader, contractHasTEVM, ethash.NewFaker(), tx, block.Hash(), 0)
_, blockCtx, _, ibs, reader, err := transactions.ComputeTxEnv(ctx, block, chainConfig, getHeader, contractHasTEVM, ethash.NewFaker(), tx, block.Hash(), 0)
if err != nil {
stream.WriteNil()
return err
Expand All @@ -82,6 +83,11 @@ func (api *PrivateDebugAPIImpl) traceBlock(ctx context.Context, blockNrOrHash rp
}
ibs.Prepare(tx.Hash(), block.Hash(), idx)
msg, _ := tx.AsMessage(*signer, block.BaseFee())
txCtx := vm.TxContext{
TxHash: tx.Hash(),
Origin: msg.From(),
GasPrice: msg.GasPrice().ToBig(),
}

transactions.TraceTx(ctx, msg, blockCtx, txCtx, ibs, config, chainConfig, stream)
_ = ibs.FinalizeTx(chainConfig.Rules(blockCtx.BlockNumber), reader)
Expand Down
121 changes: 121 additions & 0 deletions cmd/rpcdaemon/filters/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import (
"io"
"reflect"
"sync"
"sync/atomic"
"time"

"github.com/ledgerwatch/erigon-lib/gointerfaces"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/eth/filters"

"github.com/ledgerwatch/erigon-lib/gointerfaces/grpcutil"
"github.com/ledgerwatch/erigon-lib/gointerfaces/remote"
"github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/services"
Expand All @@ -28,6 +34,7 @@ type (
PendingLogsSubID SubscriptionID
PendingBlockSubID SubscriptionID
PendingTxsSubID SubscriptionID
LogsSubID uint64
)

type Filters struct {
Expand All @@ -39,6 +46,8 @@ type Filters struct {
pendingLogsSubs map[PendingLogsSubID]chan types.Logs
pendingBlockSubs map[PendingBlockSubID]chan *types.Block
pendingTxsSubs map[PendingTxsSubID]chan []types.Transaction
logsSubs *LogsFilterAggregator
logsRequestor atomic.Value
}

func New(ctx context.Context, ethBackend services.ApiBackend, txPool txpool.TxpoolClient, mining txpool.MiningClient) *Filters {
Expand All @@ -49,6 +58,7 @@ func New(ctx context.Context, ethBackend services.ApiBackend, txPool txpool.Txpo
pendingTxsSubs: make(map[PendingTxsSubID]chan []types.Transaction),
pendingLogsSubs: make(map[PendingLogsSubID]chan types.Logs),
pendingBlockSubs: make(map[PendingBlockSubID]chan *types.Block),
logsSubs: NewLogsFilterAggregator(),
}

go func() {
Expand Down Expand Up @@ -83,6 +93,31 @@ func New(ctx context.Context, ethBackend services.ApiBackend, txPool txpool.Txpo
}
}()

go func() {
if ethBackend == nil {
return
}
for {
select {
case <-ctx.Done():
return
default:
}
if err := ethBackend.SubscribeLogs(ctx, ff.OnNewLogs, &ff.logsRequestor); err != nil {
select {
case <-ctx.Done():
return
default:
}
if grpcutil.IsEndOfStream(err) || grpcutil.IsRetryLater(err) {
time.Sleep(3 * time.Second)
continue
}
log.Warn("rpc filters: error subscribing to logs", "err", err)
}
}
}()

if txPool != nil {
go func() {
for {
Expand Down Expand Up @@ -337,6 +372,73 @@ func (ff *Filters) UnsubscribePendingTxs(id PendingTxsSubID) {
delete(ff.pendingTxsSubs, id)
}

func (ff *Filters) SubscribeLogs(out chan *types.Log, crit filters.FilterCriteria) LogsSubID {
id, f := ff.logsSubs.insertLogsFilter(out)
f.addrs = map[common.Address]int{}
if len(crit.Addresses) == 0 {
f.allAddrs = 1
} else {
for _, addr := range crit.Addresses {
f.addrs[addr] = 1
}
}
f.topics = map[common.Hash]int{}
if len(crit.Topics) == 0 {
f.allTopics = 1
} else {
for _, topics := range crit.Topics {
for _, topic := range topics {
f.topics[topic] = 1
}
}
}
f.topicsOriginal = crit.Topics
ff.logsSubs.addLogsFilters(f)
lfr := &remote.LogsFilterRequest{
AllAddresses: ff.logsSubs.aggLogsFilter.allAddrs == 1,
AllTopics: ff.logsSubs.aggLogsFilter.allTopics == 1,
}
for addr := range ff.logsSubs.aggLogsFilter.addrs {
lfr.Addresses = append(lfr.Addresses, gointerfaces.ConvertAddressToH160(addr))
}
for topic := range ff.logsSubs.aggLogsFilter.topics {
lfr.Topics = append(lfr.Topics, gointerfaces.ConvertHashToH256(topic))
}
ff.mu.Lock()
defer ff.mu.Unlock()
loaded := ff.logsRequestor.Load()
if loaded != nil {
if err := loaded.(func(*remote.LogsFilterRequest) error)(lfr); err != nil {
log.Warn("Could not update remote logs filter", "err", err)
ff.logsSubs.removeLogsFilter(id)
}
}
return id
}

func (ff *Filters) UnsubscribeLogs(id LogsSubID) {
ff.logsSubs.removeLogsFilter(id)
lfr := &remote.LogsFilterRequest{
AllAddresses: ff.logsSubs.aggLogsFilter.allAddrs == 1,
AllTopics: ff.logsSubs.aggLogsFilter.allTopics == 1,
}
for addr := range ff.logsSubs.aggLogsFilter.addrs {
lfr.Addresses = append(lfr.Addresses, gointerfaces.ConvertAddressToH160(addr))
}
for topic := range ff.logsSubs.aggLogsFilter.topics {
lfr.Topics = append(lfr.Topics, gointerfaces.ConvertHashToH256(topic))
}
ff.mu.Lock()
defer ff.mu.Unlock()
loaded := ff.logsRequestor.Load()
if loaded != nil {
if err := loaded.(func(*remote.LogsFilterRequest) error)(lfr); err != nil {
log.Warn("Could not update remote logs filter", "err", err)
ff.logsSubs.removeLogsFilter(id)
}
}
}

func (ff *Filters) OnNewEvent(event *remote.SubscribeReply) {
ff.mu.RLock()
defer ff.mu.RUnlock()
Expand Down Expand Up @@ -411,6 +513,25 @@ func (ff *Filters) OnNewTx(reply *txpool.OnAddReply) {
}
}

func (ff *Filters) OnNewLogs(reply *remote.SubscribeLogsReply) {
lg := &types.Log{
Address: gointerfaces.ConvertH160toAddress(reply.Address),
Data: reply.Data,
BlockNumber: reply.BlockNumber,
TxHash: gointerfaces.ConvertH256ToHash(reply.TransactionHash),
TxIndex: uint(reply.TransactionIndex),
BlockHash: gointerfaces.ConvertH256ToHash(reply.BlockHash),
Index: uint(reply.LogIndex),
Removed: reply.Removed,
}
t := make([]common.Hash, 0)
for _, v := range reply.Topics {
t = append(t, gointerfaces.ConvertH256ToHash(v))
}
lg.Topics = t
ff.logsSubs.distributeLog(reply)
}

func generateSubscriptionID() SubscriptionID {
var id [32]byte

Expand Down
Loading