How can a common person verify the smart contract code is not a scammy code? We can never have a smart contract that is feature ready all at once or even bugless. An upgradeable smart contract is done mostly via the proxy pattern but how to make sure that the assets in a particular contract are secure in case of contract upgrade? (new code maybe rogue).
2 Answers
The smart contracts are there so that you don't have to trust the author of the smart contract in any way but still use it.
It is highly unlikely that a common person verifies the smart contract. A person acquainted with the basics of decentralised application can verify the underlying smart contract on the explorer. If one does not trust explorer they can verify the contract code themselves.
Once you verify a smart contract code, it is fairly simple. If you trust yourself to fully understand the smart contract, you can either use it or don't use it. If there is any possibility of this contract being upgraded, I suggest you completely answer questions like what is the scope of the upgradation?, Does this contract accumulate funds?, Where will the funds go after upgradation?, etc.. before deciding on using it.
If you plan to develop or use upgradable contracts, do read this.
Just to note here, directly using a smart contract is completely different from using a decentralised application as there is an additional level of trust involved.
Most popular defi protocols like AAVE, Compound distribute governance tokens that let holders earn a small profit from the protocol, and allows them to vote on upgrades to the protocol.
How does that stop a malicious contract upgrade from being applied?
The upgrade would get checked by multiple independent stakeholders who hold governance tokens before it gets approved. Keep in mind they all have something to loose if they're upvoting a bad upgrade.
Cant stakeholders be coerced or forced in the real world to accept a bad proposal?
A reasonably decentralized protocol would have 1000s of medium sized stakeholders as opposed to 10 addresses that hold the most of the governance tokens. This must be something a protocol end user would need to check to determine how decentralized the protocol is. (Agreed this is not something end users can automatically check against some metric)
How do you then protect naïve end users from using compromised protocols?
Can have a decentralized "web of trust" like system which incentivizes finders of problems in smart contracts/protocols. This can be directly used by smart contract end users to determine how secure a given protocol is. But to make results of this auditing reliable without it being backed by trusted third parties, this would need to use some decentralized method of auditing + voting. Which means this contract itself would be susceptible to the issues described in the question.