-
Notifications
You must be signed in to change notification settings - Fork 1
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
CIP-64 / CIP-66 compatible TransactionArgs
#123
Conversation
a314ec1
to
51b4d8e
Compare
dc37292
to
947fc1c
Compare
b11f374
to
9998929
Compare
Co-authored-by: bandu
The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. Just some minor comments.
Will this allow creating CIP-64 txs from the JS console, or does that require additional changes?
feeCurrency() *common.Address | ||
maxFeeInFeeCurrency() *big.Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC @piersy suggested that we can avoid extending TxData by checking the tx type and casting to a specific tx type whenever we want to use a tx-type-specific attribute. I think that can work, but for consistency it should either be done for feeCurrency
too or not at all.
I think going with the current approach is fine for now. I just wanted to bring up the point to see if there are any strong opionions or other thoughs about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally don't like the concept of the TxData interface exposing the union of all struct fields.
If I would contribute to upstream, I would vote to keep the changes of this PR as is for the purpose of consistency though.
When considering minimizing the diff and stronger segregation of Celo specific features for our fork I tend to lean towards the suggestion of @piersy.
So do you suggest implementing this in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, let's keep it as it is. If we want to change it, we should do so in a separate PR.
core/types/transaction.go
Outdated
@@ -628,6 +632,11 @@ func (tx *Transaction) FeeCurrency() *common.Address { | |||
return copyAddressPtr(tx.inner.feeCurrency()) | |||
} | |||
|
|||
// MaxFeeInFeeCurrency returns the max fee in the fee_currency for celo denominated txs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment feels too much like the variable name. We can add some more information here.
Suggestion:
MaxFeeInFeeCurrency is only used to guard against very quickly changing exchange rates. Txs must be discarded if MaxFeeInFeeCurrency is exceeded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in dbb2c57
core/state_transition.go
Outdated
type Message struct { | ||
To *common.Address | ||
From common.Address | ||
Nonce uint64 | ||
Value *big.Int | ||
GasLimit uint64 | ||
GasPrice *big.Int | ||
GasFeeCap *big.Int | ||
GasTipCap *big.Int | ||
To *common.Address | ||
From common.Address | ||
Nonce uint64 | ||
Value *big.Int | ||
GasLimit uint64 | ||
GasPrice *big.Int | ||
GasFeeCap *big.Int | ||
GasTipCap *big.Int | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an unnecessary change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in dbb2c57
@@ -213,7 +213,7 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In | |||
} | |||
// If baseFee provided, set gasPrice to effectiveGasPrice. | |||
if baseFee != nil { | |||
if msg.FeeCurrency != nil { | |||
if tx.Type() == types.CeloDynamicFeeTxType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change safe for the case where tx.Type() == types.CeloDynamicFeeTxType
but msg.FeeCurrency == nil
? Unfortunately, we didn't forbid nil
currencies for CIP-64.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the ConvertGoldToCurrency
function just returns the passed in value in that case (here baseFee
, which has the same effect as omitting the if case).
gasPrice *big.Int | ||
gasFeeCap *big.Int | ||
gasTipCap *big.Int | ||
blobFeeCap *big.Int | ||
maxFeeInFeeCurrency *big.Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a // Celo specific
comment in between will reduce the diff size because it breaks the formatter's alignment into two parts. Not sure if that is overall better in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in dbb2c57
I'm not sure what JS console you mean, but in general, if you add an additional argument However it seems that most client libraries construct their transactions by potentially making individual calls to |
I meant to one you get with |
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
@karlb can we talk about the |
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109 Add CIP-66 transaction type This introduces the CeloDenominatedTx type, which will when implemented allow for the fee-currency to be denominated in cel2 native token. Make the TransactionArgs CIP-64/CIP-66 compatible The TransactionArgs are used in some API endpoints to fill incomplete fields of passed in transactions and then convert this internally to an EVM-message or Transaction. This PR adds code that distinguishes some combination of passed in fields for the TransactionArgs between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not. Additionally, the new MaxFeeInFeeCurrency field is passed along to the internal transaction representations Included commits: * Format comments in TransactionArgs fields * Add CIP-66 tx type (Celo denominated) Co-authored-by: bandu * Fix nil-deref in CIP-66 Transaction getter * Fix required RLP field for fee-currency in CIP66 * Fix initialize MaxFeePerFeeCurrency value upon copy * Convert TransactionArgs to CIP-64/66 transaction Closes #109 * Add MaxFeeInFeeCurrency to EVM Message * Fix CIP-64/66 related sanity checks The fee-currency conversion pre-London (legacy-tx) was unneccessary, since we don't allow celo transactions here. Additionally some sanity-checks regarding Celo related fields were missing * Add tests for CIP-64/66 compatible TransactionArgs * Fix call-arg naming for currency conversion * Fix comments and formatting
Fixes #109
Add CIP-66 transaction type
This introduces the
CeloDenominatedTx
type, which will when implemented allow for the fee-currency to be denominated in cel2 native token.Make the
TransactionArgs
CIP-64/CIP-66 compatibleThe
TransactionArgs
are used in some API endpoints to fill incomplete fields of passed in transactions and thenconvert this internally to an EVM-message or
Transaction
. This PR adds code that distinguishes some combination of passed in fields for theTransactionArgs
between CIP-64 and CIP-66 transactions in order to create the concrete internal transaction type. The filling of missing required fields now considers wether the transaction is Celo-denominated or not.Additionally, the new
MaxFeeInFeeCurrency
field is passed along to the internal transaction representations.