mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
Merge branch 'master' into coreth-0.8.9-rc.0
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
ARG AVALANCHE_VERSION
|
||||
|
||||
# ============= Compilation Stage ================
|
||||
FROM golang:1.17.4-buster AS builder
|
||||
FROM golang:1.17.9-buster AS builder
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends bash=5.0-4 git=1:2.20.1-2+deb10u3 make=4.2.1-1.2 gcc=4:8.3.0-1 musl-dev=1.1.21-2 ca-certificates=20200601~deb10u2 linux-headers-amd64
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
+5
-3
@@ -61,7 +61,9 @@ const (
|
||||
// non-trivial consequences: larger transactions are significantly harder and
|
||||
// more expensive to propagate; larger transactions also take more resources
|
||||
// to validate whether they fit into the pool or not.
|
||||
txMaxSize = 4 * txSlotSize // 128KB
|
||||
//
|
||||
// Note: the max contract size is 24KB
|
||||
txMaxSize = 32 * 1024 // 32 KB
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -684,8 +686,8 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||
return ErrTxTypeNotSupported
|
||||
}
|
||||
// Reject transactions over defined size to prevent DOS attacks
|
||||
if uint64(tx.Size()) > txMaxSize {
|
||||
return ErrOversizedData
|
||||
if txSize := uint64(tx.Size()); txSize > txMaxSize {
|
||||
return fmt.Errorf("%w tx size %d > max size %d", ErrOversizedData, txSize, txMaxSize)
|
||||
}
|
||||
// Transactions can't be negative. This may never happen using RLP decoded
|
||||
// transactions but may occur if you create a transaction using the RPC.
|
||||
|
||||
@@ -37,6 +37,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ava-labs/avalanchego/utils/timer/mockable"
|
||||
"github.com/ava-labs/avalanchego/utils/units"
|
||||
"github.com/ava-labs/subnet-evm/consensus"
|
||||
"github.com/ava-labs/subnet-evm/consensus/dummy"
|
||||
"github.com/ava-labs/subnet-evm/core"
|
||||
@@ -48,6 +49,10 @@ import (
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
)
|
||||
|
||||
const (
|
||||
targetTxsSize = 232 * units.KiB
|
||||
)
|
||||
|
||||
// environment is the worker's current environment and holds all of the current state information.
|
||||
type environment struct {
|
||||
signer types.Signer
|
||||
@@ -60,6 +65,7 @@ type environment struct {
|
||||
header *types.Header
|
||||
txs []*types.Transaction
|
||||
receipts []*types.Receipt
|
||||
size common.StorageSize
|
||||
|
||||
start time.Time // Time that block building began
|
||||
}
|
||||
@@ -214,6 +220,7 @@ func (w *worker) commitTransaction(env *environment, tx *types.Transaction, coin
|
||||
}
|
||||
env.txs = append(env.txs, tx)
|
||||
env.receipts = append(env.receipts, receipt)
|
||||
env.size += tx.Size()
|
||||
|
||||
return receipt.Logs, nil
|
||||
}
|
||||
@@ -230,6 +237,14 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP
|
||||
if tx == nil {
|
||||
break
|
||||
}
|
||||
// Abort transaction if it won't fit in the block and continue to search for a smaller
|
||||
// transction that will fit.
|
||||
if totalTxsSize := env.size + tx.Size(); totalTxsSize > targetTxsSize {
|
||||
log.Trace("Skipping transaction that would exceed target size", "hash", tx.Hash(), "totalTxsSize", totalTxsSize, "txSize", tx.Size())
|
||||
|
||||
txs.Pop()
|
||||
continue
|
||||
}
|
||||
// Error may be ignored here. The error has already been checked
|
||||
// during transaction acceptance is the transaction pool.
|
||||
//
|
||||
|
||||
@@ -4,6 +4,29 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
go_version_minimum="1.17.9"
|
||||
|
||||
go_version() {
|
||||
go version | sed -nE -e 's/[^0-9.]+([0-9.]+).+/\1/p'
|
||||
}
|
||||
|
||||
version_lt() {
|
||||
# Return true if $1 is a lower version than than $2,
|
||||
local ver1=$1
|
||||
local ver2=$2
|
||||
# Reverse sort the versions, if the 1st item != ver1 then ver1 < ver2
|
||||
if [[ $(echo -e -n "$ver1\n$ver2\n" | sort -rV | head -n1) != "$ver1" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
if version_lt "$(go_version)" "$go_version_minimum"; then
|
||||
echo "SubnetEVM requires Go >= $go_version_minimum, Go $(go_version) found." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Avalanche root directory
|
||||
SUBNET_EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user