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

make eth_call not timeout during UpdateM1 #595

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Jul 30, 2024

Proposed changes

The value of timeout for a single call is 5 seconds now.

func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *StateOverride) (hexutil.Bytes, error) {
        // ......
	result, _, failed, err, vmErr := DoCall(ctx, s.b, args, *blockNrOrHash, overrides, vm.Config{}, 5*time.Second, s.b.RPCGasCap())
	if err != nil {
		return nil, err
	}
	// ......
}

When the system is extremely slow, such as the CPU is exhausted, the function Call will return err="execution aborted (timeout = 5s)". This is OK for normal transactions. But when we call the function UpdateM1:

// in function WriteBlockWithState
err := bc.UpdateM1()
if err != nil {
    log.Crit("Error when update masternodes set. Stopping node", "err", err, "blockNum", block.NumberU64())
}

// in function reorg
err := bc.UpdateM1()
if err != nil {
    log.Crit("Error when update masternodes set. Stopping node", "err", err, "blockNumber", newChain[i].NumberU64())
}

if UpdateM1 returns timeout error, then the node will exit by log.Crit. The function UpdateM1 calls the function of contract MasternodeVotingSMC(xdc0000000000000000000000000000000000000088). So this PR change the timeout value for the transactions of MasternodeVotingSMC to zero which means infinite.

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

@gzliudan gzliudan changed the title make MasternodeVotingSMC tx never timeout make UpdateM1 not timeout Jul 30, 2024
@gzliudan gzliudan changed the title make UpdateM1 not timeout make UpdateM1 not return err because of eth_call timeout Jul 31, 2024
@gzliudan gzliudan changed the title make UpdateM1 not return err because of eth_call timeout make UpdateM1 not return err when eth_call timeout Jul 31, 2024
@gzliudan gzliudan changed the title make UpdateM1 not return err when eth_call timeout make eth_call not timeout during UpdateM1 Jul 31, 2024
@liam-icheng-lai
Copy link

End to End test success on devnet rpc node while CPU is reaching 100% , it took 1m and 22s to finish the update masternode.

INFO [08-02|23:12:20] It's time to update new set of masternodes for the next epoch...
WARN [08-02|23:12:25] Served debug_traceTransaction            conn=144.126.140.1:45372 reqid=1                t=11m58.160660966s err="execution timeout"
WARN [08-02|23:12:41] [sendTimeout] Timeout message generated, ready to send! timeoutMsgRound=13695974 timeoutMsgGapNumber=20720250 whosTurn=xdc02E98d4800A1369868Aff80D0c82B0c668108Ac3
WARN [08-02|23:13:11] [sendTimeout] Timeout message generated, ready to send! timeoutMsgRound=13695974 timeoutMsgGapNumber=20720250 whosTurn=xdc02E98d4800A1369868Aff80D0c82B0c668108Ac3
WARN [08-02|23:13:29] Served debug_traceTransaction            conn=144.126.140.1:43976 reqid=2                t=1m48.045565363s  err="execution timeout"
INFO [08-02|23:13:39] Ordered list of masternode candidates
INFO [08-02|23:13:39]                                          address=xdc32606C74A18C3E97fA0e87D2e64096852676740f stake=10000000000000000000000000
...
INFO [08-02|23:13:39] Updating new set of masternodes
INFO [08-02|23:13:39] [UpdateMasternodes] take snapshot        number=20722050 hash=ff837c…fb0ebd
INFO [08-02|23:13:39] [UpdateMasternodes] New set of masternodes has been updated to snapshot number=20722050 hash=ff837c…fb0ebd
INFO [08-02|23:13:39] masternode                               index=0        address=xdc32606C74A18C3E97fA0e87D2e64096852676740f
...
INFO [08-02|23:13:39] Masternodes are ready for the next epoch
INFO [08-02|23:13:39] Imported new chain segment               blocks=2  txs=0   mgas=0.000  elapsed=1m22.370s     mgasps=0.000  number=20722050 hash=ff837c…fb0ebd                                                      cache=0.00B

@liam-lai liam-lai merged commit a0081d9 into XinFinOrg:dev-upgrade Aug 2, 2024
17 checks passed
@gzliudan gzliudan deleted the UpdateM1-timeout branch August 2, 2024 23:30
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.

3 participants