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

iTx的gas机制 #209

Open
blackpainter opened this issue Sep 19, 2019 · 1 comment
Open

iTx的gas机制 #209

blackpainter opened this issue Sep 19, 2019 · 1 comment

Comments

@blackpainter
Copy link
Member

gasUsed, err := app.gasHandler(runCtx, tx.ITxs[0].GetGasPayer())

一个transaction中含多条iTx时,当前gas策略是,先执行所有交易,再扣gas,且只扣第一个iTx的gas

存在问题:
假如扣gas失败,则整个交易回滚,之前的计算资源被浪费
应用可以将耗费gas较大的iTx放在后面,规避gas

方案:
扣gas失败的iTx及其以前的iTx执行结果回滚,之前的iTx扣gas,失败的iTx及其之后的iTx不被扣gas。缺点,有失公平
iTx增加参数maxGas,执行时先扣maxGas,执行后将maxGas - gasUsed返还

@imuge
Copy link
Contributor

imuge commented Sep 20, 2019

不是只扣第一个iTx的gas,是所有iTx的gas,这块代码说的是从第一个iTx签名账户扣

func setGasMeter(ctx ctx.Context, tx *txs.TxStd) ctx.Context {

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

2 participants