Skip to content
Draft
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
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ build-linux:
fi
.PHONY: build-linux

# Auto-detect platform: use arm64 on ARM Macs, amd64 elsewhere
DOCKER_PLATFORM ?= $(shell if [ "$$(uname -m)" = "arm64" ]; then echo "linux/arm64"; else echo "linux/amd64"; fi)
# Auto-detect the native Docker platform on ARM and x86 hosts.
DOCKER_PLATFORM ?= $(shell if [ "$$(uname -m)" = "arm64" ] || [ "$$(uname -m)" = "aarch64" ]; then echo "linux/arm64"; else echo "linux/amd64"; fi)
export DOCKER_PLATFORM

# Build docker image for detected platform
Expand Down Expand Up @@ -404,6 +404,13 @@ CLUSTER_ENV_VARS = DOCKER_PLATFORM=$(DOCKER_PLATFORM) USERID=$(shell id -u) GROU
RECEIPT_BACKEND=$(RECEIPT_BACKEND) \
AUTOBAHN=$(AUTOBAHN) \
AUTOBAHN_EVMONLY_IN_MEMORY=$(AUTOBAHN_EVMONLY_IN_MEMORY) \
AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK=$(AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK) \
AUTOBAHN_EVMONLY_BLOCK_INTERVAL=$(AUTOBAHN_EVMONLY_BLOCK_INTERVAL) \
AUTOBAHN_EVMONLY_MAX_GAS=$(AUTOBAHN_EVMONLY_MAX_GAS) \
AUTOBAHN_EVMONLY_MEMPOOL_SIZE=$(AUTOBAHN_EVMONLY_MEMPOOL_SIZE) \
AUTOBAHN_EVMONLY_GOGC=$(AUTOBAHN_EVMONLY_GOGC) \
AUTOBAHN_EVMONLY_GOMAXPROCS=$(AUTOBAHN_EVMONLY_GOMAXPROCS) \
AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY=$(AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY) \
GIGA_STORAGE=$(GIGA_STORAGE) \
GIGA_MIGRATE_FROM_MEMIAVL=$(GIGA_MIGRATE_FROM_MEMIAVL) \
GIGA_FLATKV_ONLY=$(GIGA_FLATKV_ONLY)
Expand Down
28 changes: 28 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ services:
- RECEIPT_BACKEND
- AUTOBAHN
- AUTOBAHN_EVMONLY_IN_MEMORY
- AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK
- AUTOBAHN_EVMONLY_BLOCK_INTERVAL
- AUTOBAHN_EVMONLY_MAX_GAS
- AUTOBAHN_EVMONLY_MEMPOOL_SIZE
- AUTOBAHN_EVMONLY_GOGC
- AUTOBAHN_EVMONLY_GOMAXPROCS
- AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY
- GIGA_STORAGE
- GIGA_MIGRATE_FROM_MEMIAVL
- GIGA_FLATKV_ONLY
Expand Down Expand Up @@ -57,6 +64,13 @@ services:
- RECEIPT_BACKEND
- AUTOBAHN
- AUTOBAHN_EVMONLY_IN_MEMORY
- AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK
- AUTOBAHN_EVMONLY_BLOCK_INTERVAL
- AUTOBAHN_EVMONLY_MAX_GAS
- AUTOBAHN_EVMONLY_MEMPOOL_SIZE
- AUTOBAHN_EVMONLY_GOGC
- AUTOBAHN_EVMONLY_GOMAXPROCS
- AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY
- GIGA_STORAGE
- GIGA_MIGRATE_FROM_MEMIAVL
- GIGA_FLATKV_ONLY
Expand Down Expand Up @@ -89,6 +103,13 @@ services:
- RECEIPT_BACKEND
- AUTOBAHN
- AUTOBAHN_EVMONLY_IN_MEMORY
- AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK
- AUTOBAHN_EVMONLY_BLOCK_INTERVAL
- AUTOBAHN_EVMONLY_MAX_GAS
- AUTOBAHN_EVMONLY_MEMPOOL_SIZE
- AUTOBAHN_EVMONLY_GOGC
- AUTOBAHN_EVMONLY_GOMAXPROCS
- AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY
- GIGA_STORAGE
- GIGA_MIGRATE_FROM_MEMIAVL
- GIGA_FLATKV_ONLY
Expand Down Expand Up @@ -125,6 +146,13 @@ services:
- RECEIPT_BACKEND
- AUTOBAHN
- AUTOBAHN_EVMONLY_IN_MEMORY
- AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK
- AUTOBAHN_EVMONLY_BLOCK_INTERVAL
- AUTOBAHN_EVMONLY_MAX_GAS
- AUTOBAHN_EVMONLY_MEMPOOL_SIZE
- AUTOBAHN_EVMONLY_GOGC
- AUTOBAHN_EVMONLY_GOMAXPROCS
- AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY
- GIGA_STORAGE
- GIGA_MIGRATE_FROM_MEMIAVL
- GIGA_FLATKV_ONLY
Expand Down
12 changes: 10 additions & 2 deletions docker/localnode/scripts/step2_genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

# Input parameters
NODE_ID=${ID:-0}
AUTOBAHN_EVMONLY_MAX_GAS=${AUTOBAHN_EVMONLY_MAX_GAS:-35000000}

case "$AUTOBAHN_EVMONLY_MAX_GAS" in
''|*[!0-9]*|0)
echo "AUTOBAHN_EVMONLY_MAX_GAS must be a positive integer" >&2
exit 1
;;
esac

echo "Preparing genesis file"

Expand All @@ -19,9 +27,9 @@ override_genesis '.app_state["oracle"]["params"]["vote_period"]="2"'
override_genesis '.app_state["slashing"]["params"]["signed_blocks_window"]="10000"'
override_genesis '.app_state["slashing"]["params"]["min_signed_per_window"]="0.050000000000000000"'
override_genesis '.app_state["staking"]["params"]["max_validators"]="50"'
override_genesis '.consensus_params["block"]["max_gas"]="35000000"'
override_genesis ".consensus_params[\"block\"][\"max_gas\"]=\"$AUTOBAHN_EVMONLY_MAX_GAS\""
# Set MaxGasWanted to be 2x of MaxGas, similar to mainnet, in order to avoid false-positive gas related issue reports.
override_genesis '.consensus_params["block"]["max_gas_wanted"]="70000000"'
override_genesis ".consensus_params[\"block\"][\"max_gas_wanted\"]=\"$((AUTOBAHN_EVMONLY_MAX_GAS * 2))\""
override_genesis '.app_state["staking"]["params"]["unbonding_time"]="10s"'

# Set a token release schedule for the genesis file
Expand Down
34 changes: 34 additions & 0 deletions docker/localnode/scripts/step4_config_override.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ GIGA_EXECUTOR=${GIGA_EXECUTOR:-true}
GIGA_OCC=${GIGA_OCC:-true}
AUTOBAHN=${AUTOBAHN:-false}
AUTOBAHN_EVMONLY_IN_MEMORY=${AUTOBAHN_EVMONLY_IN_MEMORY:-false}
AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK=${AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK:-2000}
AUTOBAHN_EVMONLY_BLOCK_INTERVAL=${AUTOBAHN_EVMONLY_BLOCK_INTERVAL:-400ms}
AUTOBAHN_EVMONLY_MEMPOOL_SIZE=${AUTOBAHN_EVMONLY_MEMPOOL_SIZE:-5000}
AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY=${AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY:-true}

validate_positive_integer() {
case "$2" in
''|*[!0-9]*|0)
echo "$1 must be a positive integer" >&2
exit 1
;;
esac
}

validate_positive_integer AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK "$AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK"
validate_positive_integer AUTOBAHN_EVMONLY_MEMPOOL_SIZE "$AUTOBAHN_EVMONLY_MEMPOOL_SIZE"

case "$AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY" in
true|false) ;;
*)
echo "AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY must be true or false" >&2
exit 1
;;
esac
GIGA_STORAGE=${GIGA_STORAGE:-false}
# GIGA_FLATKV_ONLY=true boots the cluster directly in the terminal v3
# steady state: all SC writes route to FlatKV and memiavl is not allocated.
Expand Down Expand Up @@ -171,7 +195,17 @@ if [ "$AUTOBAHN" = "true" ]; then

if [ "$AUTOBAHN_EVMONLY_IN_MEMORY" = "true" ]; then
seid tendermint gen-autobahn-config $NODE_DIRS --output "$AUTOBAHN_CONFIG" --persistent-state-dir=
jq \
--argjson max_txs_per_block "$AUTOBAHN_EVMONLY_MAX_TXS_PER_BLOCK" \
--arg block_interval "$AUTOBAHN_EVMONLY_BLOCK_INTERVAL" \
--argjson enable_evm_proxy "$AUTOBAHN_EVMONLY_ENABLE_EVM_PROXY" \
'.max_txs_per_block = $max_txs_per_block |
.block_interval = $block_interval |
.enable_evm_proxy = $enable_evm_proxy' \
"$AUTOBAHN_CONFIG" > "$AUTOBAHN_CONFIG.tmp"
mv "$AUTOBAHN_CONFIG.tmp" "$AUTOBAHN_CONFIG"
sed -i 's/^evm-only-in-memory = .*/evm-only-in-memory = true/' ~/.sei/config/config.toml
sed -i "s/^size = .*/size = $AUTOBAHN_EVMONLY_MEMPOOL_SIZE/" ~/.sei/config/config.toml
sed -i '/^\[rpc\]/,/^\[/ s|^laddr = .*|laddr = ""|' ~/.sei/config/config.toml
sed -i '/^\[api\]/,/^\[/ s/^enable = .*/enable = false/' ~/.sei/config/app.toml
sed -i '/^\[grpc\]/,/^\[/ s/^enable = .*/enable = false/' ~/.sei/config/app.toml
Expand Down
22 changes: 22 additions & 0 deletions docker/localnode/scripts/step5_start_sei.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ NODE_ID=${ID:-0}
INVARIANT_CHECK_INTERVAL=${INVARIANT_CHECK_INTERVAL:-0}
FREEZE_HEIGHT=${FREEZE_HEIGHT:-0}

if [ "${AUTOBAHN_EVMONLY_IN_MEMORY:-false}" = "true" ]; then
if [ -n "${AUTOBAHN_EVMONLY_GOGC:-}" ]; then
case "$AUTOBAHN_EVMONLY_GOGC" in
off) ;;
*[!0-9]*|0)
echo "AUTOBAHN_EVMONLY_GOGC must be off or a positive integer" >&2
exit 1
;;
esac
export GOGC="$AUTOBAHN_EVMONLY_GOGC"
fi
if [ -n "${AUTOBAHN_EVMONLY_GOMAXPROCS:-}" ]; then
case "$AUTOBAHN_EVMONLY_GOMAXPROCS" in
*[!0-9]*|0)
echo "AUTOBAHN_EVMONLY_GOMAXPROCS must be a positive integer" >&2
exit 1
;;
esac
export GOMAXPROCS="$AUTOBAHN_EVMONLY_GOMAXPROCS"
fi
fi

LOG_DIR="build/generated/logs"
mkdir -p $LOG_DIR

Expand Down
16 changes: 15 additions & 1 deletion giga/evmonly/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,26 @@ func (e *Executor) ExecuteBlock(ctx context.Context, req BlockRequest) (*BlockRe
}

func (e *Executor) PrepareBlock(ctx context.Context, req BlockRequest) (PreparedBlock, error) {
return e.prepareBlock(ctx, req, nil)
}

// PrepareBlockWithLookup prepares a block while reusing transaction preparation
// results validated under the same chain rules.
func (e *Executor) PrepareBlockWithLookup(
ctx context.Context,
req BlockRequest,
lookup PreparedTxLookup,
) (PreparedBlock, error) {
return e.prepareBlock(ctx, req, lookup)
}

func (e *Executor) prepareBlock(ctx context.Context, req BlockRequest, lookup PreparedTxLookup) (PreparedBlock, error) {
chainConfig := e.chainConfig(req.Context)
if err := validateBlockContext(chainConfig, req.Context); err != nil {
return PreparedBlock{}, err
}
signer := ethtypes.MakeSigner(chainConfig, new(big.Int).SetUint64(req.Context.Number), req.Context.Time)
parsed, err := parseBlockTxs(ctx, req.Txs, signer, e.cfg.ParseWorkers)
parsed, err := parseBlockTxs(ctx, req.Txs, signer, e.cfg.ParseWorkers, lookup)
if err != nil {
return PreparedBlock{}, err
}
Expand Down
54 changes: 54 additions & 0 deletions giga/evmonly/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,58 @@ func TestPrepareBlockParallelParsePreservesOrderAndReturnsIndexedError(t *testin
require.ErrorContains(t, err, "parse tx 1")
}

func TestPrepareBlockWithLookupReusesValidatedTransaction(t *testing.T) {
chainID := big.NewInt(testChainID)
key, err := crypto.GenerateKey()
require.NoError(t, err)
recipient := testAddress(0xe8)
raw := signLegacyTx(t, key, chainID, 0, &recipient, big.NewInt(1), nil)
var tx ethtypes.Transaction
require.NoError(t, tx.UnmarshalBinary(raw))
cachedSender := testAddress(0xe9)
lookedUp := false

prepared, err := NewExecutor(Config{ParseWorkers: 4}).PrepareBlockWithLookup(
t.Context(),
BlockRequest{Context: blockContext(chainID), Txs: [][]byte{raw}},
func(hash common.Hash) (PreparedTx, bool) {
lookedUp = true
require.Equal(t, tx.Hash(), hash)
return PreparedTx{Tx: &tx, Sender: cachedSender}, true
},
)

require.NoError(t, err)
require.True(t, lookedUp)
require.Len(t, prepared.Txs, 1)
require.Same(t, &tx, prepared.Txs[0].Tx)
require.Equal(t, cachedSender, prepared.Txs[0].Sender)
}

func TestPrepareBlockWithLookupIgnoresMismatchedTransaction(t *testing.T) {
chainID := big.NewInt(testChainID)
key, err := crypto.GenerateKey()
require.NoError(t, err)
wantSender := crypto.PubkeyToAddress(key.PublicKey)
recipient := testAddress(0xeb)
raw := signLegacyTx(t, key, chainID, 0, &recipient, big.NewInt(1), nil)
otherRaw := signLegacyTx(t, key, chainID, 1, &recipient, big.NewInt(1), nil)
otherTx := new(ethtypes.Transaction)
require.NoError(t, otherTx.UnmarshalBinary(otherRaw))

prepared, err := NewExecutor(Config{}).PrepareBlockWithLookup(
t.Context(),
BlockRequest{Context: blockContext(chainID), Txs: [][]byte{raw}},
func(common.Hash) (PreparedTx, bool) {
return PreparedTx{Tx: otherTx, Sender: testAddress(0xec)}, true
},
)

require.NoError(t, err)
require.Len(t, prepared.Txs, 1)
require.Equal(t, wantSender, prepared.Txs[0].Sender)
}

func TestExecutorDynamicFeeTx(t *testing.T) {
chainID := big.NewInt(testChainID)
key, err := crypto.GenerateKey()
Expand Down Expand Up @@ -592,6 +644,7 @@ func TestExecutorOCCNonConflictingTransfersMatchSequential(t *testing.T) {
require.True(t, occResult.OCCStats.Attempted)
require.False(t, occResult.OCCStats.Fallback)
require.Zero(t, occResult.OCCStats.ConflictCount)
require.Equal(t, seqResult.ChangeSet, occResult.ChangeSet)
for i := range txCount {
require.Equal(t, seqResult.Txs[i].Hash, occResult.Txs[i].Hash)
require.Equal(t, seqResult.Txs[i].Status, occResult.Txs[i].Status)
Expand Down Expand Up @@ -682,6 +735,7 @@ func TestExecutorOCCFeePayingTransfersDoNotConflictOnCoinbase(t *testing.T) {
require.True(t, occResult.OCCStats.Attempted)
require.False(t, occResult.OCCStats.Fallback)
require.Equal(t, seqResult.GasUsed, occResult.GasUsed)
require.Equal(t, seqResult.ChangeSet, occResult.ChangeSet)

seqState.ApplyChangeSet(seqResult.ChangeSet)
occState.ApplyChangeSet(occResult.ChangeSet)
Expand Down
22 changes: 20 additions & 2 deletions giga/evmonly/giga_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ var (

var _ StateReader = gigaSnapshotStateReader{}

type executorViewStore interface {
OpenExecutorView() gigastore.StateView
}

// NamedChangeSetEncoder converts an executor-native state result into the
// on-disk changesets understood by a giga store. It is called synchronously
// while the block's read snapshot is still open. It must treat the input as
Expand Down Expand Up @@ -48,11 +52,16 @@ func (e *Executor) executePreparedBlockWithStore(ctx context.Context, req Prepar
if err := ctx.Err(); err != nil {
return nil, err
}
snapshot := e.store.OpenView()
snapshot := openExecutorView(e.store)
if snapshot == nil {
return nil, errors.New("giga store returned a nil snapshot")
}
defer snapshot.Close()
snapshotOpen := true
defer func() {
if snapshotOpen {
snapshot.Close()
}
}()

result, err := e.executePreparedBlock(ctx, req, gigaSnapshotStateReader{snapshot: snapshot})
if err != nil {
Expand All @@ -72,6 +81,8 @@ func (e *Executor) executePreparedBlockWithStore(ctx context.Context, req Prepar
if err != nil {
return nil, fmt.Errorf("encode state changes for block %d: %w", req.Context.Number, err)
}
snapshot.Close()
snapshotOpen = false
if err := ctx.Err(); err != nil {
return nil, err
}
Expand All @@ -82,6 +93,13 @@ func (e *Executor) executePreparedBlockWithStore(ctx context.Context, req Prepar
return result, nil
}

func openExecutorView(store gigastore.StateDB) gigastore.StateView {
if store, ok := store.(executorViewStore); ok {
return store.OpenExecutorView()
}
return store.OpenView()
}

type gigaSnapshotStateReader struct {
snapshot gigastore.EVMStateView
}
Expand Down
Loading
Loading