Skip to content

avoid capping warnings for gas set by internal system transactions#421

Merged
temaniarpit27 merged 1 commit into
0xPolygon:developfrom
karlonovak:master
Jun 9, 2022
Merged

avoid capping warnings for gas set by internal system transactions#421
temaniarpit27 merged 1 commit into
0xPolygon:developfrom
karlonovak:master

Conversation

@karlonovak

Copy link
Copy Markdown
Contributor

While running bor v0.2.14 I've realised that periodic annoying warnings occur in the logs:

Nov 12 08:44:29 eris bor[1278821]: WARN [11-12|08:44:29.032] Caller gas above allowance, capping      requested=9,223,372,036,854,775,807 cap=50,000,000

It's happening each ~5 minutes and it disrupts the logs and leaves a mess. I started investigating and found out that the message comes from here:
https://github.com/maticnetwork/bor/blob/783f93b1d7ef5e10fcca5a59399ad8b397368e96/internal/ethapi/transaction_args.go#L195

Further, I did a stack trace dump and found two cases that trigger the WARN:

runtime/debug.PrintStack()
	runtime/debug/stack.go:16 +0x19

github.com/ethereum/go-ethereum/internal/ethapi.(*TransactionArgs).ToMessage(0xc00d3cedf8, 0x2faf080, 0xc06da5bac0)
	github.com/ethereum/go-ethereum/internal/ethapi/transaction_args.go:217 +0x811

github.com/ethereum/go-ethereum/internal/ethapi.DoCall({0x17860b8, 0xc06da0b500}, {0x17bf2e0, 0xc002f641c8}, {0x0, 0xc0446ace28, 0xc06f9304a0, 0x0, 0x0, 0x0, ...}, ...)
	github.com/ethereum/go-ethereum/internal/ethapi/api.go:994 +0x277

github.com/ethereum/go-ethereum/internal/ethapi.(*PublicBlockChainAPI).Call(0xc007e460f0, {0x17860b8, 0xc06da0b500}, {0x0, 0xc0446ace28, 0xc06f9304a0, 0x0, 0x0, 0x0, 0x0, ...}, ...)
	github.com/ethereum/go-ethereum/internal/ethapi/api.go:1063 +0x11d

github.com/ethereum/go-ethereum/consensus/bor.(*Bor).GetCurrentValidators(0xc0004b7900, {0x75, 0x22, 0x93, 0x53, 0x46, 0xce, 0x82, 0xc4, 0xac, ...}, ...)    -------> setiraju gas na maxint / 2
	github.com/ethereum/go-ethereum/consensus/bor/bor.go:992 +0x43a

github.com/ethereum/go-ethereum/consensus/bor.(*Bor).Prepare(0xc0004b7900, {0x178c5d8, 0xc0000b7200}, 0xc0693b5b00)
	github.com/ethereum/go-ethereum/consensus/bor/bor.go:647 +0x34c

github.com/ethereum/go-ethereum/miner.(*worker).commitNewWork(0xc021b3ad80, 0xc00d3cfc6c, 0x0, 0x62990e8b)
	github.com/ethereum/go-ethereum/miner/worker.go:939 +0x846

github.com/ethereum/go-ethereum/miner.(*worker).mainLoop(0xc021b3ad80)
	github.com/ethereum/go-ethereum/miner/worker.go:464 +0x67d

created by github.com/ethereum/go-ethereum/miner.newWorker
	github.com/ethereum/go-ethereum/miner/worker.go:231 +0x725

and

runtime/debug.PrintStack()
	runtime/debug/stack.go:16 +0x19

github.com/ethereum/go-ethereum/internal/ethapi.(*TransactionArgs).ToMessage(0xc088274270, 0x2faf080, 0xc073c169a0)
	github.com/ethereum/go-ethereum/internal/ethapi/transaction_args.go:217 +0x811

github.com/ethereum/go-ethereum/internal/ethapi.DoCall({0x17860f0, 0xc000040090}, {0x17bf2e0, 0xc002f641c8}, {0x0, 0xc072232420, 0xc04e9671c0, 0x0, 0x0, 0x0, ...}, ...)
	github.com/ethereum/go-ethereum/internal/ethapi/api.go:994 +0x277

github.com/ethereum/go-ethereum/internal/ethapi.(*PublicBlockChainAPI).Call(0xc007e460f0, {0x17860f0, 0xc000040090}, {0x0, 0xc072232420, 0xc04e9671c0, 0x0, 0x0, 0x0, 0x0, ...}, ...)
	github.com/ethereum/go-ethereum/internal/ethapi/api.go:1063 +0x11d

github.com/ethereum/go-ethereum/consensus/bor.(*GenesisContractsClient).LastStateId(0xc00035bb00, 0x1957aff)
	github.com/ethereum/go-ethereum/consensus/bor/genesis_contracts_client.go:89 +0x2d4

github.com/ethereum/go-ethereum/consensus/bor.(*Bor).CommitStates(0xc0004b7900, 0xc0786fbe00, 0xc01edceb40, {{0x178c5d8, 0xc0000b7200}, {0x17a3cd0, 0xc0004b7900}})
	github.com/ethereum/go-ethereum/consensus/bor/bor.go:1154 +0xd5

github.com/ethereum/go-ethereum/consensus/bor.(*Bor).Finalize(0xc067c59580, {0x178c5d8, 0xc0000b7200}, 0xc01edceb40, 0xc0623ba000, {0xc0623ba000, 0xc0623ba040, 0x22d7b38}, {0x22d7b38, 0x0, ...})
	github.com/ethereum/go-ethereum/consensus/bor/bor.go:704 +0x205

github.com/ethereum/go-ethereum/core.(*StateProcessor).Process(_, _, _, {0x0, {0x0, 0x0}, 0x0, 0x0, 0x0, {0x0, ...}, ...})
	github.com/ethereum/go-ethereum/core/state_processor.go:90 +0xd5a

github.com/ethereum/go-ethereum/core.(*BlockChain).insertChain(0xc0000b7200, {0xc02fb86248, 0x1, 0x1}, 0x1)
	github.com/ethereum/go-ethereum/core/blockchain.go:1924 +0x1cc4

github.com/ethereum/go-ethereum/core.(*BlockChain).InsertChain(0xc0000b7200, {0xc02fb86248, 0x1, 0x1})
	github.com/ethereum/go-ethereum/core/blockchain.go:1699 +0xb54

github.com/ethereum/go-ethereum/eth.newHandler.func3({0xc02fb86248, 0xc080ecb500, 0x792b7ec3cc2a1363})
	github.com/ethereum/go-ethereum/eth/handler.go:214 +0x5f8

github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).importBlocks.func1()
	github.com/ethereum/go-ethereum/eth/fetcher/block_fetcher.go:817 +0x5b3

created by github.com/ethereum/go-ethereum/eth/fetcher.(*BlockFetcher).importBlocks
	github.com/ethereum/go-ethereum/eth/fetcher/block_fetcher.go:791 +0x3cf

Functions that actually pass the gas for genesis contracts interaction use a hardcoded value:
(hexutil.Uint64)(uint64(math.MaxUint64 / 2))
which always results in capping, therefore triggering a warning.

To avoid this, I've added a check that ignores capping warning for in-built contracts by checking gas set by the caller.

@temaniarpit27 temaniarpit27 changed the base branch from master to develop June 8, 2022 08:05
@temaniarpit27 temaniarpit27 requested a review from JekaMas June 9, 2022 06:39
@temaniarpit27 temaniarpit27 merged commit edd21b3 into 0xPolygon:develop Jun 9, 2022
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