-
Notifications
You must be signed in to change notification settings - Fork 20k
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
msg.sender throws exception in my constellation of Geth, Solidity, and Web3 #21685
Comments
Is there any log? |
@beyonderyue thank you for the reply ... the log below ... some interesting stuff there for a private blockchain.
|
Can you show the log from the beginning? |
@beyonderyue ... thanks again for the reply. https://gist.github.com/datafatmunger/e1a7539fae85ce35ab79c78716a3f83b Hum...this is not the idea.
|
Found no exception in logs... And I test your contract with remix, it seems ok |
@beyonderyue this is supposed to be a private blockchain ... I'm not sure why it says, starting on mainnet? |
You should set flag --networkid= 65090 |
Okay ... I'm still REALLY stuck here. I'm currently starting Geth as follows: ... even built my own Geth prep'ing to do some serious debugging ... is this correct?, what should networkid be, does it matter?
I've got the most simple contract I can to reproduce the issue:
... compiles, and everything looks fine ... I'm try to just run this thing from the Geth console ... I use this ....
Run with ...
In this case I get ...
Tried...
and ...
Same result ... starts to feel like my wallets are just incorrect or something else is going on ... ? Thanks! cc @beyonderyue |
NetworkId is a unique tag of your private chain, generally can be same as your chainId. |
Can you deploy the contract correctly? I am confused... Or you set the flag networkId, still can't call the contract rightly? |
Contract deploys fine. I can call the contract ... also just fine. What is not working ... it seems is specifically |
It's a bit like my addresses coming from web3 -> Geth don't get translated, even in the console. |
Can you test with remix? Firstly, make sure your geth works correctly. |
Try follows in your geth console var testContract = web3.eth.contract([{"constant":true,"inputs":[],"name":"getAddr","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"title","type":"string"},{"name":"description","type":"string"}],"name":"addPost","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]);
var test = testContract.new(
{
from: web3.eth.accounts[0],
data: '0x608060405234801561001057600080fd5b5061029a806100206000396000f3fe608060405260043610610046576000357c010000000000000000000000000000000000000000000000000000000090048063a74c2bb61461004b578063b02c6516146100a2575b600080fd5b34801561005757600080fd5b50610060610201565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100ae57600080fd5b506101ff600480360360408110156100c557600080fd5b81019080803590602001906401000000008111156100e257600080fd5b8201836020820111156100f457600080fd5b8035906020019184600183028401116401000000008311171561011657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061022a565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505056fea165627a7a723058208a5135b93cb5fd36691f0cd29eb958ac60e33ed30a2abd59a1595e39d3eefdae0029',
gas: '4700000'
}, function (e, contract){
console.log(e, contract);
if (typeof contract.address !== 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
}) After you see the log test.addPost("1", "2", {from: eth.accounts[0]}) test.getAddr() |
Hum ... I don't know that IDE. 🙁 I'm almost 100% my Geth is working, and a simple contract, the get/set an uint totally works. There is something about the storage of the address from msg.sender (Spoiler alert ... I'm gonna guess something is wrong with This illustrates the bug very clearly ... I think.
|
Result from your example:
|
My result:
I also use geth1.9.22 |
Maybe something in the genesis.json? |
You can call test.getAddr() several times... after a new block mined |
A normal gensis file... |
Ah, now we are getting somewhere ... value is there. Can you share the contract you used for the abi, bin in your example? |
I use your contract... pragma solidity >=0.4.22 <0.6.0;
contract Test {
address lastAddr;
function addPost(string memory title, string memory description) public {
//lastAddr = address(0x79D9A20F9A24f4F52da3930F9B3E84144A209E35); // Works
lastAddr = msg.sender; // Throws exception
}
function getAddr() public view returns (address) {
return lastAddr; // This always returns 0x0000000000000000000000000000000000000000, but likely because it throws before it's set in the last function
}
} |
Almost ... :-) |
Okay ... yes, everything works perfect with my 0.5.13 compiler ... it DOES NOT work with 0.7.3. Both the bin and abi files are different .... so I'm not totally sure where it's going wrong. |
OK, maybe need check 0.7 change list... |
It's the abi ... one second, I'm diff'ing the files. |
Looks like 2 things ... missing in the 0.7.3 abi one of which would "fix" the issue ... |
It's not relate to the version of solidity.. |
My result: > Contract mined! Address: 0xb9147fe22c603234479cfe286b6689f4a233c8aa
Current val: 0x0000000000000000000000000000000000000000
Gas: 41990
RESULT: 0x40a34274fb811cfa0de2c994c9b4282e58cf5f48
ERROR: null
Current ---0x0000000000000000000000000000000000000000
RESULT ---0x40a34274fb811cfa0de2c994c9b4282e58cf5f48
>
>
> instance.get.call()
"0x0000000000000000000000000000000000000000"
> instance.get.call()
"0x0000000000000000000000000000000000000000"
>
> instance.set({from: eth.accounts[0]})
"0xeae1327e42503f90a618fee450883e94ce894da3d4331a49982b582608823f43"
> instance.get.call()
"0x0000000000000000000000000000000000000000"
> instance.get.call()
"0x40a34274fb811cfa0de2c994c9b4282e58cf5f48"
> instance.get.call()
"0x40a34274fb811cfa0de2c994c9b4282e58cf5f48" |
Well this was sort of helpful, in that ... it indicated I was not on the right track after all ... I circled back ... I started looking at web3 instead, and found the gas estimation was incorrect ... and then landed here: web3/web3.js#3456 ... So basically, it seems if I do not provide This thread can be closed for now. |
System information
Geth version: 1.9.22-stable-c71a7e26
OS & Version: Linux f6f221184e1a 5.8.13-arch1-1 #1 SMP PREEMPT Thu, 01 Oct 2020 20:40:35 +0000 x86_64 x86_64 x86_64 GNU/Linux
Commit hash : ...
Solidity: 0.7.3+commit.9bfce1f6.Linux.g++
Web3: 1.3.0
Expected behaviour
msg.sender is the from field/address coming in from the HTTP provider in the case of non-constant contract functions.
Actual behaviour
Exception is thrown.
Steps to reproduce the behaviour
Simple contract:
Backtrace
Additional information ...
What web3 is sending ...
... I feel pretty confident the from/sender address is there until it hits geth. 🤷♀️ The contract address is also correct here.
The text was updated successfully, but these errors were encountered: