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

[action] enable dynamic fee tx #4393

Merged
merged 4 commits into from
Sep 23, 2024
Merged

[action] enable dynamic fee tx #4393

merged 4 commits into from
Sep 23, 2024

Conversation

dustinxie
Copy link
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #(issue)

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Code refactor or improvement
  • [] Breaking change (fix or feature that would cause a new or changed behavior of existing functionality)
  • [] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [] make test
  • [] fullsync
  • [] Other test (please specify)

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • [] My code follows the style guidelines of this project
  • [] I have performed a self-review of my code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] New and existing unit tests pass locally with my changes
  • [] Any dependent changes have been merged and published in downstream modules

// ======================================
// utility funcs to convert native action to eth tx
// ======================================
func toLegacyEthTx(ab TxCommon, act Action) (*types.Transaction, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

moved to envelope.ToEthTx()

iotextypes.Encoding_ETHEREUM_DYNAMICFEE,
nil,
"0dd507264fcc092c6430c248e48ac525e334e3699852e44451a376c4744e09af",
},
Copy link
Member Author

Choose a reason for hiding this comment

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

test case for access list and dynamic fee tx

GasFeeCap: big.NewInt(1045),
})
_, _, _, err = ExtractTypeSigPubkey(tx)
require.ErrorIs(err, ErrNotSupported)
Copy link
Member Author

Choose a reason for hiding this comment

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

these tx types are supported now, so the test become obsolete

@@ -83,7 +84,8 @@ func (sealed *SealedEnvelope) calcHash() (hash.Hash256, error) {
return hash.ZeroHash256, ErrInvalidAct
}
return act.hash(), nil
case iotextypes.Encoding_ETHEREUM_EIP155, iotextypes.Encoding_ETHEREUM_UNPROTECTED:
case iotextypes.Encoding_ETHEREUM_EIP155, iotextypes.Encoding_ETHEREUM_UNPROTECTED, iotextypes.Encoding_ETHEREUM_ACCESSLIST,
Copy link
Member

Choose a reason for hiding this comment

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

may use Encoding_ETHEREUM_EIP155 to representing tx with eth-format

fallthrough
case encoding == iotextypes.Encoding_ETHEREUM_EIP155 || encoding == iotextypes.Encoding_ETHEREUM_UNPROTECTED:
return toLegacyEthTx(elp.common, elp.Action())
tx, ok := elp.Action().(EthCompatibleAction)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add ToEthTx(to, data) to EthCompatibleAction, and the corresponding types will handle their own conversion logics by calling return tx.ToEthTx(to, data)

Copy link
Member Author

Choose a reason for hiding this comment

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

corresponding types -- do you mean elp.Action() = transfer, execution, staking? or the 4 types of actions elp.common = legacy, accesslist, dynamicfee, blob?
now the data are split into 2 parts:

  1. elp.Action() provides 3 fieldsValue, To, Data
  2. elp.common provides other fields like Nonce, Gas, AccessList, etc

so here the code is getting 3 fields from elp.Action(), and add to elp.common to construct the return tx

@@ -217,58 +218,12 @@ func (elp *envelope) Action() Action { return elp.payload }

// ToEthTx converts to Ethereum tx
func (elp *envelope) ToEthTx(evmNetworkID uint32, encoding iotextypes.Encoding) (*types.Transaction, error) {
tx, ok := elp.Action().(EthCompatibleAction)
act, ok := elp.Action().(EthCompatibleAction)
Copy link
Member Author

Choose a reason for hiding this comment

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

still have putpullresult does not implement this, so for now this check is still needed
can remove this in another PR if we decide to implement EthCompatibleAction for putpullresult

return nil, errors.Wrapf(ErrInvalidAct, "unsupported type = %v", common.Version())
}
return types.NewTx(txdata), nil
return elp.common.toEthTx(act)
Copy link
Collaborator

Choose a reason for hiding this comment

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

        to, err := act.EthTo()
	if err != nil {
		return nil, err
	}
	data, err := act.EthData()
	if err != nil {
		return nil, err
	}
        return elp.common.toEthTx(to, data, act.Value())

Copy link
Member Author

Choose a reason for hiding this comment

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

changed to this

Copy link

sonarcloud bot commented Sep 23, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
7.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@dustinxie dustinxie merged commit f855dce into master Sep 23, 2024
2 of 3 checks passed
@dustinxie dustinxie deleted the enabletx branch September 23, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants