Skip to content

Commit

Permalink
Remove minimum client version check (#2026)
Browse files Browse the repository at this point in the history
* Remove minimum client version check CLI param

* Remove periodic client version checks

* Remove minimum client version test

* Remove minimum client version from contract info

* Update monorepo_commit to remove min-ver-test

We must not test the minimum version check anymore once we removed it.
  • Loading branch information
karlb authored May 17, 2023
1 parent bebd763 commit 8566b27
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 195 deletions.
17 changes: 0 additions & 17 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package main

import (
"context"
"fmt"
"os"
"sort"
Expand All @@ -31,9 +30,7 @@ import (
"github.com/celo-org/celo-blockchain/cmd/utils"
"github.com/celo-org/celo-blockchain/common"
"github.com/celo-org/celo-blockchain/console/prompt"
"github.com/celo-org/celo-blockchain/contracts/blockchain_parameters"
"github.com/celo-org/celo-blockchain/core/types"
"github.com/celo-org/celo-blockchain/core/vm"
"github.com/celo-org/celo-blockchain/eth"
"github.com/celo-org/celo-blockchain/eth/downloader"
"github.com/celo-org/celo-blockchain/ethclient"
Expand All @@ -44,7 +41,6 @@ import (
"github.com/celo-org/celo-blockchain/log"
"github.com/celo-org/celo-blockchain/metrics"
"github.com/celo-org/celo-blockchain/node"
"github.com/celo-org/celo-blockchain/rpc"
"gopkg.in/urfave/cli.v1"
)

Expand Down Expand Up @@ -153,7 +149,6 @@ var (
utils.AnnounceAggressiveQueryEnodeGossipOnEnablementFlag,
utils.PingIPFromPacketFlag,
utils.UseInMemoryDiscoverTableFlag,
utils.VersionCheckFlag,
utils.ProxyFlag,
utils.ProxyInternalFacingEndpointFlag,
utils.ProxiedValidatorAddressFlag,
Expand Down Expand Up @@ -454,18 +449,6 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend) {
utils.Fatalf("Failed to start mining: %v", err)
}
}
if !ctx.GlobalBool(utils.VersionCheckFlag.Name) {
runnerFactory := func() (vm.EVMRunner, error) {
header := backend.CurrentHeader()
stateDB, _, err := backend.StateAndHeaderByNumberOrHash(context.Background(), rpc.BlockNumberOrHashWithHash(header.Hash(), true))
if err != nil {
return nil, err
}
return backend.NewEVMRunner(header, stateDB), nil
}

blockchain_parameters.SpawnCheck(runnerFactory)
}
}

// unlockAccounts unlocks any account specifically requested.
Expand Down
1 change: 0 additions & 1 deletion cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ var AppHelpFlagGroups = []flags.FlagGroup{
{
Name: "MISC",
Flags: []cli.Flag{
utils.VersionCheckFlag,
utils.SnapshotFlag,
utils.BloomFilterSizeFlag,
cli.HelpFlag,
Expand Down
4 changes: 0 additions & 4 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,6 @@ var (
Usage: "Specifies whether to use an in memory discovery table",
}

VersionCheckFlag = cli.BoolFlag{
Name: "disable-version-check",
Usage: "Disable version check. Use if the parameter is set erroneously",
}
DNSDiscoveryFlag = cli.StringFlag{
Name: "discovery.dns",
Usage: "Sets DNS discovery entry points (use \"\" to disable DNS)",
Expand Down
22 changes: 0 additions & 22 deletions contracts/abis/abi_str.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,6 @@ const RegistryStr = `[
]`

const BlockchainParametersStr = `[
{
"constant": true,
"inputs": [],
"name": "getMinimumClientVersion",
"outputs": [
{
"name": "major",
"type": "uint256"
},
{
"name": "minor",
"type": "uint256"
},
{
"name": "patch",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
Expand Down
51 changes: 0 additions & 51 deletions contracts/blockchain_parameters/blockchain_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package blockchain_parameters

import (
"math/big"
"time"

"github.com/celo-org/celo-blockchain/common/hexutil"
"github.com/celo-org/celo-blockchain/contracts"
Expand All @@ -35,29 +34,13 @@ const (
)

var (
getMinimumClientVersionMethod = contracts.NewRegisteredContractMethod(config.BlockchainParametersRegistryId, abis.BlockchainParameters, "getMinimumClientVersion", maxGasForReadBlockchainParameter)
intrinsicGasForAlternativeFeeCurrencyMethod = contracts.NewRegisteredContractMethod(config.BlockchainParametersRegistryId, abis.BlockchainParameters, "intrinsicGasForAlternativeFeeCurrency", maxGasForReadBlockchainParameter)
blockGasLimitMethod = contracts.NewRegisteredContractMethod(config.BlockchainParametersRegistryId, abis.BlockchainParameters, "blockGasLimit", maxGasForReadBlockchainParameter)
getUptimeLookbackWindowMethod = contracts.NewRegisteredContractMethod(config.BlockchainParametersRegistryId, abis.BlockchainParameters, "getUptimeLookbackWindow", maxGasForReadBlockchainParameter)
)

const DefaultIntrinsicGasForAlternativeFeeCurrency = config.IntrinsicGasForAlternativeFeeCurrency

// getMinimumVersion retrieves the client required minimum version
// If a node is running a version smaller than this, it should exit/stop
func getMinimumVersion(vmRunner vm.EVMRunner) (*config.VersionInfo, error) {
version := [3]*big.Int{big.NewInt(0), big.NewInt(0), big.NewInt(0)}
err := getMinimumClientVersionMethod.Query(vmRunner, &version)
if err != nil {
return nil, err
}
return &config.VersionInfo{
Major: version[0].Uint64(),
Minor: version[1].Uint64(),
Patch: version[2].Uint64(),
}, nil
}

// GetIntrinsicGasForAlternativeFeeCurrencyOrDefault retrieves the intrisic gas for transactions that pay gas in
// with an alternative currency (not CELO).
// In case of error, it returns the default value
Expand Down Expand Up @@ -118,44 +101,10 @@ func GetLookbackWindow(vmRunner vm.EVMRunner) (uint64, error) {
return lookbackWindow.Uint64(), nil
}

// checkMinimumVersion performs a check on the client's minimum version
// In case of not passing hte check it will exit the node
func checkMinimumVersion(vmRunner vm.EVMRunner) {
version, err := getMinimumVersion(vmRunner)

if err != nil {
logError("getMinimumClientVersion", err)
return
}

if config.CurrentVersionInfo.Cmp(version) == -1 {
time.Sleep(10 * time.Second)
// TODO this should exist gracefully, not like this
log.Crit("Client version older than required", "current", params.Version, "required", version)
}

}

func logError(method string, err error) {
if err == contracts.ErrRegistryContractNotDeployed {
log.Debug("Error calling "+method, "err", err, "contract", hexutil.Encode(config.BlockchainParametersRegistryId[:]))
} else {
log.Warn("Error calling "+method, "err", err, "contract", hexutil.Encode(config.BlockchainParametersRegistryId[:]))
}
}

// SpawnCheck starts a goroutine that will periodically check the client's minimun version
// In case of not passing hte check it will exit the node
func SpawnCheck(runnerFactory func() (vm.EVMRunner, error)) {
go func() {
for {
time.Sleep(60 * time.Second)

vmRunner, err := runnerFactory()
if err != nil {
continue
}
checkMinimumVersion(vmRunner)
}
}()
}
21 changes: 0 additions & 21 deletions contracts/blockchain_parameters/blockchain_parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,6 @@ import (
. "github.com/onsi/gomega"
)

func TestGetMinimumVersion(t *testing.T) {
testutil.TestFailOnFailingRunner(t, getMinimumVersion)
testutil.TestFailsWhenContractNotDeployed(t, contracts.ErrSmartContractNotDeployed, getMinimumVersion)

t.Run("should return minimum version", func(t *testing.T) {
g := NewGomegaWithT(t)

runner := testutil.NewSingleMethodRunner(
config.BlockchainParametersRegistryId,
"getMinimumClientVersion",
func() (*big.Int, *big.Int, *big.Int) {
return big.NewInt(5), big.NewInt(4), big.NewInt(3)
},
)

version, err := getMinimumVersion(runner)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(version).To(Equal(&config.VersionInfo{Major: 5, Minor: 4, Patch: 3}))
})
}

func TestGetIntrinsicGasForAlternativeFeeCurrency(t *testing.T) {
testutil.TestFailOnFailingRunner(t, getIntrinsicGasForAlternativeFeeCurrency)
testutil.TestFailsWhenContractNotDeployed(t, contracts.ErrSmartContractNotDeployed, getIntrinsicGasForAlternativeFeeCurrency)
Expand Down
3 changes: 0 additions & 3 deletions contracts/testutil/blockchain_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ func NewBlockchainParametersMock() *BlockchainParametersMock {
return mock
}

func (bp *BlockchainParametersMock) GetMinimumClientVersion() (*big.Int, *big.Int, *big.Int) {
return big.NewInt(int64(bp.MinimumVersion.Major)), big.NewInt(int64(bp.MinimumVersion.Minor)), big.NewInt(int64(bp.MinimumVersion.Patch))
}
func (bp *BlockchainParametersMock) BlockGasLimit() *big.Int {
return bp.BlockGasLimitValue
}
Expand Down
2 changes: 1 addition & 1 deletion monorepo_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f9c26529aac16e226d054fcdf51183e6efb28af8
ad770ace57ec3fa1bc1fd540d0321ab2e7317076
75 changes: 0 additions & 75 deletions mycelo/contract/gen_abis.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8566b27

Please sign in to comment.