Skip to content

Commit

Permalink
Last seen block: as in-mem atomic instead of db field (#12505)
Browse files Browse the repository at this point in the history
also fixing #11487
  • Loading branch information
AskAlexSharov authored Nov 9, 2024
1 parent 5d9ec47 commit 54960b0
Show file tree
Hide file tree
Showing 19 changed files with 778 additions and 506 deletions.
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/rpcdaemontest/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func CreateTestGrpcConn(t *testing.T, m *mock.MockSentry) (context.Context, *grp
ethashApi := apis[1].Service.(*ethash.API)
server := grpc.NewServer()

remote.RegisterETHBACKENDServer(server, privateapi.NewEthBackendServer(ctx, nil, m.DB, m.Notifications.Events,
remote.RegisterETHBACKENDServer(server, privateapi.NewEthBackendServer(ctx, nil, m.DB, m.Notifications,
m.BlockReader, log.New(), builder.NewLatestBlockBuiltStore()))
txpool.RegisterTxpoolServer(server, m.TxPoolGrpcServer)
txpool.RegisterMiningServer(server, privateapi.NewMiningServer(ctx, &IsMiningMock{}, ethashApi, m.Log))
Expand Down
12 changes: 12 additions & 0 deletions cmd/rpcdaemon/rpcservices/eth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ func (back *RemoteBackend) Etherbase(ctx context.Context) (common.Address, error
return gointerfaces.ConvertH160toAddress(res.Address), nil
}

func (back *RemoteBackend) Syncing(ctx context.Context) (*remote.SyncingReply, error) {
res, err := back.remoteEthBackend.Syncing(ctx, &emptypb.Empty{})
if err != nil {
if s, ok := status.FromError(err); ok {
return nil, errors.New(s.Message())
}
return nil, err
}

return res, nil
}

func (back *RemoteBackend) NetVersion(ctx context.Context) (uint64, error) {
res, err := back.remoteEthBackend.NetVersion(ctx, &remote.NetVersionRequest{})
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1338,10 +1338,6 @@ func ReadDBSchemaVersion(tx kv.Tx) (major, minor, patch uint32, ok bool, err err
return major, minor, patch, true, nil
}

func WriteLastNewBlockSeen(tx kv.RwTx, blockNum uint64) error {
return tx.Put(kv.SyncStageProgress, kv.LastNewBlockSeen, dbutils.EncodeBlockNumber(blockNum))
}

func ReadLastNewBlockSeen(tx kv.Tx) (uint64, error) {
v, err := tx.GetOne(kv.SyncStageProgress, kv.LastNewBlockSeen)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions erigon-lib/direct/eth_backend_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (s *EthBackendClientDirect) Version(ctx context.Context, in *emptypb.Empty,
return s.server.Version(ctx, in)
}

func (s *EthBackendClientDirect) Syncing(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*remote.SyncingReply, error) {
return s.server.Syncing(ctx, in)
}

func (s *EthBackendClientDirect) ProtocolVersion(ctx context.Context, in *remote.ProtocolVersionRequest, opts ...grpc.CallOption) (*remote.ProtocolVersionReply, error) {
return s.server.ProtocolVersion(ctx, in)
}
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.0

require (
github.com/erigontech/erigon-snapshot v1.3.1-0.20241023024258-f64407a77e8e
github.com/erigontech/interfaces v0.0.0-20241024130452-38a90d9c6fd5
github.com/erigontech/interfaces v0.0.0-20241026045526-56f59523ec08
github.com/erigontech/mdbx-go v0.38.4
github.com/erigontech/secp256k1 v1.1.0
github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417
Expand Down
4 changes: 2 additions & 2 deletions erigon-lib/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/erigontech/erigon-snapshot v1.3.1-0.20241023024258-f64407a77e8e h1:ZpIO6HeopuZPYDLldL6zR0qyRezj80kQrDOGEF779ts=
github.com/erigontech/erigon-snapshot v1.3.1-0.20241023024258-f64407a77e8e/go.mod h1:ooHlCl+eEYzebiPu+FP6Q6SpPUeMADn8Jxabv3IKb9M=
github.com/erigontech/interfaces v0.0.0-20241024130452-38a90d9c6fd5 h1:1Rc1N2CGb9NGlHH5frMbh5xXHL028abz/boh5eSgBVU=
github.com/erigontech/interfaces v0.0.0-20241024130452-38a90d9c6fd5/go.mod h1:N7OUkhkcagp9+7yb4ycHsG2VWCOmuJ1ONBecJshxtLE=
github.com/erigontech/interfaces v0.0.0-20241026045526-56f59523ec08 h1:kjkEK5+jMxU9UkcBiFp1ZsRDyaAN8AXnoaITmso3FYQ=
github.com/erigontech/interfaces v0.0.0-20241026045526-56f59523ec08/go.mod h1:N7OUkhkcagp9+7yb4ycHsG2VWCOmuJ1ONBecJshxtLE=
github.com/erigontech/mdbx-go v0.38.4 h1:S9T7mTe9KPcFe4dOoOtVdI6gPzht9y7wMnYfUBgrQLo=
github.com/erigontech/mdbx-go v0.38.4/go.mod h1:IcOLQDPw3VM/asP6T5JVPPN4FHHgJtY16XfYjzWKVNI=
github.com/erigontech/secp256k1 v1.1.0 h1:mO3YJMUSoASE15Ya//SoHiisptUhdXExuMUN1M0X9qY=
Expand Down
Loading

0 comments on commit 54960b0

Please sign in to comment.