Skip to content

Commit 8566b27

Browse files
authored
Remove minimum client version check (#2026)
* 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.
1 parent bebd763 commit 8566b27

File tree

9 files changed

+1
-195
lines changed

9 files changed

+1
-195
lines changed

cmd/geth/main.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package main
1919

2020
import (
21-
"context"
2221
"fmt"
2322
"os"
2423
"sort"
@@ -31,9 +30,7 @@ import (
3130
"github.com/celo-org/celo-blockchain/cmd/utils"
3231
"github.com/celo-org/celo-blockchain/common"
3332
"github.com/celo-org/celo-blockchain/console/prompt"
34-
"github.com/celo-org/celo-blockchain/contracts/blockchain_parameters"
3533
"github.com/celo-org/celo-blockchain/core/types"
36-
"github.com/celo-org/celo-blockchain/core/vm"
3734
"github.com/celo-org/celo-blockchain/eth"
3835
"github.com/celo-org/celo-blockchain/eth/downloader"
3936
"github.com/celo-org/celo-blockchain/ethclient"
@@ -44,7 +41,6 @@ import (
4441
"github.com/celo-org/celo-blockchain/log"
4542
"github.com/celo-org/celo-blockchain/metrics"
4643
"github.com/celo-org/celo-blockchain/node"
47-
"github.com/celo-org/celo-blockchain/rpc"
4844
"gopkg.in/urfave/cli.v1"
4945
)
5046

@@ -153,7 +149,6 @@ var (
153149
utils.AnnounceAggressiveQueryEnodeGossipOnEnablementFlag,
154150
utils.PingIPFromPacketFlag,
155151
utils.UseInMemoryDiscoverTableFlag,
156-
utils.VersionCheckFlag,
157152
utils.ProxyFlag,
158153
utils.ProxyInternalFacingEndpointFlag,
159154
utils.ProxiedValidatorAddressFlag,
@@ -454,18 +449,6 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend) {
454449
utils.Fatalf("Failed to start mining: %v", err)
455450
}
456451
}
457-
if !ctx.GlobalBool(utils.VersionCheckFlag.Name) {
458-
runnerFactory := func() (vm.EVMRunner, error) {
459-
header := backend.CurrentHeader()
460-
stateDB, _, err := backend.StateAndHeaderByNumberOrHash(context.Background(), rpc.BlockNumberOrHashWithHash(header.Hash(), true))
461-
if err != nil {
462-
return nil, err
463-
}
464-
return backend.NewEVMRunner(header, stateDB), nil
465-
}
466-
467-
blockchain_parameters.SpawnCheck(runnerFactory)
468-
}
469452
}
470453

471454
// unlockAccounts unlocks any account specifically requested.

cmd/geth/usage.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ var AppHelpFlagGroups = []flags.FlagGroup{
236236
{
237237
Name: "MISC",
238238
Flags: []cli.Flag{
239-
utils.VersionCheckFlag,
240239
utils.SnapshotFlag,
241240
utils.BloomFilterSizeFlag,
242241
cli.HelpFlag,

cmd/utils/flags.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,10 +635,6 @@ var (
635635
Usage: "Specifies whether to use an in memory discovery table",
636636
}
637637

638-
VersionCheckFlag = cli.BoolFlag{
639-
Name: "disable-version-check",
640-
Usage: "Disable version check. Use if the parameter is set erroneously",
641-
}
642638
DNSDiscoveryFlag = cli.StringFlag{
643639
Name: "discovery.dns",
644640
Usage: "Sets DNS discovery entry points (use \"\" to disable DNS)",

contracts/abis/abi_str.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,6 @@ const RegistryStr = `[
2424
]`
2525

2626
const BlockchainParametersStr = `[
27-
{
28-
"constant": true,
29-
"inputs": [],
30-
"name": "getMinimumClientVersion",
31-
"outputs": [
32-
{
33-
"name": "major",
34-
"type": "uint256"
35-
},
36-
{
37-
"name": "minor",
38-
"type": "uint256"
39-
},
40-
{
41-
"name": "patch",
42-
"type": "uint256"
43-
}
44-
],
45-
"payable": false,
46-
"stateMutability": "view",
47-
"type": "function"
48-
},
4927
{
5028
"constant": true,
5129
"inputs": [],

contracts/blockchain_parameters/blockchain_parameters.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package blockchain_parameters
1818

1919
import (
2020
"math/big"
21-
"time"
2221

2322
"github.com/celo-org/celo-blockchain/common/hexutil"
2423
"github.com/celo-org/celo-blockchain/contracts"
@@ -35,29 +34,13 @@ const (
3534
)
3635

3736
var (
38-
getMinimumClientVersionMethod = contracts.NewRegisteredContractMethod(config.BlockchainParametersRegistryId, abis.BlockchainParameters, "getMinimumClientVersion", maxGasForReadBlockchainParameter)
3937
intrinsicGasForAlternativeFeeCurrencyMethod = contracts.NewRegisteredContractMethod(config.BlockchainParametersRegistryId, abis.BlockchainParameters, "intrinsicGasForAlternativeFeeCurrency", maxGasForReadBlockchainParameter)
4038
blockGasLimitMethod = contracts.NewRegisteredContractMethod(config.BlockchainParametersRegistryId, abis.BlockchainParameters, "blockGasLimit", maxGasForReadBlockchainParameter)
4139
getUptimeLookbackWindowMethod = contracts.NewRegisteredContractMethod(config.BlockchainParametersRegistryId, abis.BlockchainParameters, "getUptimeLookbackWindow", maxGasForReadBlockchainParameter)
4240
)
4341

4442
const DefaultIntrinsicGasForAlternativeFeeCurrency = config.IntrinsicGasForAlternativeFeeCurrency
4543

46-
// getMinimumVersion retrieves the client required minimum version
47-
// If a node is running a version smaller than this, it should exit/stop
48-
func getMinimumVersion(vmRunner vm.EVMRunner) (*config.VersionInfo, error) {
49-
version := [3]*big.Int{big.NewInt(0), big.NewInt(0), big.NewInt(0)}
50-
err := getMinimumClientVersionMethod.Query(vmRunner, &version)
51-
if err != nil {
52-
return nil, err
53-
}
54-
return &config.VersionInfo{
55-
Major: version[0].Uint64(),
56-
Minor: version[1].Uint64(),
57-
Patch: version[2].Uint64(),
58-
}, nil
59-
}
60-
6144
// GetIntrinsicGasForAlternativeFeeCurrencyOrDefault retrieves the intrisic gas for transactions that pay gas in
6245
// with an alternative currency (not CELO).
6346
// In case of error, it returns the default value
@@ -118,44 +101,10 @@ func GetLookbackWindow(vmRunner vm.EVMRunner) (uint64, error) {
118101
return lookbackWindow.Uint64(), nil
119102
}
120103

121-
// checkMinimumVersion performs a check on the client's minimum version
122-
// In case of not passing hte check it will exit the node
123-
func checkMinimumVersion(vmRunner vm.EVMRunner) {
124-
version, err := getMinimumVersion(vmRunner)
125-
126-
if err != nil {
127-
logError("getMinimumClientVersion", err)
128-
return
129-
}
130-
131-
if config.CurrentVersionInfo.Cmp(version) == -1 {
132-
time.Sleep(10 * time.Second)
133-
// TODO this should exist gracefully, not like this
134-
log.Crit("Client version older than required", "current", params.Version, "required", version)
135-
}
136-
137-
}
138-
139104
func logError(method string, err error) {
140105
if err == contracts.ErrRegistryContractNotDeployed {
141106
log.Debug("Error calling "+method, "err", err, "contract", hexutil.Encode(config.BlockchainParametersRegistryId[:]))
142107
} else {
143108
log.Warn("Error calling "+method, "err", err, "contract", hexutil.Encode(config.BlockchainParametersRegistryId[:]))
144109
}
145110
}
146-
147-
// SpawnCheck starts a goroutine that will periodically check the client's minimun version
148-
// In case of not passing hte check it will exit the node
149-
func SpawnCheck(runnerFactory func() (vm.EVMRunner, error)) {
150-
go func() {
151-
for {
152-
time.Sleep(60 * time.Second)
153-
154-
vmRunner, err := runnerFactory()
155-
if err != nil {
156-
continue
157-
}
158-
checkMinimumVersion(vmRunner)
159-
}
160-
}()
161-
}

contracts/blockchain_parameters/blockchain_parameters_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,6 @@ import (
1212
. "github.com/onsi/gomega"
1313
)
1414

15-
func TestGetMinimumVersion(t *testing.T) {
16-
testutil.TestFailOnFailingRunner(t, getMinimumVersion)
17-
testutil.TestFailsWhenContractNotDeployed(t, contracts.ErrSmartContractNotDeployed, getMinimumVersion)
18-
19-
t.Run("should return minimum version", func(t *testing.T) {
20-
g := NewGomegaWithT(t)
21-
22-
runner := testutil.NewSingleMethodRunner(
23-
config.BlockchainParametersRegistryId,
24-
"getMinimumClientVersion",
25-
func() (*big.Int, *big.Int, *big.Int) {
26-
return big.NewInt(5), big.NewInt(4), big.NewInt(3)
27-
},
28-
)
29-
30-
version, err := getMinimumVersion(runner)
31-
g.Expect(err).ToNot(HaveOccurred())
32-
g.Expect(version).To(Equal(&config.VersionInfo{Major: 5, Minor: 4, Patch: 3}))
33-
})
34-
}
35-
3615
func TestGetIntrinsicGasForAlternativeFeeCurrency(t *testing.T) {
3716
testutil.TestFailOnFailingRunner(t, getIntrinsicGasForAlternativeFeeCurrency)
3817
testutil.TestFailsWhenContractNotDeployed(t, contracts.ErrSmartContractNotDeployed, getIntrinsicGasForAlternativeFeeCurrency)

contracts/testutil/blockchain_parameters.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ func NewBlockchainParametersMock() *BlockchainParametersMock {
2929
return mock
3030
}
3131

32-
func (bp *BlockchainParametersMock) GetMinimumClientVersion() (*big.Int, *big.Int, *big.Int) {
33-
return big.NewInt(int64(bp.MinimumVersion.Major)), big.NewInt(int64(bp.MinimumVersion.Minor)), big.NewInt(int64(bp.MinimumVersion.Patch))
34-
}
3532
func (bp *BlockchainParametersMock) BlockGasLimit() *big.Int {
3633
return bp.BlockGasLimitValue
3734
}

monorepo_commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f9c26529aac16e226d054fcdf51183e6efb28af8
1+
ad770ace57ec3fa1bc1fd540d0321ab2e7317076

mycelo/contract/gen_abis.go

Lines changed: 0 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)