polaris
polaris copied to clipboard
Gas Estimation Issue in Precompile
05fe9eda07dec60d9407aa1ba","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x00664462a20fdf17608fbafdd4c98434b6a42483","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","number":"0x4a","parentHash":"0x2117424493dbbf9990b3b986a25346424845a584aa1be950371eb44b4c772ecd","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","stateRoot":"0x4a188d111fb76a6369f8405d5e2fadcd9ab0d9c9321736230e85a5b16587e1ea","timestamp":"0x64053ed5","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","withdrawalsRoot":null} module=geth txContext={"GasPrice":0,"Origin":"0xad4a4e3ce3f4cf07770e61bec0233feb050e6022"} vmConfig={"Debug":false,"EnablePreimageRecording":false,"ExtraEips":null,"NoBaseFee":true,"Tracer":null}
8:16PM ERR RPC method eth_estimateGas crashed: Int64() out of bound
goroutine 5765 [running]:
github.com/ethereum/go-ethereum/rpc.(*callback).call.func1()
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/rpc/service.go:199 +0x74
panic({0x1038acea0, 0x103d6f4f8})
/opt/homebrew/Cellar/go/1.20.1/libexec/src/runtime/panic.go:884 +0x1f4
cosmossdk.io/math.Int.Int64({0x14003794090?})
/Users/dev/go/pkg/mod/cosmossdk.io/[email protected]/int.go:160 +0x88
github.com/cosmos/cosmos-sdk/types.TokensToConsensusPower({0x3e8?}, {0x3e8?})
/Users/dev/go/pkg/mod/github.com/cosmos/[email protected]/types/staking.go:29 +0x20
github.com/cosmos/cosmos-sdk/x/staking/types.GetValidatorsByPowerIndexKey({{0x1400324d6c0, 0x37}, 0x14003259980, 0x0, 0x3, {0x14003257da0}, {0x14003257dc0}, {{0x14003782c70, 0xc}, {0x0, ...}, ...}, ...}, ...)
/Users/dev/go/pkg/mod/github.com/cosmos/[email protected]/x/staking/types/keys.go:116 +0x28
github.com/cosmos/cosmos-sdk/x/staking/keeper.Keeper.SetValidatorByPowerIndex({{_, _}, {_, _}, {_, _}, {_, _}, {_, _}, ...}, ...)
/Users/dev/go/pkg/mod/github.com/cosmos/[email protected]/x/staking/keeper/validator.go:85 +0xd0
github.com/cosmos/cosmos-sdk/x/staking/keeper.Keeper.AddValidatorTokensAndShares({{_, _}, {_, _}, {_, _}, {_, _}, {_, _}, ...}, ...)
/Users/dev/go/pkg/mod/github.com/cosmos/[email protected]/x/staking/keeper/validator.go:107 +0x27c
github.com/cosmos/cosmos-sdk/x/staking/keeper.Keeper.Delegate({{_, _}, {_, _}, {_, _}, {_, _}, {_, _}, ...}, ...)
/Users/dev/go/pkg/mod/github.com/cosmos/[email protected]/x/staking/keeper/delegation.go:705 +0xd00
github.com/cosmos/cosmos-sdk/x/staking/keeper.msgServer.Delegate({0x14003257360?}, {0x103da1d00?, 0x140037a2000?}, 0x14001791fc0)
/Users/dev/go/pkg/mod/github.com/cosmos/[email protected]/x/staking/keeper/msg_server.go:221 +0x3f4
pkg.berachain.dev/stargazer/precompile/staking.(*Contract).delegateHelper(0x1400300c1e0, {0x103da1d00, 0x140037a2000}, {0xad, 0x4a, 0x4e, 0x3c, 0xe3, 0xf4, 0xcf, ...}, ...)
/Users/dev/go/src/stargazer/precompile/staking/helpers.go:122 +0x108
pkg.berachain.dev/stargazer/precompile/staking.(*Contract).DelegateAddrInput(0x100d90228?, {0x103da1d00, 0x140037a2000}, {0xad, 0x4a, 0x4e, 0x3c, 0xe3, 0xf4, 0xcf, ...}, ...)
/Users/dev/go/src/stargazer/precompile/staking/staking.go:304 +0x118
pkg.berachain.dev/stargazer/eth/core/precompile.(*stateful).Run(0x14003794090?, {0x103da1d00, 0x140037a2000}, {0x1400323ea50, 0x44, 0x44}, {0xad, 0x4a, 0x4e, 0x3c, ...}, ...)
/Users/dev/go/src/stargazer/eth/core/precompile/stateful.go:91 +0xf4
pkg.berachain.dev/stargazer/x/evm/plugins/precompile.(*plugin).Run(0x1400300e8f0, {0x12d66c7f0?, 0x14003792460}, {0x103d99fd0, 0x140023cca68}, {0x1400323ea50, 0x44, 0x44}, {0xad, 0x4a, ...}, ...)
/Users/dev/go/src/stargazer/x/evm/plugins/precompile/plugin.go:126 +0x340
github.com/ethereum/go-ethereum/core/vm.(*EVM).Call(0x1400323bc20, {0x103d819e0, 0x14003254e28}, {0xd9, 0xa9, 0x98, 0xca, 0xc6, 0x60, 0x92, ...}, ...)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/core/vm/evm.go:232 +0x6b8
github.com/ethereum/go-ethereum/core.(*StateTransition).TransitionDb(0x14001538e80)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/core/state_transition.go:359 +0x7a4
github.com/ethereum/go-ethereum/core.ApplyMessage(0x103d14c40?, {0x103db5400?, 0x1400324e7e0?}, 0x103db5400?)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/core/state_transition.go:204 +0x28
github.com/ethereum/go-ethereum/ethapi.DoCall({0x103d9ffe8, 0x140012788c0}, {0x12d9889f0, 0x1400300cba0}, {0x14003254738, 0x14003254750, 0x140037821d0, 0x0, 0x0, 0x0, ...}, ...)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/ethapi/api.go:997 +0x2fc
github.com/ethereum/go-ethereum/ethapi.DoEstimateGas.func1(0xe50ac3)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/ethapi/api.go:1134 +0x114
github.com/ethereum/go-ethereum/ethapi.DoEstimateGas({0x103d9ffe8, 0x140012788c0}, {0x12d9889f0?, 0x1400300cba0?}, {0x14003254738, 0x14003254750, 0x140037821d0, 0x0, 0x0, 0x0, ...}, ...)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/ethapi/api.go:1146 +0x6e4
github.com/ethereum/go-ethereum/ethapi.(*BlockChainAPI).EstimateGas(0x14003081da0, {0x103d9ffe8, 0x140012788c0}, {0x14003254738, 0x14003254750, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/ethapi/api.go:1187 +0x118
reflect.Value.call({0x140004fb110?, 0x1400237c670?, 0x12db79e08?}, {0x102ac938e, 0x4}, {0x14003258540, 0x4, 0x1028fd92c?})
/opt/homebrew/Cellar/go/1.20.1/libexec/src/reflect/value.go:586 +0x838
reflect.Value.Call({0x140004fb110?, 0x1400237c670?, 0x2?}, {0x14003258540?, 0x0?, 0x140032584e0?})
/opt/homebrew/Cellar/go/1.20.1/libexec/src/reflect/value.go:370 +0x90
github.com/ethereum/go-ethereum/rpc.(*callback).call(0x14003b0db60, {0x103d9ffe8?, 0x140012788c0}, {0x140036f5d60, 0xf}, {0x1400325a390, 0x2, 0x1028f73a8?})
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/rpc/service.go:205 +0x34c
github.com/ethereum/go-ethereum/rpc.(*handler).runMethod(0x1400000d400?, {0x103d9ffe8?, 0x140012788c0?}, 0x14003201b20, 0x2?, {0x1400325a390?, 0x14001f88658?, 0x0?})
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/rpc/handler.go:513 +0x40
github.com/ethereum/go-ethereum/rpc.(*handler).handleCall(0x1400324e360, 0x1400325a300, 0x14003201b20)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/rpc/handler.go:459 +0x1d4
github.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg(0x1400324e360, 0x140012788c0?, 0x14003201b20)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/rpc/handler.go:420 +0x1d0
github.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1(0x1400325a300)
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/rpc/handler.go:256 +0x174
github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1()
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/rpc/handler.go:348 +0xbc
created by github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc
/Users/dev/go/pkg/mod/github.com/berachain/[email protected]/rpc/handler.go:344 +0x88
module=geth
8:16PM INF Served eth_estimateGas conn=127.0.0.1:55977 duration=1.115708 err="method handler crashed" module=geth reqid=2382233803
8:16PM INF Timed out dur=988.698 height=75 module=consensus round=0 step=1
8:16PM INF received proposal module=consensus proposal={"Type":32,"block_id":{"hash":"857B503F7647ABB8508768ADDC17C7F175B3D0BCA5BA66395C5698E8997C50B0","parts":{"hash":"5B7F640F17F427DAA8B14CE798802110890FA3A92B93ED828560AEB10452FA10","total":1}},"height":75,"pol_round":-1,"round":0,"signature":"rSbUu89HKhuCa0RNDfFGHv1o1YWhLVeuGi/A9iCHFwI3d3sHfcJRWH2GcZd0ou3HAI6h+i1hnepN+jIqqEhQDQ==","timestamp":"2023-03-06T01:16:07.304652Z"}
8:16PM INF received complete proposal block hash=857B503F7647ABB8508768ADDC17C7F175B3D0BCA5BA66395C5698E8997C50B0 height=75 module=consensus
8:16PM INF finalizing commit of block hash={} height=75 module=consensus num_txs=0 root=3A3B305EF65D800F1D7ABF8EEF06F1ECC384C982345E56F1A723DB3FB8EFD0D6
8:16PM INF keeper.BeginBlocker module=server
8:16PM INF keeper.EndBlocker block header:={"baseFeePerGas":"0x1","difficulty":"0x0","extraData":"0x","gasLimit":"0x1c9c380","gasUsed":"0x0","hash":"0xbb09a54324edb41cdfca6d39cb7499d5e9ff30141ebec43c46a60eb32df98bf3","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000
Dynamic gas is broken. Temporary workaround is static gas. My guess is a cosmos sdk context / meter issue is causing double consumption.
@calbera was this fixed by #539 ?
this one's old, but I think its the delegate function on staking (calling it every other time works), so it hasn't been fixed yet. #539 fixed the regular evm state change (like minting) after calling precompile
@calbera can we close this?
staking Delegate
-- Estimate Gas --
Gas consumed 79146 supplied gas 48186
Gas consumed 79146 supplied gas 72590
Gas consumed 79146 supplied gas 78691
Gas consumed 79146 supplied gas 79072
Gas consumed 79146 supplied gas 79119
Gas consumed 79146 supplied gas 79143
Gas consumed 79146 supplied gas 79144
Gas consumed 79146 supplied gas 79145
-- Execution --
Gas consumed <= supplied gas
staking Undelegate
-- Estimate Gas --
Gas consumed 133305 supplied gas 96994
Gas consumed 133305 supplied gas 121397
Gas consumed 133305 supplied gas 127498
Gas consumed 133305 supplied gas 130548
Gas consumed 133305 supplied gas 132073
Gas consumed 133305 supplied gas 132836
Gas consumed 133305 supplied gas 133217
Gas consumed 133305 supplied gas 133264
Gas consumed 133305 supplied gas 133288
Gas consumed 133305 supplied gas 133300
Gas consumed 133305 supplied gas 133303
Gas consumed 133305 supplied gas 133304
-- Execution --
gas consumed 153759 supplied gas 164290
*with a 20% gas bump