mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
avago bump: Bloom filter metrics + Durango time (#1064)
* avago bump: Bloom filter metrics + Durango time * Update plugin/evm/vm.go Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: Darioush Jalali <[email protected]> --------- Signed-off-by: Darioush Jalali <[email protected]> Co-authored-by: Stephen Buttolph <[email protected]>
This commit is contained in:
committed by
GitHub
co-authored by
Stephen Buttolph
parent
b28858af37
commit
07ff25b373
@@ -5,7 +5,7 @@ go 1.20
|
||||
require (
|
||||
github.com/VictoriaMetrics/fastcache v1.10.0
|
||||
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0
|
||||
github.com/ava-labs/avalanchego v1.10.18
|
||||
github.com/ava-labs/avalanchego v1.10.19-legacy-upgrade-times
|
||||
github.com/cespare/cp v0.1.0
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/deckarep/golang-set/v2 v2.1.0
|
||||
@@ -54,7 +54,7 @@ require (
|
||||
github.com/DataDog/zstd v1.5.2 // indirect
|
||||
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||||
github.com/NYTimes/gziphandler v1.1.1 // indirect
|
||||
github.com/ava-labs/coreth v0.12.10-rc.5 // indirect
|
||||
github.com/ava-labs/coreth v0.12.10-wip-bloom-metrics // 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
|
||||
|
||||
@@ -61,10 +61,10 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0 h1:xNbCMNqenaDr0bb35j27sqwa+C8t8BgRz51vXd6q0QM=
|
||||
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0/go.mod h1:B7Ynk/avkCk49CCIWbM4j1UrPlqIi0IHCPAB2MZNvLw=
|
||||
github.com/ava-labs/avalanchego v1.10.18 h1:ErJ+SJBtN9tVqk3OPRXffpf+MWeQnNZJlBNWQIgAg8A=
|
||||
github.com/ava-labs/avalanchego v1.10.18/go.mod h1:wqmokVcLXE+9Nfa8wHdGJtjEW35acVf8rkraSZPVBA4=
|
||||
github.com/ava-labs/coreth v0.12.10-rc.5 h1:FMVvXHssvMQ3Eade7i85Wsx9tuD3kUOFMG8ktHeDTp8=
|
||||
github.com/ava-labs/coreth v0.12.10-rc.5/go.mod h1:a58HbIBc9jscGc3aL8e7JuG8RfhBBOm63waq1q0YM+U=
|
||||
github.com/ava-labs/avalanchego v1.10.19-legacy-upgrade-times h1:VWI/+vOP63QzrHK2HFw+So+qK1f8gKGpFmdvrKFzOM8=
|
||||
github.com/ava-labs/avalanchego v1.10.19-legacy-upgrade-times/go.mod h1:bxbOXEYGnwz0K6uPsiB56Ig3pQbBfi4P8NOLtRNhNgw=
|
||||
github.com/ava-labs/coreth v0.12.10-wip-bloom-metrics h1:uSISbdHpLVlTkwUUqVonMgdX91ePbgP/qJ7iHup9xS4=
|
||||
github.com/ava-labs/coreth v0.12.10-wip-bloom-metrics/go.mod h1:bw3pxnF+IBw5SoxAKujUiZPbPimieJHPd9fQWZZ/MOM=
|
||||
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=
|
||||
|
||||
+21
-1
@@ -31,8 +31,11 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/ava-labs/avalanchego/snow"
|
||||
"github.com/ava-labs/avalanchego/utils/constants"
|
||||
"github.com/ava-labs/avalanchego/version"
|
||||
"github.com/ava-labs/subnet-evm/commontype"
|
||||
"github.com/ava-labs/subnet-evm/precompile/modules"
|
||||
"github.com/ava-labs/subnet-evm/precompile/precompileconfig"
|
||||
@@ -86,7 +89,7 @@ var (
|
||||
PetersburgBlock: big.NewInt(0),
|
||||
IstanbulBlock: big.NewInt(0),
|
||||
MuirGlacierBlock: big.NewInt(0),
|
||||
MandatoryNetworkUpgrades: MainnetNetworkUpgrades, // This can be changed to correct network (local, test) via VM.
|
||||
MandatoryNetworkUpgrades: GetMandatoryNetworkUpgrades(constants.MainnetID), // This can be changed to correct network (local, test) via VM.
|
||||
GenesisPrecompiles: Precompiles{},
|
||||
}
|
||||
|
||||
@@ -155,6 +158,23 @@ var (
|
||||
TestRules = TestChainConfig.AvalancheRules(new(big.Int), 0)
|
||||
)
|
||||
|
||||
func getUpgradeTime(networkID uint32, upgradeTimes map[uint32]time.Time) *uint64 {
|
||||
if upgradeTime, ok := upgradeTimes[networkID]; ok {
|
||||
return utils.TimeToNewUint64(upgradeTime)
|
||||
}
|
||||
// If the upgrade time isn't specified, default being enabled in the
|
||||
// genesis.
|
||||
return utils.NewUint64(0)
|
||||
}
|
||||
|
||||
// GetMandatoryNetworkUpgrades returns the mandatory network upgrades for the specified network ID.
|
||||
func GetMandatoryNetworkUpgrades(networkID uint32) MandatoryNetworkUpgrades {
|
||||
return MandatoryNetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
DurangoTimestamp: getUpgradeTime(networkID, version.DurangoTimes),
|
||||
}
|
||||
}
|
||||
|
||||
// UpgradeConfig includes the following configs that may be specified in upgradeBytes:
|
||||
// - Timestamps that enable avalanche network upgrades,
|
||||
// - Enabling or disabling precompiles as network upgrades.
|
||||
|
||||
@@ -3,32 +3,6 @@
|
||||
|
||||
package params
|
||||
|
||||
import (
|
||||
"github.com/ava-labs/subnet-evm/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
LocalNetworkUpgrades = MandatoryNetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
DurangoTimestamp: utils.NewUint64(0),
|
||||
}
|
||||
|
||||
FujiNetworkUpgrades = MandatoryNetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
// DurangoTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value
|
||||
}
|
||||
|
||||
MainnetNetworkUpgrades = MandatoryNetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
// DurangoTimestamp: utils.NewUint64(0), // TODO: Uncomment and set this to the correct value
|
||||
}
|
||||
|
||||
UnitTestNetworkUpgrades = MandatoryNetworkUpgrades{
|
||||
SubnetEVMTimestamp: utils.NewUint64(0),
|
||||
DurangoTimestamp: utils.NewUint64(0),
|
||||
}
|
||||
)
|
||||
|
||||
// MandatoryNetworkUpgrades contains timestamps that enable mandatory network upgrades.
|
||||
// These upgrades are mandatory, meaning that if a node does not upgrade by the
|
||||
// specified timestamp, it will be unable to participate in consensus.
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/ava-labs/avalanchego/ids"
|
||||
"github.com/ava-labs/avalanchego/utils/logging"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
"github.com/ava-labs/avalanchego/network/p2p"
|
||||
"github.com/ava-labs/avalanchego/network/p2p/gossip"
|
||||
@@ -84,8 +85,8 @@ func (t txGossipHandler) CrossChainAppRequest(context.Context, ids.ID, time.Time
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewGossipEthTxPool(mempool *txpool.TxPool) (*GossipEthTxPool, error) {
|
||||
bloom, err := gossip.NewBloomFilter(txGossipBloomMinTargetElements, txGossipBloomTargetFalsePositiveRate, txGossipBloomResetFalsePositiveRate)
|
||||
func NewGossipEthTxPool(mempool *txpool.TxPool, registerer prometheus.Registerer) (*GossipEthTxPool, error) {
|
||||
bloom, err := gossip.NewBloomFilter(registerer, "eth_tx_bloom_filter", txGossipBloomMinTargetElements, txGossipBloomTargetFalsePositiveRate, txGossipBloomResetFalsePositiveRate)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to initialize bloom filter: %w", err)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/ava-labs/subnet-evm/params"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -49,11 +50,11 @@ func TestGossipSubscribe(t *testing.T) {
|
||||
txPool.SetGasPrice(common.Big1)
|
||||
txPool.SetMinFee(common.Big0)
|
||||
|
||||
gossipTxPool, err := NewGossipEthTxPool(txPool)
|
||||
gossipTxPool, err := NewGossipEthTxPool(txPool, prometheus.NewRegistry())
|
||||
require.NoError(err)
|
||||
|
||||
// use a custom bloom filter to test the bloom filter reset
|
||||
gossipTxPool.bloom, err = gossip.NewBloomFilter(1, 0.01, 0.0000000000000001) // maxCount =1
|
||||
gossipTxPool.bloom, err = gossip.NewBloomFilter(prometheus.NewRegistry(), "", 1, 0.01, 0.0000000000000001) // maxCount =1
|
||||
require.NoError(err)
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
defer cancel()
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestEthTxGossip(t *testing.T) {
|
||||
}
|
||||
|
||||
// Ask the VM for any new transactions. We should get nothing at first.
|
||||
emptyBloomFilter, err := gossip.NewBloomFilter(txGossipBloomMinTargetElements, txGossipBloomTargetFalsePositiveRate, txGossipBloomResetFalsePositiveRate)
|
||||
emptyBloomFilter, err := gossip.NewBloomFilter(prometheus.NewRegistry(), "", txGossipBloomMinTargetElements, txGossipBloomTargetFalsePositiveRate, txGossipBloomResetFalsePositiveRate)
|
||||
require.NoError(err)
|
||||
emptyBloomFilterBytes, _ := emptyBloomFilter.Marshal()
|
||||
request := &sdk.PullGossipRequest{
|
||||
|
||||
+3
-18
@@ -324,8 +324,8 @@ func (vm *VM) Initialize(
|
||||
g.Config = params.SubnetEVMDefaultChainConfig
|
||||
}
|
||||
|
||||
mandatoryNetworkUpgrades, enforce := getMandatoryNetworkUpgrades(chainCtx.NetworkID)
|
||||
if enforce {
|
||||
mandatoryNetworkUpgrades := params.GetMandatoryNetworkUpgrades(chainCtx.NetworkID)
|
||||
if avalanchegoConstants.ProductionNetworkIDs.Contains(chainCtx.NetworkID) {
|
||||
// We enforce network upgrades here, regardless of the chain config
|
||||
// provided in the genesis file
|
||||
g.Config.MandatoryNetworkUpgrades = mandatoryNetworkUpgrades
|
||||
@@ -693,7 +693,7 @@ func (vm *VM) initBlockBuilding() error {
|
||||
vm.builder.awaitSubmittedTxs()
|
||||
vm.Network.SetGossipHandler(NewGossipHandler(vm, gossipStats))
|
||||
|
||||
ethTxPool, err := NewGossipEthTxPool(vm.txPool)
|
||||
ethTxPool, err := NewGossipEthTxPool(vm.txPool, vm.sdkMetrics)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1091,18 +1091,3 @@ func attachEthService(handler *rpc.Server, apis []rpc.API, names []string) error
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// getMandatoryNetworkUpgrades returns the mandatory network upgrades for the specified network ID,
|
||||
// along with a flag that indicates if returned upgrades should be strictly enforced.
|
||||
func getMandatoryNetworkUpgrades(networkID uint32) (params.MandatoryNetworkUpgrades, bool) {
|
||||
switch networkID {
|
||||
case avalanchegoConstants.MainnetID:
|
||||
return params.MainnetNetworkUpgrades, true
|
||||
case avalanchegoConstants.FujiID:
|
||||
return params.FujiNetworkUpgrades, true
|
||||
case avalanchegoConstants.UnitTestID:
|
||||
return params.UnitTestNetworkUpgrades, false
|
||||
default:
|
||||
return params.LocalNetworkUpgrades, false
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Don't export them as they're used in the context of other calls
|
||||
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.10.18'}
|
||||
AVALANCHE_VERSION=${AVALANCHE_VERSION:-'v1.10.19-legacy-upgrade-times'}
|
||||
GINKGO_VERSION=${GINKGO_VERSION:-'v2.2.0'}
|
||||
|
||||
# This won't be used, but it's here to make code syncs easier
|
||||
|
||||
Reference in New Issue
Block a user