Skip to content

make GetBalance return the sum of native & sgt balance#24

Merged
blockchaindevsh merged 2 commits intoop-esfrom
sgt_mm
Jan 8, 2025
Merged

make GetBalance return the sum of native & sgt balance#24
blockchaindevsh merged 2 commits intoop-esfrom
sgt_mm

Conversation

@blockchaindevsh
Copy link
Copy Markdown
Collaborator

@blockchaindevsh blockchaindevsh commented Dec 29, 2024

This is a workaround for ethstorage/optimism#148 .

This PR adds another http server for SGT that will include SGT balance for the eth_GetBalance API.

}
b := state.GetBalance(address).ToBig()
return (*hexutil.Big)(b), state.Error()
nativeBalance, sgtBalance := core.GetGasBalancesInBig(state, api.b.ChainConfig(), address)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use a flag to turn it on or off? Or another idea is to use a flag with different port number for SGT balance RPC

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a254afb.

@qzhodl
Copy link
Copy Markdown

qzhodl commented Dec 30, 2024

Has the workaround been tested with MetaMask to confirm it works?

@blockchaindevsh
Copy link
Copy Markdown
Collaborator Author

blockchaindevsh commented Dec 30, 2024

Has the workaround been tested with MetaMask to confirm it works?

Not yet, but I've shipped it to the beta testnet since it doesn't affect consensus. Could you have another try ? If not , I can do it a bit later.

@qzhodl
Copy link
Copy Markdown

qzhodl commented Dec 30, 2024

Has the workaround been tested with MetaMask to confirm it works?

Not yet, but I've shipped it to the beta testnet since it doesn't affect consensus. Could you have another try ? If not , I can do it a bit later.

It worked on my side. However, as we discussed earlier, the side effect is that Metamask displays the SGT balance, which might confuse users when they attempt to transfer it, as the transaction will ultimately fail.

@blockchaindevsh
Copy link
Copy Markdown
Collaborator Author

blockchaindevsh commented Dec 30, 2024

Oops, looks like if user specifies a msg.value greater than native balance, metamask won't stop the user from sending the tx, and the tx will fail like this:

image

But the failed tx isn't on chain, as can be verified by checking nonce.

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

Successfully merging this pull request may close these issues.

3 participants