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

How to get right value from "address(this).balance" in local private geth #20804

Closed
daenamkim opened this issue Mar 24, 2020 · 9 comments
Closed

Comments

@daenamkim
Copy link

System information

Geth version: geth version

Geth
Version: 1.9.12-stable
Git Commit: b6f1c8dcc058a936955eb8e5766e2962218924bc
Architecture: amd64
Protocol Versions: [65 64 63]
Go Version: go1.14
Operating System: darwin
GOPATH=/Users/daenamkim/go
GOROOT=/usr/local/opt/go/libexec

OS & Version: Windows/Linux/OSX
image

Expected behaviour

Return right value from address(this).balance

Actual behaviour

Return always 0 from address(this).balance

Steps to reproduce the behaviour

https://gist.github.com/daenamkim/d064bb1ed874d5e2477b179a97a89e93

@karalabe
Copy link
Member

You mentioned that you deployed this on testnets too and they behave the same? Can you send us a contract address on Goerli? Would be super easy to repro that way and verify what's going wrong?

@daenamkim
Copy link
Author

Things that I have tested on TestNet (Ropsten, Rinkeby) were fine but local private node with genesis file in https://gist.github.com/daenamkim/d064bb1ed874d5e2477b179a97a89e93

So I just want to know about some missing configs when I run geth or wrong part of genesis file

@karalabe
Copy link
Member

Aaah, I see. You might be missing the Petersburg hard fork "petersburgBlock": 0. Solidity might use some features introduced in that. See https://github.com/ethereum/go-ethereum#defining-the-private-genesis-state for all the forks

@daenamkim
Copy link
Author

daenamkim commented Mar 25, 2020

Thanks! but even I added "petersburgBlock": 0 (reset chain data) and tried access address(this).balance, it still returned abi: attempting to unmarshall an empty string while arguments are expected 😢

@shoenseiwaso
Copy link
Contributor

@karalabe leaving the new genesis block question aside for now, is there a way to specify the petersburg block for a private PoA network, without resetting the entire network?

Also, the --override.muirglacier and --override.istanbul options do not appear to work for private chains:

$ geth --datadir test <snip> override.istanbul 12 --override.muirglacier 13 console
INFO [03-31|23:01:33.196] Maximum peer count                       ETH=50 LES=0 total=50
INFO [03-31|23:01:33.223] Starting peer-to-peer node               instance=Geth/v1.9.12-stable-b6f1c8dc/darwin-amd64/go1.14
INFO [03-31|23:01:33.223] Allocated trie memory caches             clean=512.00MiB dirty=0.00B
INFO [03-31|23:01:33.223] Allocated cache and file handles         database=./test/geth/chaindata cache=512.00MiB handles=5120
INFO [03-31|23:01:33.312] Opened ancient database                  database=./test/geth/chaindata/ancient
INFO [03-31|23:01:33.313] Initialised chain configuration          config="{ChainID: 25846 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: 0 Petersburg: <nil> Istanbul: <nil>, Muir Glacier: <nil>, Engine: clique}"

Note the Petersburg: <nil> Istanbul: <nil>, Muir Glacier: <nil> despite the override.istanbul 12 --override.muirglacier 13 being passed on the command line.

Is this expected? If so, how can we "upgrade" a currently-running PoA local blockchain?

@shoenseiwaso
Copy link
Contributor

@karalabe ok, partially resolved this with #20841: the sample genesis state omits both Istanbul and Muir Glacier blocks, which need to be set for this to work.

@shoenseiwaso
Copy link
Contributor

@karalabe any comment on the note above about the intended behaviour of --override.istanbul? Is it intended to work on private networks? It would be useful to avoid resetting chain data when a fork occurs.

@holiman
Copy link
Contributor

holiman commented Aug 13, 2020

I'm going to close this, reasoning:

  • The balance(self) is compiled into SELFBALANCE, an opcode introduced in petersburg,
  • Remaining issue abi: attempting to unmarshall... is something else, and it would be better to open a separate ticket if that still is unresolved

@holiman holiman closed this as completed Aug 13, 2020
@holiman
Copy link
Contributor

holiman commented Aug 13, 2020

re --override.istanbul, it's supposed to be used before istanbul, to postpone the built-in schedule. Not meant for custom configurations.

@fjl fjl removed the status:triage label Aug 27, 2020
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

No branches or pull requests

6 participants