Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ava-labs/subnet-evm into geth-v.1…
Browse files Browse the repository at this point in the history
…3.2-x
  • Loading branch information
darioush committed Mar 25, 2024
2 parents cadd7bb + a8a0e0f commit 1283cb0
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:

env:
tmpnet_data_path: ~/.tmpnet/networks/1000
tmpnet_data_path: ~/.tmpnet/networks
min_go_version: '~1.21.7'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The Subnet EVM runs in a separate process from the main AvalancheGo process and
[v0.6.0] [email protected] (Protocol Version: 33)
[v0.6.1] [email protected] (Protocol Version: 33)
[v0.6.2] [email protected] (Protocol Version: 34)
[v0.6.3] [email protected].2 (Protocol Version: 34)
[v0.6.3] [email protected].3 (Protocol Version: 35)
```

## API
Expand Down
2 changes: 1 addition & 1 deletion compatibility.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rpcChainVMProtocolVersion": {
"v0.6.3": 34,
"v0.6.3": 35,
"v0.6.2": 34,
"v0.6.1": 33,
"v0.6.0": 33,
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/VictoriaMetrics/fastcache v1.10.0
github.com/ava-labs/avalanchego v1.11.2
github.com/ava-labs/avalanchego v1.11.3
github.com/cespare/cp v0.1.0
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set/v2 v2.1.0
Expand Down Expand Up @@ -47,14 +47,14 @@ require (
golang.org/x/sys v0.16.0
golang.org/x/text v0.14.0
golang.org/x/time v0.3.0
google.golang.org/protobuf v1.32.0
google.golang.org/protobuf v1.33.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
)

require (
github.com/DataDog/zstd v1.5.2 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/ava-labs/coreth v0.13.2-0.20240306013913-b6a82a8aaecc // indirect
github.com/ava-labs/coreth v0.13.2-rc.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ 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.2 h1:8iodZ+RjqpRwHdiXPPtvaNt72qravge7voGzw3yPRzg=
github.com/ava-labs/avalanchego v1.11.2/go.mod h1:oTVnF9idL57J4LM/6RByTmKhI4QvV6OCnF99ysyBljE=
github.com/ava-labs/coreth v0.13.2-0.20240306013913-b6a82a8aaecc h1:1IdlOYUXgZArwcO3qASCQ2PGO2MxYJrMM0J2vCbdUGg=
github.com/ava-labs/coreth v0.13.2-0.20240306013913-b6a82a8aaecc/go.mod h1:yhVBvnE5BTcPJS8IKdLy0UIb1FyOD+tuAt/o3k8ywj8=
github.com/ava-labs/avalanchego v1.11.3 h1:Fgf2R46SFsbe3dbaCu0vFPaA8F1zMqdf6Y/NYjG/wcA=
github.com/ava-labs/avalanchego v1.11.3/go.mod h1:ruzSPKSH8GBFegvNsnKerD8+8oVnkJ5ejRAOUQ4pAZU=
github.com/ava-labs/coreth v0.13.2-rc.2 h1:GmXSyDykDUuDyW7933T8lK7Fp6/4k/IcHhLJjkvjUYI=
github.com/ava-labs/coreth v0.13.2-rc.2/go.mod h1:jOapwtgvroqZ2U8PJpoaq1PHrUFOrlgshUWQfM3nba0=
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 Expand Up @@ -990,8 +990,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
12 changes: 4 additions & 8 deletions peer/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ func TestNetworkRouting(t *testing.T) {

func buildCodec(t *testing.T, types ...interface{}) codec.Manager {
codecManager := codec.NewDefaultManager()
c := linearcodec.NewDefault(time.Time{})
c := linearcodec.NewDefault()
for _, typ := range types {
assert.NoError(t, c.RegisterType(typ))
}
Expand All @@ -871,7 +871,7 @@ type testAppSender struct {
sendCrossChainAppResponseFn func(ids.ID, uint32, []byte) error
sendAppRequestFn func(context.Context, set.Set[ids.NodeID], uint32, []byte) error
sendAppResponseFn func(ids.NodeID, uint32, []byte) error
sendAppGossipFn func([]byte, int, int, int) error
sendAppGossipFn func(common.SendConfig, []byte) error
}

func (t testAppSender) SendCrossChainAppRequest(_ context.Context, chainID ids.ID, requestID uint32, appRequestBytes []byte) error {
Expand All @@ -882,10 +882,6 @@ func (t testAppSender) SendCrossChainAppResponse(_ context.Context, chainID ids.
return t.sendCrossChainAppResponseFn(chainID, requestID, appResponseBytes)
}

func (t testAppSender) SendAppGossipSpecific(context.Context, set.Set[ids.NodeID], []byte) error {
panic("not implemented")
}

func (t testAppSender) SendAppRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, message []byte) error {
return t.sendAppRequestFn(ctx, nodeIDs, requestID, message)
}
Expand All @@ -894,8 +890,8 @@ func (t testAppSender) SendAppResponse(_ context.Context, nodeID ids.NodeID, req
return t.sendAppResponseFn(nodeID, requestID, message)
}

func (t testAppSender) SendAppGossip(_ context.Context, message []byte, numValidators int, numNonValidators int, numPeers int) error {
return t.sendAppGossipFn(message, numValidators, numNonValidators, numPeers)
func (t testAppSender) SendAppGossip(_ context.Context, config common.SendConfig, message []byte) error {
return t.sendAppGossipFn(config, message)
}

func (t testAppSender) SendAppError(ctx context.Context, nodeID ids.NodeID, requestID uint32, errorCode int32, errorMessage string) error {
Expand Down
6 changes: 6 additions & 0 deletions plugin/evm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
defaultMaxBlocksPerRequest = 0 // Default to no maximum on the number of blocks per getLogs request
defaultContinuousProfilerFrequency = 15 * time.Minute
defaultContinuousProfilerMaxFiles = 5
defaultPushGossipPercentStake = .9
defaultPushGossipNumValidators = 100
defaultPushGossipNumPeers = 0
defaultPushRegossipNumValidators = 10
Expand Down Expand Up @@ -154,6 +155,7 @@ type Config struct {
KeystoreInsecureUnlockAllowed bool `json:"keystore-insecure-unlock-allowed"`

// Gossip Settings
PushGossipPercentStake float64 `json:"push-gossip-percent-stake"`
PushGossipNumValidators int `json:"push-gossip-num-validators"`
PushGossipNumPeers int `json:"push-gossip-num-peers"`
PushRegossipNumValidators int `json:"push-regossip-num-validators"`
Expand Down Expand Up @@ -262,6 +264,7 @@ func (c *Config) SetDefaults() {
c.AcceptorQueueLimit = defaultAcceptorQueueLimit
c.CommitInterval = defaultCommitInterval
c.SnapshotWait = defaultSnapshotWait
c.PushGossipPercentStake = defaultPushGossipPercentStake
c.PushGossipNumValidators = defaultPushGossipNumValidators
c.PushGossipNumPeers = defaultPushGossipNumPeers
c.PushRegossipNumValidators = defaultPushRegossipNumValidators
Expand Down Expand Up @@ -319,6 +322,9 @@ func (c *Config) Validate() error {
return fmt.Errorf("cannot use commit interval of 0 with pruning enabled")
}

if c.PushGossipPercentStake < 0 || c.PushGossipPercentStake > 1 {
return fmt.Errorf("push-gossip-percent-stake is %f but must be in the range [0, 1]", c.PushGossipPercentStake)
}
return nil
}

Expand Down
4 changes: 3 additions & 1 deletion plugin/evm/gossiper_eth_gossiping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/set"

commonEng "github.com/ava-labs/avalanchego/snow/engine/common"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
Expand Down Expand Up @@ -105,7 +107,7 @@ func TestMempoolEthTxsAppGossipHandling(t *testing.T) {
return nil
}
wg.Add(1)
sender.SendAppGossipF = func(context.Context, []byte, int, int, int) error {
sender.SendAppGossipF = func(context.Context, commonEng.SendConfig, []byte) error {
wg.Done()
return nil
}
Expand Down
6 changes: 2 additions & 4 deletions plugin/evm/message/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package message

import (
"time"

"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/codec/linearcodec"
"github.com/ava-labs/avalanchego/utils/units"
Expand All @@ -24,7 +22,7 @@ var (

func init() {
Codec = codec.NewManager(maxMessageSize)
c := linearcodec.NewDefault(time.Time{})
c := linearcodec.NewDefault()

errs := wrappers.Errs{}
errs.Add(
Expand Down Expand Up @@ -55,7 +53,7 @@ func init() {
}

CrossChainCodec = codec.NewManager(maxMessageSize)
ccc := linearcodec.NewDefault(time.Time{})
ccc := linearcodec.NewDefault()

errs = wrappers.Errs{}
errs.Add(
Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/syncervm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestStateSyncToggleEnabledToDisabled(t *testing.T) {

syncDisabledVM := &VM{}
appSender := &commonEng.SenderTest{T: t}
appSender.SendAppGossipF = func(context.Context, []byte, int, int, int) error { return nil }
appSender.SendAppGossipF = func(context.Context, commonEng.SendConfig, []byte) error { return nil }
appSender.SendAppRequestF = func(ctx context.Context, nodeSet set.Set[ids.NodeID], requestID uint32, request []byte) error {
nodeID, hasItem := nodeSet.Pop()
if !hasItem {
Expand Down
21 changes: 16 additions & 5 deletions plugin/evm/tx_gossip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ func TestEthTxGossip(t *testing.T) {
return 0, nil
}
validatorState.GetValidatorSetF = func(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) {
return map[ids.NodeID]*validators.GetValidatorOutput{requestingNodeID: nil}, nil
return map[ids.NodeID]*validators.GetValidatorOutput{
requestingNodeID: {
NodeID: requestingNodeID,
Weight: 1,
},
}, nil
}

// Ask the VM for any new transactions. We should get nothing at first.
Expand Down Expand Up @@ -148,12 +153,19 @@ func TestEthTxPushGossipOutbound(t *testing.T) {
require := require.New(t)
ctx := context.Background()
snowCtx := utils.TestSnowContext()
snowCtx.ValidatorState = &validators.TestState{
GetCurrentHeightF: func(context.Context) (uint64, error) {
return 0, nil
},
GetValidatorSetF: func(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) {
return nil, nil
},
}
sender := &common.FakeSender{
SentAppGossip: make(chan []byte, 1),
}

vm := &VM{
p2pSender: sender,
ethTxPullGossiper: gossip.NoOpGossiper{},
}

Expand All @@ -166,7 +178,7 @@ func TestEthTxPushGossipOutbound(t *testing.T) {
nil,
make(chan common.Message),
nil,
&common.FakeSender{},
sender,
))
require.NoError(vm.SetState(ctx, snow.NormalOp))

Expand Down Expand Up @@ -207,7 +219,6 @@ func TestEthTxPushGossipInbound(t *testing.T) {

sender := &common.SenderTest{}
vm := &VM{
p2pSender: sender,
ethTxPullGossiper: gossip.NoOpGossiper{},
}

Expand All @@ -220,7 +231,7 @@ func TestEthTxPushGossipInbound(t *testing.T) {
nil,
make(chan common.Message),
nil,
&common.FakeSender{},
sender,
))
require.NoError(vm.SetState(ctx, snow.NormalOp))

Expand Down
6 changes: 4 additions & 2 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,8 +698,9 @@ func (vm *VM) initBlockBuilding() error {
}()

pushGossipParams := gossip.BranchingFactor{
Validators: vm.config.PushGossipNumValidators,
Peers: vm.config.PushGossipNumPeers,
StakePercentage: vm.config.PushGossipPercentStake,
Validators: vm.config.PushGossipNumValidators,
Peers: vm.config.PushGossipNumPeers,
}
pushRegossipParams := gossip.BranchingFactor{
Validators: vm.config.PushRegossipNumValidators,
Expand All @@ -711,6 +712,7 @@ func (vm *VM) initBlockBuilding() error {
ethTxPushGossiper, err = gossip.NewPushGossiper[*GossipEthTx](
ethTxGossipMarshaller,
ethTxPool,
vm.validators,
ethTxGossipClient,
ethTxGossipMetrics,
pushGossipParams,
Expand Down
4 changes: 2 additions & 2 deletions plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func GenesisVM(t *testing.T,
ctx, dbManager, genesisBytes, issuer, _ := setupGenesis(t, genesisJSON)
appSender := &commonEng.SenderTest{T: t}
appSender.CantSendAppGossip = true
appSender.SendAppGossipF = func(context.Context, []byte, int, int, int) error { return nil }
appSender.SendAppGossipF = func(context.Context, commonEng.SendConfig, []byte) error { return nil }
err := vm.Initialize(
context.Background(),
ctx,
Expand Down Expand Up @@ -1994,7 +1994,7 @@ func TestConfigureLogLevel(t *testing.T) {
ctx, dbManager, genesisBytes, issuer, _ := setupGenesis(t, test.genesisJSON)
appSender := &commonEng.SenderTest{T: t}
appSender.CantSendAppGossip = true
appSender.SendAppGossipF = func(context.Context, []byte, int, int, int) error { return nil }
appSender.SendAppGossipF = func(context.Context, commonEng.SendConfig, []byte) error { return nil }
err := vm.Initialize(
context.Background(),
ctx,
Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/vm_upgrade_bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func TestNetworkUpgradesOverriden(t *testing.T) {
ctx, dbManager, genesisBytes, issuer, _ := setupGenesis(t, string(genesisBytes))
appSender := &commonEng.SenderTest{T: t}
appSender.CantSendAppGossip = true
appSender.SendAppGossipF = func(context.Context, []byte, int, int, int) error { return nil }
appSender.SendAppGossipF = func(context.Context, commonEng.SendConfig, []byte) error { return nil }
err = vm.Initialize(
context.Background(),
ctx,
Expand Down
3 changes: 1 addition & 2 deletions predicate/predicate_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package predicate
import (
"fmt"
"strings"
"time"

"github.com/ava-labs/avalanchego/codec"
"github.com/ava-labs/avalanchego/codec/linearcodec"
Expand All @@ -25,7 +24,7 @@ var Codec codec.Manager
func init() {
Codec = codec.NewManager(MaxResultsSize)

c := linearcodec.NewDefault(time.Time{})
c := linearcodec.NewDefault()
errs := wrappers.Errs{}
errs.Add(
c.RegisterType(Results{}),
Expand Down
2 changes: 1 addition & 1 deletion scripts/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# shellcheck disable=SC2034

# Don't export them as they're used in the context of other calls
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.11.2'}
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.11.3'}
GINKGO_VERSION=${GINKGO_VERSION:-'v2.2.0'}

# This won't be used, but it's here to make code syncs easier
Expand Down
20 changes: 11 additions & 9 deletions utils/snow.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ava-labs/avalanchego/api/metrics"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/logging"
)
Expand All @@ -18,14 +19,15 @@ func TestSnowContext() *snow.Context {
}
pk := bls.PublicFromSecretKey(sk)
return &snow.Context{
NetworkID: 0,
SubnetID: ids.Empty,
ChainID: ids.Empty,
NodeID: ids.EmptyNodeID,
PublicKey: pk,
Log: logging.NoLog{},
BCLookup: ids.NewAliaser(),
Metrics: metrics.NewOptionalGatherer(),
ChainDataDir: "",
NetworkID: 0,
SubnetID: ids.Empty,
ChainID: ids.Empty,
NodeID: ids.EmptyNodeID,
PublicKey: pk,
Log: logging.NoLog{},
BCLookup: ids.NewAliaser(),
Metrics: metrics.NewOptionalGatherer(),
ChainDataDir: "",
ValidatorState: &validators.TestState{},
}
}
2 changes: 1 addition & 1 deletion warp/aggregator/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func newValidator(t testing.TB, weight uint64) (*bls.SecretKey, *avalancheWarp.V
pk := bls.PublicFromSecretKey(sk)
return sk, &avalancheWarp.Validator{
PublicKey: pk,
PublicKeyBytes: bls.PublicKeyToBytes(pk),
PublicKeyBytes: bls.PublicKeyToCompressedBytes(pk),
Weight: weight,
NodeIDs: []ids.NodeID{ids.GenerateTestNodeID()},
}
Expand Down

0 comments on commit 1283cb0

Please sign in to comment.