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

Checking minimum client version #481

Merged
merged 16 commits into from
Oct 10, 2019
Merged

Conversation

mrsmkl
Copy link
Contributor

@mrsmkl mrsmkl commented Sep 23, 2019

Description

Checks the minimum client version from a smart contract, exits with error message if required version is larger than current version.

Tested

Still need to figure out how to test.

Other changes

Related issues

PR for the smart contract: celo-org/celo-monorepo#1081

Backwards compatibility

@mrsmkl mrsmkl requested a review from asaj as a code owner September 23, 2019 16:22
const defaultGasAmount = 2000000

var (
blockchainParametersABI, _ = abi.JSON(strings.NewReader(blockchainParametersABIString))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use init() and check the error here? (golang newbie here)
@kevjue ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrsmkl can we move this to an init and check the error?

@mcortesi mcortesi assigned mrsmkl and unassigned mcortesi Oct 2, 2019
@mrsmkl mrsmkl assigned mcortesi and asaj and unassigned mrsmkl Oct 2, 2019
@mrsmkl
Copy link
Contributor Author

mrsmkl commented Oct 2, 2019

About killing the node, perhaps we should check for a confirmed block?

@asaj
Copy link
Contributor

asaj commented Oct 3, 2019

About killing the node, perhaps we should check for a confirmed block?

What do you mean by checking for a confirmed block? Do you mean waiting for an additional block?

@mrsmkl
Copy link
Contributor Author

mrsmkl commented Oct 3, 2019

Yeah, I was thinking that it would read the value from some parent block.

@asaj asaj assigned mrsmkl and unassigned asaj Oct 3, 2019
core/state_processor.go Outdated Show resolved Hide resolved
}

if params.CurrentVersionInfo.Cmp(version) == -1 {
time.Sleep(10 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why sleep here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing, it's useful to know that the node cannot exit immediately when making the transaction.

@mrsmkl mrsmkl assigned asaj and timmoreton and unassigned mrsmkl Oct 9, 2019
@asaj asaj dismissed mcortesi’s stale review October 10, 2019 02:00

Changes have been addressed

@@ -156,3 +157,5 @@ const (
// We charge for reading the balance, 1 debit, and 3 credits (refunding gas, paying the gas fee recipient, sending to the infrastructure fund)
AdditionalGasForNonGoldCurrencies uint64 = 3*ExpectedGasForCreditToTransactions + ExpectedGasForDebitFromTransactions + ExpectedGasToReadErc20Balance
)

const ContractCommGas uint64 = 2000000 // gas amount used for querying system contracts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is entirely accurate, as if you look above we specify different amounts for different calls to system contracts. Instead, consider specifying one specific to this call, e.g. MaxGasForGetMinimumClientVersion

@@ -97,7 +97,7 @@ const (
]`
)

const defaultGasAmount = 2000000
const defaultGasAmount = params.ContractCommGas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@@ -84,7 +84,7 @@ const (
"type": "function"
}
]`
gasAmount = 1000000
gasAmount = params.ContractCommGas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@asaj asaj assigned mrsmkl and unassigned timmoreton, mcortesi and asaj Oct 10, 2019
var err error
blockchainParametersABI, err = abi.JSON(strings.NewReader(blockchainParametersABIString))
if err != nil {
log.Error("Error reading ABI for BlockchainParameters", "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably fatal here, since this happens on startup and the erros means a developer bug

Copy link
Contributor

@mcortesi mcortesi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a comment, but the rest is ok

@asaj asaj merged commit c1ae452 into celo-org:master Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blockchain SBAT reference governable smart contract with minimum client version
5 participants