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

Sync to changes in subnet-evm up to 252592ae #645

Merged
merged 11 commits into from
Sep 4, 2024
Merged
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
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

# review whenever someone opens a pull request.

* @darioush @ceyonur
* @ceyonur @darioush @ava-labs/platform-evm

2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ run:
skip-dirs-use-default: true
# Include non-test files tagged as test-only.
# Context: https://github.com/ava-labs/avalanchego/pull/3173
build-tags:
- test

linters:
disable-all: true
Expand Down
3 changes: 0 additions & 3 deletions accounts/keystore/keystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,6 @@ type walletEvent struct {
// Tests that wallet notifications and correctly fired when accounts are added
// or deleted from the keystore.
func TestWalletNotifications(t *testing.T) {
if os.Getenv("RUN_FLAKY_TESTS") != "true" {
t.Skip("FLAKY")
}
t.Parallel()
_, ks := tmpKeyStore(t, false)

Expand Down
29 changes: 3 additions & 26 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,9 @@ func (bc *BlockChain) Reject(block *types.Block) error {
return fmt.Errorf("failed to write delete block batch: %w", err)
}

// Remove the block from the block cache (ignore return value of whether it was in the cache)
_ = bc.blockCache.Remove(block.Hash())

return nil
}

Expand Down Expand Up @@ -1721,32 +1724,6 @@ func (bc *BlockChain) reportBlock(block *types.Block, receipts types.Receipts, e
log.Debug(reason.String())
}

func (bc *BlockChain) RemoveRejectedBlocks(start, end uint64) error {
batch := bc.db.NewBatch()

for i := start; i < end; i++ {
hashes := rawdb.ReadAllHashes(bc.db, i)
canonicalBlock := bc.GetBlockByNumber((i))
if canonicalBlock == nil {
return fmt.Errorf("failed to retrieve block by number at height %d", i)
}
canonicalHash := canonicalBlock.Hash()
for _, hash := range hashes {
if hash == canonicalHash {
continue
}
rawdb.DeleteBlock(batch, hash, i)
}

if err := batch.Write(); err != nil {
return fmt.Errorf("failed to write delete rejected block batch at height %d", i)
}
batch.Reset()
}

return nil
}

// reprocessBlock reprocesses a previously accepted block. This is often used
// to regenerate previously pruned state tries.
func (bc *BlockChain) reprocessBlock(parent *types.Block, current *types.Block) (common.Hash, error) {
Expand Down
4 changes: 3 additions & 1 deletion core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"testing"

"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/coreth/consensus/dummy"
"github.com/ava-labs/coreth/core/rawdb"
"github.com/ava-labs/coreth/core/state"
Expand Down Expand Up @@ -1212,7 +1213,8 @@ func TestEIP3651(t *testing.T) {
addr2 = crypto.PubkeyToAddress(key2.PublicKey)
funds = new(big.Int).Mul(common.Big1, big.NewInt(params.Ether))
gspec = &Genesis{
Config: params.TestChainConfig,
Config: params.TestChainConfig,
Timestamp: uint64(upgrade.InitiallyActiveTime.Unix()),
Alloc: GenesisAlloc{
addr1: {Balance: funds},
addr2: {Balance: funds},
Expand Down
2 changes: 1 addition & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ type genesisSpecMarshaling struct {
GasUsed math.HexOrDecimal64
Number math.HexOrDecimal64
Difficulty *math.HexOrDecimal256
BaseFee *math.HexOrDecimal256
Alloc map[common.UnprefixedAddress]GenesisAccount
BaseFee *math.HexOrDecimal256
ExcessBlobGas *math.HexOrDecimal64
BlobGasUsed *math.HexOrDecimal64
}
Expand Down
2 changes: 1 addition & 1 deletion core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func TestGenesisWriteUpgradesRegression(t *testing.T) {

genesis.Config.UpgradeConfig.PrecompileUpgrades = []params.PrecompileUpgrade{
{
Config: warp.NewConfig(utils.NewUint64(51), 0),
Config: warp.NewConfig(utils.NewUint64(51), 0, false),
},
}
_, _, err = SetupGenesisBlock(db, trieDB, genesis, genesisBlock.Hash(), false)
Expand Down
4 changes: 3 additions & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"math/big"
"testing"

"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/coreth/consensus"
"github.com/ava-labs/coreth/consensus/dummy"
"github.com/ava-labs/coreth/consensus/misc/eip4844"
Expand Down Expand Up @@ -108,7 +109,8 @@ func TestStateProcessorErrors(t *testing.T) {
var (
db = rawdb.NewMemoryDatabase()
gspec = &Genesis{
Config: config,
Config: config,
Timestamp: uint64(upgrade.InitiallyActiveTime.Unix()),
Alloc: GenesisAlloc{
common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"): GenesisAccount{
Balance: big.NewInt(4000000000000000000), // 4 ether
Expand Down
1 change: 1 addition & 0 deletions core/test_blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ func TestAcceptNonCanonicalBlock(t *testing.T, create func(db ethdb.Database, gs
if err := blockchain.Reject(chain1[i]); err != nil {
t.Fatal(err)
}
require.False(t, blockchain.HasBlock(chain1[i].Hash(), chain1[i].NumberU64()))
}

lastAcceptedBlock := blockchain.LastConsensusAcceptedBlock()
Expand Down
1 change: 1 addition & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ func New(
log.Info("Unprotected transactions allowed")
}
gpoParams := config.GPO
gpoParams.MinPrice = new(big.Int).SetUint64(config.TxPool.PriceLimit)
eth.APIBackend.gpo, err = gasprice.NewOracle(eth.APIBackend, gpoParams)
if err != nil {
return nil, err
Expand Down
15 changes: 8 additions & 7 deletions eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,15 @@ func (es *EventSystem) handlePendingLogs(filters filterIndex, ev []*types.Log) {
}
}

func (es *EventSystem) handleTxsEvent(filters filterIndex, ev core.NewTxsEvent, accepted bool) {
func (es *EventSystem) handleTxsEvent(filters filterIndex, ev core.NewTxsEvent) {
for _, f := range filters[PendingTransactionsSubscription] {
f.txs <- ev.Txs
}
if accepted {
for _, f := range filters[AcceptedTransactionsSubscription] {
f.txs <- ev.Txs
}
}

func (es *EventSystem) handleTxsAcceptedEvent(filters filterIndex, ev core.NewTxsEvent) {
for _, f := range filters[AcceptedTransactionsSubscription] {
f.txs <- ev.Txs
}
}

Expand Down Expand Up @@ -565,7 +566,7 @@ func (es *EventSystem) eventLoop() {
for {
select {
case ev := <-es.txsCh:
es.handleTxsEvent(index, ev, false)
es.handleTxsEvent(index, ev)
case ev := <-es.logsCh:
es.handleLogs(index, ev)
case ev := <-es.logsAcceptedCh:
Expand All @@ -579,7 +580,7 @@ func (es *EventSystem) eventLoop() {
case ev := <-es.chainAcceptedCh:
es.handleChainAcceptedEvent(index, ev)
case ev := <-es.txsAcceptedCh:
es.handleTxsEvent(index, ev, true)
es.handleTxsAcceptedEvent(index, ev)

case f := <-es.install:
if f.typ == MinedAndPendingLogsSubscription {
Expand Down
4 changes: 4 additions & 0 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,10 @@ func overrideConfig(original *params.ChainConfig, override *params.ChainConfig)
copy.CancunTime = timestamp
canon = false
}
if timestamp := override.EtnaTimestamp; timestamp != nil {
copy.EtnaTimestamp = timestamp
canon = false
}

return copy, canon
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.12

require (
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/ava-labs/avalanchego v1.11.11-0.20240814145500-1ac532af76df
github.com/ava-labs/avalanchego v1.11.11
github.com/cespare/cp v0.1.0
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233
github.com/davecgh/go-spew v1.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.11.11-0.20240814145500-1ac532af76df h1:Yp9rCHpgEsPFzpx2MXxpb/T+/NbP2NpS1EDwFquffLQ=
github.com/ava-labs/avalanchego v1.11.11-0.20240814145500-1ac532af76df/go.mod h1:Kw2GKwTaCkLwq2z3zSVH4V2eiAmq2FohHmN3AIDWjvY=
github.com/ava-labs/avalanchego v1.11.11 h1:MIQq8xRavRj4ZXHA4G+aMiymig7SOScGOG1SApmMvBc=
github.com/ava-labs/avalanchego v1.11.11/go.mod h1:yFx3V31Jy9NFa8GZlgGnwiVf8KGjeF2+Uc99l9Scd/8=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
1 change: 0 additions & 1 deletion internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,6 @@ func setupReceiptBackend(t *testing.T, genBlocks int) (*testBackend, []common.Ha
b.AddTx(tx)
txHashes[i] = tx.Hash()
}
// b.SetPoS()
})
return backend, txHashes
}
Expand Down
17 changes: 8 additions & 9 deletions internal/ethapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,12 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b feeBackend) e
if args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil {
return errors.New("maxFeePerGas and maxPriorityFeePerGas are not valid before London is active")
}
if args.GasPrice == nil {
price, err := b.SuggestGasTipCap(ctx)
if err != nil {
return err
}
args.GasPrice = (*hexutil.Big)(price)
// London not active, set gas price.
price, err := b.SuggestGasTipCap(ctx)
if err != nil {
return err
}
args.GasPrice = (*hexutil.Big)(price)
}
return nil
}
Expand All @@ -217,11 +216,11 @@ func (args *TransactionArgs) setApricotPhase3FeeDefault(ctx context.Context, hea
// Set the max fee to be 2 times larger than the previous block's base fee.
// The additional slack allows the tx to not become invalidated if the base
// fee is rising.
gasFeeCap := new(big.Int).Add(
(*big.Int)(args.MaxPriorityFeePerGas),
val := new(big.Int).Add(
args.MaxPriorityFeePerGas.ToInt(),
new(big.Int).Mul(head.BaseFee, big.NewInt(2)),
)
args.MaxFeePerGas = (*hexutil.Big)(gasFeeCap)
args.MaxFeePerGas = (*hexutil.Big)(val)
}
// Both EIP-1559 fee parameters are now set; sanity check them.
if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
Expand Down
4 changes: 0 additions & 4 deletions metrics/sample_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package metrics
import (
"math"
"math/rand"
"os"
"runtime"
"testing"
"time"
Expand Down Expand Up @@ -133,9 +132,6 @@ func TestExpDecaySample(t *testing.T) {
// The priority becomes +Inf quickly after starting if this is done,
// effectively freezing the set of samples until a rescale step happens.
func TestExpDecaySampleNanosecondRegression(t *testing.T) {
if os.Getenv("RUN_FLAKY_TESTS") != "true" {
t.Skip("FLAKY")
}
sw := NewExpDecaySample(100, 0.99)
for i := 0; i < 100; i++ {
sw.Update(10)
Expand Down
4 changes: 2 additions & 2 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ type ChainConfig struct {

CancunTime *uint64 `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already activated)
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
// Avalanche Network Upgrades
NetworkUpgrades

NetworkUpgrades // Config for timestamps that enable network upgrades. Skip encoding/decoding directly into ChainConfig.

AvalancheContext `json:"-"` // Avalanche specific context set during VM initialization. Not serialized.

Expand Down
4 changes: 0 additions & 4 deletions plugin/evm/gossiper_atomic_gossiping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package evm

import (
"context"
"os"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -107,9 +106,6 @@ func TestMempoolAtmTxsAppGossipHandling(t *testing.T) {

// show that txs already marked as invalid are not re-requested on gossiping
func TestMempoolAtmTxsAppGossipHandlingDiscardedTx(t *testing.T) {
if os.Getenv("RUN_FLAKY_TESTS") != "true" {
t.Skip("FLAKY")
}
assert := assert.New(t)

_, vm, _, sharedMemory, sender := GenesisVM(t, true, "", "", "")
Expand Down
4 changes: 0 additions & 4 deletions plugin/evm/gossiper_eth_gossiping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"crypto/ecdsa"
"encoding/json"
"math/big"
"os"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -74,9 +73,6 @@ func getValidEthTxs(key *ecdsa.PrivateKey, count int, gasPrice *big.Int) []*type
// show that a geth tx discovered from gossip is requested to the same node that
// gossiped it
func TestMempoolEthTxsAppGossipHandling(t *testing.T) {
if os.Getenv("RUN_FLAKY_TESTS") != "true" {
t.Skip("FLAKY")
}
assert := assert.New(t)

key, err := crypto.GenerateKey()
Expand Down
6 changes: 3 additions & 3 deletions plugin/evm/tx_gossip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestEthTxGossip(t *testing.T) {

network, err := p2p.NewNetwork(logging.NoLog{}, peerSender, prometheus.NewRegistry(), "")
require.NoError(err)
client := network.NewClient(ethTxGossipProtocol)
client := network.NewClient(p2p.TxGossipHandlerID)

// we only accept gossip requests from validators
requestingNodeID := ids.GenerateTestNodeID()
Expand Down Expand Up @@ -363,7 +363,7 @@ func TestEthTxPushGossipOutbound(t *testing.T) {

// we should get a message that has the protocol prefix and the gossip
// message
require.Equal(byte(ethTxGossipProtocol), sent[0])
require.Equal(byte(p2p.TxGossipHandlerID), sent[0])
require.NoError(proto.Unmarshal(sent[1:], got))

marshaller := GossipEthTxMarshaller{}
Expand Down Expand Up @@ -428,7 +428,7 @@ func TestEthTxPushGossipInbound(t *testing.T) {
inboundGossipBytes, err := proto.Marshal(inboundGossip)
require.NoError(err)

inboundGossipMsg := append(binary.AppendUvarint(nil, ethTxGossipProtocol), inboundGossipBytes...)
inboundGossipMsg := append(binary.AppendUvarint(nil, p2p.TxGossipHandlerID), inboundGossipBytes...)
require.NoError(vm.AppGossip(ctx, ids.EmptyNodeID, inboundGossipMsg))

require.True(vm.txPool.Has(signedTx.Hash()))
Expand Down
Loading
Loading