Skip to content

Commit

Permalink
Merge pull request #1309 from maticnetwork/merge-master-develop
Browse files Browse the repository at this point in the history
merge master into develop
  • Loading branch information
marcello33 authored Aug 19, 2024
2 parents d0c74c4 + aa54ff5 commit 5009267
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 47 deletions.
2 changes: 0 additions & 2 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,6 @@ func geth(ctx *cli.Context) error {
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
// miner.
func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isConsole bool) {
debug.Memsize.Add("node", stack)

// Start up the node itself
utils.StartNode(ctx, stack, isConsole)

Expand Down
2 changes: 1 addition & 1 deletion consensus/bor/heimdallgrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewHeimdallGRPCClient(address string) *HeimdallGRPCClient {
grpc_retry.WithCodes(codes.Internal, codes.Unavailable, codes.Aborted, codes.NotFound),
}

conn, err := grpc.Dial(address,
conn, err := grpc.NewClient(address,
grpc.WithStreamInterceptor(grpc_retry.StreamClientInterceptor(opts...)),
grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(opts...)),
grpc.WithTransportCredentials(insecure.NewCredentials()),
Expand Down
2 changes: 1 addition & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
prevAccount, ok := s.accountsOrigin[prev.address]
s.journal.append(resetObjectChange{
account: &addr,
prev: prev,
prev: prev.deepCopy(s),
prevdestruct: prevdestruct,
prevAccount: s.accounts[prev.addrHash],
prevStorage: s.storages[prev.addrHash],
Expand Down
2 changes: 1 addition & 1 deletion core/txpool/legacypool/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestFilterTxConditional(t *testing.T) {
// and add to the list.
tx2 := transaction(1, 1000, key)

var options types.OptionsAA4337
var options types.OptionsPIP15

options.KnownAccounts = types.KnownAccounts{
common.Address{19: 1}: &types.Value{
Expand Down
8 changes: 4 additions & 4 deletions core/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ func (h *Header) EmptyReceipts() bool {
return h.ReceiptHash == EmptyReceiptsHash
}

// ValidateBlockNumberOptions4337 validates the block range passed as in the options parameter in the conditional transaction (EIP-4337)
func (h *Header) ValidateBlockNumberOptions4337(minBlockNumber *big.Int, maxBlockNumber *big.Int) error {
// ValidateBlockNumberOptionsPIP15 validates the block range passed as in the options parameter in the conditional transaction (PIP-15)
func (h *Header) ValidateBlockNumberOptionsPIP15(minBlockNumber *big.Int, maxBlockNumber *big.Int) error {
currentBlockNumber := h.Number

if minBlockNumber != nil {
Expand All @@ -208,8 +208,8 @@ func (h *Header) ValidateBlockNumberOptions4337(minBlockNumber *big.Int, maxBloc
return nil
}

// ValidateBlockNumberOptions4337 validates the timestamp range passed as in the options parameter in the conditional transaction (EIP-4337)
func (h *Header) ValidateTimestampOptions4337(minTimestamp *uint64, maxTimestamp *uint64) error {
// ValidateBlockNumberOptionsPIP15 validates the timestamp range passed as in the options parameter in the conditional transaction (PIP-15)
func (h *Header) ValidateTimestampOptionsPIP15(minTimestamp *uint64, maxTimestamp *uint64) error {
currentBlockTime := h.Time

if minTimestamp != nil {
Expand Down
12 changes: 6 additions & 6 deletions core/types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func TestRlpDecodeParentHash(t *testing.T) {
}
}

func TestValidateBlockNumberOptions4337(t *testing.T) {
func TestValidateBlockNumberOptionsPIP15(t *testing.T) {
t.Parallel()

testsPass := []struct {
Expand Down Expand Up @@ -503,19 +503,19 @@ func TestValidateBlockNumberOptions4337(t *testing.T) {
}

for _, test := range testsPass {
if err := test.header.ValidateBlockNumberOptions4337(test.minBlockNumber, test.maxBlockNumber); err != nil {
if err := test.header.ValidateBlockNumberOptionsPIP15(test.minBlockNumber, test.maxBlockNumber); err != nil {
t.Fatalf("test number %v should not have failed. err: %v", test.number, err)
}
}

for _, test := range testsFail {
if err := test.header.ValidateBlockNumberOptions4337(test.minBlockNumber, test.maxBlockNumber); err == nil {
if err := test.header.ValidateBlockNumberOptionsPIP15(test.minBlockNumber, test.maxBlockNumber); err == nil {
t.Fatalf("test number %v should have failed. err is nil", test.number)
}
}
}

func TestValidateTimestampOptions4337(t *testing.T) {
func TestValidateTimestampOptionsPIP15(t *testing.T) {
t.Parallel()

u64Ptr := func(n uint64) *uint64 {
Expand Down Expand Up @@ -587,13 +587,13 @@ func TestValidateTimestampOptions4337(t *testing.T) {
}

for _, test := range testsPass {
if err := test.header.ValidateTimestampOptions4337(test.minTimestamp, test.maxTimestamp); err != nil {
if err := test.header.ValidateTimestampOptionsPIP15(test.minTimestamp, test.maxTimestamp); err != nil {
t.Fatalf("test number %v should not have failed. err: %v", test.number, err)
}
}

for _, test := range testsFail {
if err := test.header.ValidateTimestampOptions4337(test.minTimestamp, test.maxTimestamp); err == nil {
if err := test.header.ValidateTimestampOptionsPIP15(test.minTimestamp, test.maxTimestamp); err == nil {
t.Fatalf("test number %v should have failed. err is nil", test.number)
}
}
Expand Down
16 changes: 8 additions & 8 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type Transaction struct {
time time.Time // Time first seen locally (spam avoidance)

// BOR specific - DO NOT REMOVE
// knownAccounts (EIP-4337)
optionsAA4337 *OptionsAA4337
// knownAccounts (PIP-15)
optionsPIP15 *OptionsPIP15

// caches
hash atomic.Value
Expand Down Expand Up @@ -106,14 +106,14 @@ type TxData interface {
decode([]byte) error
}

// PutOptions stores the optionsAA4337 field of the conditional transaction (EIP-4337)
func (tx *Transaction) PutOptions(options *OptionsAA4337) {
tx.optionsAA4337 = options
// PutOptions stores the optionsPIP15 field of the conditional transaction (PIP-15)
func (tx *Transaction) PutOptions(options *OptionsPIP15) {
tx.optionsPIP15 = options
}

// GetOptions returns the optionsAA4337 field of the conditional transaction (EIP-4337)
func (tx *Transaction) GetOptions() *OptionsAA4337 {
return tx.optionsAA4337
// GetOptions returns the optionsPIP15 field of the conditional transaction (PIP-15)
func (tx *Transaction) GetOptions() *OptionsPIP15 {
return tx.optionsPIP15
}

// EncodeRLP implements rlp.Encoder
Expand Down
2 changes: 1 addition & 1 deletion core/types/transaction_conditional.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func InsertKnownAccounts[T common.Hash | map[common.Hash]common.Hash](accounts K
}
}

type OptionsAA4337 struct {
type OptionsPIP15 struct {
KnownAccounts KnownAccounts `json:"knownAccounts"`
BlockNumberMin *big.Int `json:"blockNumberMin"`
BlockNumberMax *big.Int `json:"blockNumberMax"`
Expand Down
4 changes: 2 additions & 2 deletions eth/protocols/eth/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (p *Peer) broadcastTransactions() {
tx := p.txpool.Get(queue[i])

// BOR specific - DO NOT REMOVE
// Skip EIP-4337 bundled transactions
// Skip PIP-15 bundled transactions
if tx != nil && tx.GetOptions() == nil {
txs = append(txs, tx)
size += common.StorageSize(tx.Size())
Expand Down Expand Up @@ -156,7 +156,7 @@ func (p *Peer) announceTransactions() {
for count = 0; count < len(queue) && size < maxTxPacketSize; count++ {
tx := p.txpool.Get(queue[count])
// BOR specific - DO NOT REMOVE
// Skip EIP-4337 bundled transactions
// Skip PIP-15 bundled transactions
if tx != nil && tx.GetOptions() == nil {
pending = append(pending, queue[count])
pendingTypes = append(pendingTypes, tx.Type())
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ require (
github.com/ethereum/c-kzg-4844 v0.4.3
github.com/fatih/color v1.17.0
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e
github.com/fjl/memsize v0.0.2
github.com/fsnotify/fsnotify v1.7.0
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,6 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e h1:bBLctRc7kr01YGvaDfgLbTwjFNW5jdp5y5rj8XXBHfY=
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/flosch/pongo2/v4 v4.0.2/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (m *Meta2) NewFlagSet(n string) *flagset.Flagset {
}

func (m *Meta2) Conn() (*grpc.ClientConn, error) {
conn, err := grpc.Dial(m.addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(m.addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("failed to connect to server: %v", err)
}
Expand Down
4 changes: 0 additions & 4 deletions internal/debug/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/metrics/exp"
"github.com/fjl/memsize/memsizeui"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"github.com/urfave/cli/v2"
"golang.org/x/exp/slog"
"gopkg.in/natefinch/lumberjack.v2"
)

var Memsize memsizeui.Handler

var (
verbosityFlag = &cli.IntFlag{
Name: "verbosity",
Expand Down Expand Up @@ -323,7 +320,6 @@ func StartPProf(address string, withMetrics bool) {
if withMetrics {
exp.Exp(metrics.DefaultRegistry)
}
http.Handle("/memsize/", http.StripPrefix("/memsize", &Memsize))
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
go func() {
if err := http.ListenAndServe(address, nil); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/ethapi/bor_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewBorAPI(b Backend) *BorAPI {

// SendRawTransactionConditional will add the signed transaction to the transaction pool.
// The sender/bundler is responsible for signing the transaction
func (api *BorAPI) SendRawTransactionConditional(ctx context.Context, input hexutil.Bytes, options types.OptionsAA4337) (common.Hash, error) {
func (api *BorAPI) SendRawTransactionConditional(ctx context.Context, input hexutil.Bytes, options types.OptionsPIP15) (common.Hash, error) {
tx := new(types.Transaction)
if err := tx.UnmarshalBinary(input); err != nil {
return common.Hash{}, err
Expand All @@ -81,12 +81,12 @@ func (api *BorAPI) SendRawTransactionConditional(ctx context.Context, input hexu
}

// check block number range
if err := currentHeader.ValidateBlockNumberOptions4337(options.BlockNumberMin, options.BlockNumberMax); err != nil {
if err := currentHeader.ValidateBlockNumberOptionsPIP15(options.BlockNumberMin, options.BlockNumberMax); err != nil {
return common.Hash{}, &rpc.OptionsValidateError{Message: "out of block range. err: " + err.Error()}
}

// check timestamp range
if err := currentHeader.ValidateTimestampOptions4337(options.TimestampMin, options.TimestampMax); err != nil {
if err := currentHeader.ValidateTimestampOptionsPIP15(options.TimestampMin, options.TimestampMax); err != nil {
return common.Hash{}, &rpc.OptionsValidateError{Message: "out of time range. err: " + err.Error()}
}

Expand Down
4 changes: 2 additions & 2 deletions miner/test_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,14 @@ mainloop:
// not prioritising conditional transaction, yet.
//nolint:nestif
if options := tx.GetOptions(); options != nil {
if err := env.header.ValidateBlockNumberOptions4337(options.BlockNumberMin, options.BlockNumberMax); err != nil {
if err := env.header.ValidateBlockNumberOptionsPIP15(options.BlockNumberMin, options.BlockNumberMax); err != nil {
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
txs.Pop()

continue
}

if err := env.header.ValidateTimestampOptions4337(options.TimestampMin, options.TimestampMax); err != nil {
if err := env.header.ValidateTimestampOptionsPIP15(options.TimestampMin, options.TimestampMax); err != nil {
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
txs.Pop()

Expand Down
4 changes: 2 additions & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,14 +1023,14 @@ mainloop:
// not prioritising conditional transaction, yet.
//nolint:nestif
if options := tx.GetOptions(); options != nil {
if err := env.header.ValidateBlockNumberOptions4337(options.BlockNumberMin, options.BlockNumberMax); err != nil {
if err := env.header.ValidateBlockNumberOptionsPIP15(options.BlockNumberMin, options.BlockNumberMax); err != nil {
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
txs.Pop()

continue
}

if err := env.header.ValidateTimestampOptions4337(options.TimestampMin, options.TimestampMax); err != nil {
if err := env.header.ValidateTimestampOptionsPIP15(options.TimestampMin, options.TimestampMax); err != nil {
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
txs.Pop()

Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 1.3.4
Version: 1.3.7
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 1.3.4
Version: 1.3.7
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.profile.amd64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.3.4
Version: 1.3.7
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.profile.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.3.4
Version: 1.3.7
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.validator
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.3.4
Version: 1.3.7
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.3.4
Version: 1.3.7
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionPatch = 7 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
)

Expand Down

0 comments on commit 5009267

Please sign in to comment.