after cleos set account permission, anyone can authorized to others deposit?
I use newest master branch test dice contract.
create a account
wangchh@XEPR03:~$ cleos create account eosio wang.4 EOS8KsyDnHwsUSqxDDowCdJhA8rDou9PMGQ7yx9xKgSpYCWPUaxSb EOS8KsyDnHwsUSqxDDowCdJhA8rDou9PMGQ7yx9xKgSpYCWPUaxSb
executed transaction: f6c7165d8d9dfc496cf21611299e92cf33338cd0716396cf2c498692ecbabb58 200 bytes 529 us
create dice account
wangchh@XEPR03:~$ cleos create account eosio dice EOS8KsyDnHwsUSqxDDowCdJhA8rDou9PMGQ7yx9xKgSpYCWPUaxSb EOS8KsyDnHwsUSqxDDowCdJhA8rDou9PMGQ7yx9xKgSpYCWPUaxSb
executed transaction: 236c56b8744c3e1e3f89d164ee3d9c8988992ed975e3af555515afc926663ba3 200 bytes 289 us
set dice contract
wangchh@XEPR03:~$ cleos set contract dice eos/build/contracts/dice/ -p dice
Reading WAST/WASM from eos/build/contracts/dice/dice.wasm...
Using already assembled WASM...
Publishing contract...
executed transaction: 7392883066edaa4b5f15a2a03479fdd73676ce0c2f71bdae70e7e4dcd6d9a54e 11984 bytes 1485 us
set dice permission? why?
wangchh@XEPR03:~$ cleos set account permission wang.4 active '{"threshold": 1,"keys": [{"key": "EOS8KsyDnHwsUSqxDDowCdJhA8rDou9PMGQ7yx9xKgSpYCWPUaxSb","weight": 1}],"accounts": [{"permission":{"actor":"dice","permission":"eosio.code"},"weight":1}]}' owner -p wang.4
executed transaction: e3f6322913f90037c8eb20e4c5af8b376c783cc5266b4f9917cedf71a9478a75 184 bytes 447 us
issue some currency to wang.4
wangchh@XEPR03:~$ cleos push action eosio.token issue '["wang.4", "1000.0000 SYS" ""]' -p wang.1
executed transaction: 613bd823a38bd97b50ad4605e4a20142e6d50d388fcff7907a4c7b787174bbd5 120 bytes 2004 us
wang.4 deposit 100 to dice, is OK
wangchh@XEPR03:~$ cleos push action dice deposit '[ "wang.4", "100.0000 SYS" ]' -p wang.4
executed transaction: 8b5be3d10c888771d71b170d61825f9f166eaabca342ed5fc52f92eda81bfe1f 120 bytes 2956 us
But why the following is successful -p wang.3 is NOT wang.4
wangchh@XEPR03:~$ cleos push action dice deposit '[ "wang.4", "100.0000 SYS" ]' -p wang.3
executed transaction: 47ea222971aab496e12ced1df1806fa726f144c30bb13066a98fbbab6c75885b 120 bytes 3034 us
even so
wangchh@XEPR03:~$ cleos push action dice deposit '[ "wang.4", "100.0000 SYS" ]' -p eosio.token
executed transaction: f8e2fee87a682c28548586ba941e38ae3c6fe4959bbe45ab944d65dad1a28010 120 bytes 3014 us
I need to know the permission tables for wang.3 and wang.4 there is not quite enough info
@bytemaster notice wang.3 actor != wang.4 actor ##wang.3:
wangchh@XEPR03:~/xpa.ex$ cleos get account wang.3 -j
{
"account_name": "wang.3",
"privileged": false,
"last_code_update": "1970-01-01T00:00:00.000",
"created": "2018-05-24T17:43:28.000",
"ram_quota": -1,
"net_weight": -1,
"cpu_weight": -1,
"net_limit": {
"used": -1,
"available": -1,
"max": -1
},
"cpu_limit": {
"used": -1,
"available": -1,
"max": -1
},
"ram_usage": 2884,
"permissions": [{
"perm_name": "active",
"parent": "owner",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS8KsyDnHwsUSqxDDowCdJhA8rDou9PMGQ7yx9xKgSpYCWPUaxSb",
"weight": 1
}
],
"accounts": [{
"permission": {
"actor": "xpa.ex",
"permission": "eosio.code"
},
"weight": 1
}
],
"waits": []
}
},{
"perm_name": "owner",
"parent": "",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"weight": 1
}
],
"accounts": [],
"waits": []
}
}
],
"total_resources": null,
"delegated_bandwidth": null,
"voter_info": null
}
##wang.4
wangchh@XEPR03:~/xpa.ex$ cleos get account wang.4 -j
{
"account_name": "wang.4",
"privileged": false,
"last_code_update": "1970-01-01T00:00:00.000",
"created": "2018-05-25T01:08:04.000",
"ram_quota": -1,
"net_weight": -1,
"cpu_weight": -1,
"net_limit": {
"used": -1,
"available": -1,
"max": -1
},
"cpu_limit": {
"used": -1,
"available": -1,
"max": -1
},
"ram_usage": 3124,
"permissions": [{
"perm_name": "active",
"parent": "owner",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS8KsyDnHwsUSqxDDowCdJhA8rDou9PMGQ7yx9xKgSpYCWPUaxSb",
"weight": 1
}
],
"accounts": [{
"permission": {
"actor": "dice",
"permission": "eosio.code"
},
"weight": 1
}
],
"waits": []
}
},{
"perm_name": "owner",
"parent": "",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS8KsyDnHwsUSqxDDowCdJhA8rDou9PMGQ7yx9xKgSpYCWPUaxSb",
"weight": 1
}
],
"accounts": [],
"waits": []
}
}
],
"total_resources": null,
"delegated_bandwidth": null,
"voter_info": null
}
deposit is missing require_auth. This action will likely be removed with #3003
yes, thinks @tbfleming but when do withdraw, have to set dice account permission to eosio.code
This isn't a bug in the system, it is a bug in the dice contract. You cannot withdraw from "any" account, only from "any account which granted permission".
In this case:
wangchh@XEPR03:~$ cleos push action dice deposit '[ "wang.4", "100.0000 SYS" ]' -p wang.3
executed transaction: 47ea222971aab496e12ced1df1806fa726f144c30bb13066a98fbbab6c75885b 120 bytes 3034 us
wang.4 granted dice permission to withdraw from his account. wang.3 granted permission to call dice::deposit and dice is allowed to do inline transfer from wang.4
The dice contract should have required_auth(wang.4) on deposit which would have stopped wang.3 from issuing deposit from wang.4