feat: refund a portion of remaining unused tokens to user#3734
feat: refund a portion of remaining unused tokens to user#3734
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThis pull request introduces a refund mechanism for unused tokens during outbound transactions and enhances gas fee handling across the codebase. New changelog entries and documentation files have been added, along with additional OpenAPI properties. Several proto messages now include extra fields (e.g. for tracking user gas fees and stability pool percentages). Updates span test utilities, mocks, and crosschain as well as fungible keeper functions. In the observer module, migration logic is updated to version 11 with corresponding validations and error handling improvements. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant C as CrossChainTx
participant K as Keeper
participant F as FungibleKeeper
participant SP as StabilityPool
U->>C: Initiate outbound transaction
C->>K: Calculate gas fees (UserGasFeePaid)
K->>K: Evaluate remaining unused tokens
alt User eligible for refund
K->>F: RefundRemainingGasFees(ctx, chainID, amount, receiver)
F-->>K: Refund processed
else Refund directed to stability pool
K->>SP: Allocate remaining fees to Stability Pool
SP-->>K: Acknowledge allocation
end
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing touches🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3734 +/- ##
==========================================
+ Coverage 65.08% 65.17% +0.09%
==========================================
Files 451 451
Lines 34042 34141 +99
==========================================
+ Hits 22155 22253 +98
- Misses 10915 10916 +1
Partials 972 972
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (11)
x/crosschain/keeper/initiate_outbound.go (1)
43-45: Clear documentation of gateway behavior distinctions.The comments properly explain the different gateways and their gas fee requirements. This information is crucial for understanding how outbound processing works across different chain types.
Consider adding a period after "connected chains" in the first comment line for consistent formatting.
- // - CCTXGateway_observers : This is the gateway used for all connected chains.The outbound processing involves paying gas fees. + // - CCTXGateway_observers : This is the gateway used for all connected chains. The outbound processing involves paying gas fees.docs/openapi/openapi.swagger.yaml (2)
57816-57818: New Property Addition:userGasFeePaid
The newuserGasFeePaidproperty is well integrated with the existing schema. The type is set as a string and its description accurately reflects its purpose. Please verify that using a string type aligns with any expected future arithmetic operations; if numerical computations are anticipated, a numerical type might be more suitable.
58520-58525: Typographical Correction:stabilityPoolPercentageTitle
The addition of thestabilityPoolPercentageproperty is a solid enhancement. However, there is a minor typographical error in the title text: the phrase “that are are sent to the stability pool” includes an extra “are.” Please correct this redundancy for clarity.x/fungible/keeper/gas_stability_pool.go (3)
61-82: Fix typo in function name.The function name contains a typo:
RefundRemainGasFessshould beRefundRemainingGasFees. This affects code readability and consistency.-// RefundRemainGasFess refunds the remaining gas fees to the receiver -func (k Keeper) RefundRemainGasFess( +// RefundRemainingGasFees refunds the remaining gas fees to the receiver +func (k Keeper) RefundRemainingGasFees(Additionally, ensure this change is synchronized with the interface and mock implementation.
68-72: Add error context to returned error.The function currently returns the raw error without additional context, making it harder to debug issues in production. Consider wrapping the error with additional context.
gasZRC20, err := k.QuerySystemContractGasCoinZRC20(ctx, big.NewInt(chainID)) if err != nil { - return err + return fmt.Errorf("failed to query gas coin ZRC20 for chain %d: %w", chainID, err) }
74-81: Add error context to deposit method call.Similar to the previous comment, the error returned from
CallZRC20Depositshould be wrapped with context for better debugging.// call deposit ZRC20 method - return k.CallZRC20Deposit( + err = k.CallZRC20Deposit( ctx, types.ModuleAddressEVM, gasZRC20, receiver, amount, ) + if err != nil { + return fmt.Errorf("failed to deposit %s gas tokens to %s on chain %d: %w", + amount.String(), receiver.Hex(), chainID, err) + } + return niltestutil/keeper/mocks/crosschain/fungible.go (1)
633-649: Mock implementation for new RefundRemainGasFess method.The mock implementation is correctly added with the appropriate signature. However, it contains the same typo as observed in the original implementation. This should be corrected for consistency.
-// RefundRemainGasFess provides a mock function with given fields: ctx, chainID, amount, receiver -func (_m *CrosschainFungibleKeeper) RefundRemainGasFess(ctx types.Context, chainID int64, amount *big.Int, receiver common.Address) error { +// RefundRemainingGasFees provides a mock function with given fields: ctx, chainID, amount, receiver +func (_m *CrosschainFungibleKeeper) RefundRemainingGasFees(ctx types.Context, chainID int64, amount *big.Int, receiver common.Address) error {Also update the panic message accordingly:
- panic("no return value specified for RefundRemainGasFess") + panic("no return value specified for RefundRemainingGasFees")docs/zetacore/gas_fee.md (1)
1-114: Documentation provides comprehensive gas fee overviewThis new documentation file provides a clear and detailed explanation of gas fee mechanics in ZetaChain. It covers key concepts, protocol flows for both V1 and V2, and specific payment mechanisms for different coin types and transaction scenarios.
I suggest a few improvements to enhance the documentation quality:
- Add code block language specifiers to your code blocks on lines 30, 37, and 41 for better syntax highlighting
- Fix list indentation on lines 45-46 (use 2 spaces instead of 4 for consistency)
- On line 46, replace "amount of tokens" with "number of tokens" since tokens are countable
- ``` - actualFee = receipt.GasUsed * transaction.GasPrice() - ``` + ```go + actualFee = receipt.GasUsed * transaction.GasPrice() + ``` - ``` - totalRemainingFees = userGasFeePaid - actualFee - ``` + ```go + totalRemainingFees = userGasFeePaid - actualFee + ``` - ``` - remainingFees = 95% of totalRemainingFees - ``` + ```go + remainingFees = 95% of totalRemainingFees + ``` - We intentionally use only 95% of the unused fee to avoid any potential over-minting: - - The 5% of tokens that are not minted back are retained by the TSS address - - This creates a safety buffer since we burn the total amount of tokens when initiating the transaction, which creates a deficit + We intentionally use only 95% of the unused fee to avoid any potential over-minting: + - The 5% of tokens that are not minted back are retained by the TSS address + - This creates a safety buffer since we burn the total number of tokens when initiating the transaction, which creates a deficitdocs/zetacore/managment_for_unused_gas_fee.md (1)
1-69: Well-structured documentation with minor formatting issuesThis new document effectively explains the management of unused gas fees, including the refund mechanism and stability pool allocation. The descriptions of fee tracking, calculations, and distributions are clear and comprehensive.
There are a few formatting issues to address:
- Add language specifiers to code blocks on lines 30, 37, and 41
- Fix list indentation on lines 45-46 (should use 2 spaces instead of 4)
- ``` - actualFee = receipt.GasUsed * transaction.GasPrice() - ``` + ```go + actualFee = receipt.GasUsed * transaction.GasPrice() + ``` - ``` - totalRemainingFees = userGasFeePaid - actualFee - ``` + ```go + totalRemainingFees = userGasFeePaid - actualFee + ``` - ``` - remainingFees = 95% of totalRemainingFees - ``` + ```go + remainingFees = 95% of totalRemainingFees + ``` - We intentionally use only 95% of the unused fee to avoid any potential over-minting: - - The 5% of tokens that are not minted back are retained by the TSS address - - This creates a safety buffer since we burn the total amount of tokens when initiating the transaction, which creates a deficit + We intentionally use only 95% of the unused fee to avoid any potential over-minting: + - The 5% of tokens that are not minted back are retained by the TSS address + - This creates a safety buffer since we burn the total amount of tokens when initiating the transaction, which creates a deficit🧰 Tools
🪛 LanguageTool
[uncategorized] ~46-~46: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...a safety buffer since we burn the total amount of tokens when initiating the transacti...(AMOUNTOF_TO_NUMBEROF)
🪛 markdownlint-cli2 (0.17.2)
30-30: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
37-37: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
41-41: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
45-45: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
46-46: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
proto/zetachain/zetacore/observer/params.proto (1)
41-44: Resolve grammatical typo and confirm usage range.The comment contains a repeated word "are are". Additionally, ensure that the
stability_pool_percentagefield highlights whether this value is out of 100 or if larger percentages are permissible, thereby preventing accidental misconfigurations.- // Percentage of unused tokens for outbounds that are are sent to the + // Percentage of unused tokens for outbounds that are sent to thex/crosschain/keeper/msg_server_vote_outbound_tx.go (1)
142-145: Minor grammar nitpick in function comment."Event if the funding fails" should be "Even if the funding fails." Fix grammatical correctness for clarity.
-// This wraps the UseRemainingGasFee function and logs an error if it fails.We do not return an error here. // Event if the funding fails, the outbound tx is still processed. +// This wraps the UseRemainingGasFee function and logs an error if it fails. We do not return an error here. // Even if the funding fails, the outbound tx is still processed.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.tsis excluded by!**/*_pb.d.tstypescript/zetachain/zetacore/observer/params_pb.d.tsis excluded by!**/*_pb.d.tsx/crosschain/types/cross_chain_tx.pb.gois excluded by!**/*.pb.go,!**/*.pb.gox/observer/types/params.pb.gois excluded by!**/*.pb.go,!**/*.pb.go
📒 Files selected for processing (27)
docs/openapi/openapi.swagger.yaml(2 hunks)docs/zetacore/gas_fee.md(1 hunks)docs/zetacore/managment_for_unused_gas_fee.md(1 hunks)proto/zetachain/zetacore/crosschain/cross_chain_tx.proto(1 hunks)proto/zetachain/zetacore/observer/params.proto(1 hunks)testutil/keeper/mocks/crosschain/fungible.go(1 hunks)x/crosschain/keeper/cctx_gateway_observers.go(2 hunks)x/crosschain/keeper/cctx_test.go(3 hunks)x/crosschain/keeper/evm_hooks.go(2 hunks)x/crosschain/keeper/gas_payment.go(7 hunks)x/crosschain/keeper/initiate_outbound.go(1 hunks)x/crosschain/keeper/msg_server_vote_outbound_tx.go(5 hunks)x/crosschain/keeper/msg_server_vote_outbound_tx_test.go(3 hunks)x/crosschain/keeper/v2_zevm_inbound.go(1 hunks)x/crosschain/types/cctx.go(1 hunks)x/crosschain/types/errors.go(1 hunks)x/crosschain/types/expected_keepers.go(1 hunks)x/crosschain/types/inbound_parsing.go(1 hunks)x/crosschain/types/keys.go(1 hunks)x/fungible/keeper/gas_stability_pool.go(2 hunks)x/observer/keeper/migrator.go(2 hunks)x/observer/migrations/v11/migrate.go(1 hunks)x/observer/migrations/v11/migrate_test.go(1 hunks)x/observer/module.go(2 hunks)x/observer/types/chain_params.go(1 hunks)x/observer/types/chain_params_test.go(1 hunks)x/observer/types/errors.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.go`: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
x/crosschain/types/keys.gox/crosschain/types/errors.gox/crosschain/keeper/v2_zevm_inbound.gox/crosschain/keeper/initiate_outbound.gox/crosschain/keeper/evm_hooks.gox/observer/keeper/migrator.gox/crosschain/keeper/cctx_gateway_observers.gox/observer/types/chain_params_test.gox/observer/types/chain_params.gox/observer/migrations/v11/migrate_test.gox/crosschain/types/cctx.gox/observer/types/errors.gox/crosschain/types/inbound_parsing.gotestutil/keeper/mocks/crosschain/fungible.gox/crosschain/types/expected_keepers.gox/observer/module.gox/crosschain/keeper/cctx_test.gox/observer/migrations/v11/migrate.gox/fungible/keeper/gas_stability_pool.gox/crosschain/keeper/msg_server_vote_outbound_tx_test.gox/crosschain/keeper/gas_payment.gox/crosschain/keeper/msg_server_vote_outbound_tx.go
`**/*.proto`: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.
**/*.proto: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.
proto/zetachain/zetacore/crosschain/cross_chain_tx.protoproto/zetachain/zetacore/observer/params.proto
🧬 Code Definitions (11)
x/crosschain/types/errors.go (1)
x/crosschain/types/keys.go (1) (1)
ModuleName(13-13)
x/crosschain/keeper/cctx_gateway_observers.go (3)
testutil/sample/crosschain.go (2) (2)
GasPrice(124-136)InboundParams(170-185)x/crosschain/keeper/gas_price.go (2) (2)
gasPrice(52-52)priorityFee(53-53)x/crosschain/keeper/msg_server_vote_gas_price.go (1) (1)
gasPrice(88-88)
x/observer/types/chain_params.go (1)
x/observer/types/errors.go (1) (1)
ErrParamsStabilityPoolPercentage(79-82)
x/observer/migrations/v11/migrate_test.go (2)
x/observer/migrations/v11/migrate.go (1) (1)
MigrateStore(18-40)x/observer/types/errors.go (2) (2)
ErrChainParamsNotFound(43-43)ErrInvalidChainParams(42-42)
x/observer/types/errors.go (1)
x/observer/types/keys.go (1) (1)
ModuleName(12-12)
x/crosschain/types/inbound_parsing.go (9)
zetaclient/chains/evm/observer/inbound.go (1) (1)
gasLimit(320-320)zetaclient/chains/base/observer.go (1) (1)
gasLimit(390-390)zetaclient/chains/evm/observer/outbound.go (1) (1)
gasLimit(122-122)zetaclient/chains/ton/observer/inbound.go (1) (1)
gasLimit(257-257)zetaclient/chains/ton/observer/outbound.go (1) (1)
gasLimit(253-253)zetaclient/chains/solana/observer/outbound.go (1) (1)
gasLimit(151-151)x/crosschain/types/cmd_cctxs.go (1) (1)
gasLimit(177-177)zetaclient/chains/bitcoin/observer/outbound.go (1) (1)
gasLimit(108-108)zetaclient/chains/bitcoin/observer/event.go (2) (2)
event(53-76)event(80-133)
x/crosschain/types/expected_keepers.go (2)
x/crosschain/keeper/v2_zevm_inbound.go (1) (1)
receiver(33-33)x/crosschain/types/message_vote_inbound_test.go (1) (1)
receiver(486-486)
x/observer/module.go (3)
x/observer/types/keys.go (1) (1)
ModuleName(12-12)x/observer/keeper/migrator.go (1) (1)
m(21-23)x/observer/types/ballot.go (6) (6)
m(10-25)m(27-33)m(36-44)m(49-80)m(82-84)m(96-129)
x/observer/migrations/v11/migrate.go (1)
x/observer/types/errors.go (2) (2)
ErrChainParamsNotFound(43-43)ErrInvalidChainParams(42-42)
x/crosschain/keeper/gas_payment.go (1)
testutil/sample/crosschain.go (1) (1)
GasPrice(124-136)
x/crosschain/keeper/msg_server_vote_outbound_tx.go (4)
x/crosschain/keeper/cctx_orchestrator_validate_outbound.go (7) (7)
k(35-68)k(81-101)k(104-172)k(176-198)k(215-288)k(291-361)k(369-471)x/fungible/keeper/gas_stability_pool.go (5) (5)
k(13-21)k(24-35)k(38-59)k(62-82)k(85-106)x/crosschain/types/keys.go (1) (1)
RemainingFeesToStabilityPoolPercentage(32-32)x/observer/types/errors.go (1) (1)
ErrChainParamsNotFound(43-43)
🪛 LanguageTool
docs/zetacore/managment_for_unused_gas_fee.md
[uncategorized] ~46-~46: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...a safety buffer since we burn the total amount of tokens when initiating the transacti...
(AMOUNTOF_TO_NUMBEROF)
🪛 markdownlint-cli2 (0.17.2)
docs/zetacore/managment_for_unused_gas_fee.md
30-30: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
37-37: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
41-41: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
45-45: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
46-46: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
🔇 Additional comments (39)
x/crosschain/keeper/v2_zevm_inbound.go (1)
127-131: Readability Improvement: Blank Line Insertion
The addition of a blank line before the error check (after callingValidateInbound) enhances the readability by visually separating the assignment from the subsequent error handling block. This change does not affect the logic or control flow of the function.x/crosschain/types/keys.go (1)
32-32: New constant for stability pool percentage looks appropriate.The added constant
RemainingFeesToStabilityPoolPercentagewith value 95% aligns well with the PR objective of refunding unused tokens to users. This indicates that 95% of remaining fees will go to the stability pool, with the remaining 5% being returned to users.Ensure this constant is referenced correctly in the fee management logic elsewhere in the codebase.
proto/zetachain/zetacore/crosschain/cross_chain_tx.proto (1)
127-131: Appropriate addition of user_gas_fee_paid field to OutboundParams.The new field for tracking the original gas fee paid by the user is well-defined with proper annotations. This is a critical component for enabling the refund functionality described in the PR objectives.
Ensure this field is populated correctly in all relevant keeper methods that handle gas fee payments.
x/crosschain/types/errors.go (1)
63-63: Appropriate new error for invalid gas fees.Adding
ErrInvalidGasFeePaidByUserprovides a specific error type for handling cases where the gas fee paid by the user is invalid, following good practice for error management in the codebase.This error will be useful for validating gas fees throughout the transaction lifecycle, which is critical for the refund functionality.
x/observer/types/errors.go (1)
79-82: Well-organized error registration for stability pool validation.The error code 1142 follows sequentially from the previous error code, and the error message clearly describes the constraint being enforced. This addition properly integrates with the existing error handling pattern.
x/crosschain/keeper/evm_hooks.go (2)
214-214: Improved code clarity with gas fee handling explanation.This comment clarifies the gas fee flow for ZRC20Withdrawal events, making the existing behavior more explicit. Since the gas fee is already paid at creation time, this context helps future developers understand the process flow.
298-298: Documented critical payment process distinction.This comment correctly identifies the difference in gas fee handling between events - in this case, the fee hasn't been paid yet and needs to be processed during inbound validation. This documentation is essential for maintaining consistent behavior.
x/observer/types/chain_params_test.go (1)
105-110: Appropriate test case for stability pool percentage validation.This test ensures the validation logic correctly rejects a percentage value over 100, maintaining system integrity. The test uses proper assertions and error checking methodology.
x/observer/types/chain_params.go (1)
150-152: Appropriate validation for percentage boundaryThe validation ensures that
StabilityPoolPercentagedoesn't exceed 100, which is a logical constraint for percentage values. The validation integrates well with the existing validation logic.x/crosschain/keeper/cctx_gateway_observers.go (2)
73-73: Good initialization of gas limit from outbound parametersThe code properly extracts and initializes the gas limit from the current outbound parameters.
78-82: Well-documented gas fee calculationThe code calculates the user's gas fee by multiplying gas limit with gas price and stores it in the outbound parameters. The comments clearly explain that this excludes protocol fees, which is important for stability pool and refund calculations.
x/crosschain/types/cctx.go (1)
193-194: Method name improved to better reflect its functionality.The method rename from
AddOutboundtoUpdateCurrentOutboundprovides greater clarity about what the function actually does. This aligns well with the method's behavior, making the codebase more maintainable.x/observer/keeper/migrator.go (1)
6-7: Import for v11 migrations correctly updated.The import has been properly updated to reference the new v11 migrations package.
x/crosschain/keeper/gas_payment.go (6)
131-132: Good refactoring to improve clarity.Breaking down the gas fee calculation into two distinct steps enhances readability and maintenance while supporting the new requirement to track user gas fees separately.
156-157: Storing user gas fee for potential refunds.This properly captures the gas fee paid by the user in native tokens, enabling the feature to refund unused tokens as indicated in the PR objective.
197-198: Consistent gas fee calculation pattern applied to ERC20 payments.The implementation correctly follows the same pattern established for native tokens, calculating gas fees in a two-step process that clearly separates user gas fees from protocol fees.
318-320: User gas fee tracking for ERC20 tokens.Consistently storing the user-paid portion of gas fees for ERC20 tokens, which aligns with the overall refund mechanism being implemented.
383-384: Improved comment for clarity.The comment clarifies that this calculation is specifically for the gas fee in the outbound chain's gas token, which enhances code readability.
459-461: User gas fee tracking for Zeta token payments.This implementation correctly uses the Zeta amount swapped for gas (outTxGasFeeInZeta) to track the user's paid portion, which differs slightly from the other methods but is appropriate given the token conversion involved.
x/observer/module.go (2)
24-24: Version increment for new migration.Correctly incremented the consensus version as required when introducing a new state migration.
133-133: Updated migration registration.The migration registration has been properly updated to use the new Migrate10to11 function and correct version number. This ensures the new stability pool percentage field will be initialized during the migration.
x/observer/migrations/v11/migrate.go (2)
10-13: Well-defined keeper interface.The interface is appropriately scoped with only the methods required for this migration, following best practices for interface design.
18-39: Well-structured migration function.The migration function follows a clear pattern: get existing data, update it, validate it, and save it back. The error handling is thorough and uses appropriate domain-specific error types.
Setting the stability pool percentage to a fixed value of 60 appears to be a prerequisite for the token refund feature, as it likely determines what portion of unused gas fees can be returned to users.
x/crosschain/keeper/cctx_test.go (3)
310-311: Method name updated for clarity.The method rename from
AddOutboundtoUpdateCurrentOutboundbetter reflects the function's purpose, as it's updating an existing outbound parameter rather than adding a new one.
333-334: Consistent method rename application.The method rename has been consistently applied throughout the test cases, maintaining the same functionality while improving naming clarity.
356-357: Consistent test coverage for edge cases.The error case test has been properly updated with the new method name while maintaining the same validation logic, ensuring comprehensive test coverage for the refactored code.
x/observer/migrations/v11/migrate_test.go (1)
72-99: Test case validation contains a strong approachThe third test case provides an excellent example of testing validation failures by intentionally setting an invalid value. This approach ensures the migration's validation logic works correctly.
x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (1)
25-85: Well-structured TestPercentOf test casesThe
TestPercentOftest function is well-implemented with comprehensive test cases covering various scenarios including zero percent, specific percentage, rounding, and handling large percentages. This provides good test coverage for the percentage calculation functionality.proto/zetachain/zetacore/observer/params.proto (2)
51-52: No functional changes.This closing brace and whitespace adjust a deprecated message. No concerns here.
53-84: Approved introduction of a legacy params message.Declaring
LegacyChainParamsfor migration/compatibility is helpful, with clear deprecation labeling. Good job preserving older fields to prevent data loss.x/crosschain/keeper/msg_server_vote_outbound_tx.go (9)
11-12: New imports identified.These imports are necessary for working with Ethereum addresses and error wrapping. No issues found.
18-18: Observer types import alias.This import improves clarity. Looks good.
118-118: Rename from AddOutbound to UpdateCurrentOutbound.Using
UpdateCurrentOutboundclarifies the operation's purpose. Good improvement.
125-125: Call to ManageUnusedGasFee.Introducing a single function to handle leftover fees is clean and improves code organization.
128-128: Outbound observers validation kept intact.No issues with this call—logic remains consistent with the updated flow.
146-165: Error handling decision is acceptable.Swallowing the error (logging only) ensures outbound flow is not blocked by partial funding failures. This design choice is defensible, though consider revisiting if reliability becomes an issue.
167-229: Sufficient logic for leftover fee management.The step-by-step usage of remaining gas fees—funding the pool and optionally refunding users—is correctly laid out. Error handling for missing
chainParamsis appropriate.
249-255: Refactor to new PercentOf function.Switching to
PercentOf(remainingFees, ...)increases readability. Implementation is consistent.
266-279: PercentOf utility method is straightforward and clear.Good approach for scaling numerical values by a uint64 percentage without floating-point operations.
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (2)
x/crosschain/types/expected_keepers.go (1)
219-219:⚠️ Potential issueMethod name has a typo: 'Fess' should be 'Fees'
The method name
RefundRemainGasFesscontains a typo - it should beRefundRemainGasFees. This is a public interface method, so this typo will propagate to all implementations.- RefundRemainGasFess(ctx sdk.Context, chainID int64, amount *big.Int, receiver ethcommon.Address) error + RefundRemainGasFees(ctx sdk.Context, chainID int64, amount *big.Int, receiver ethcommon.Address) errorx/observer/migrations/v11/migrate_test.go (1)
61-61:⚠️ Potential issueCritical error: Using v10.MigrateStore instead of v11.MigrateStore.
The test is calling the wrong migration function in the second and third test cases, which invalidates the test results.
Apply this diff to fix the issue:
- err := v10.MigrateStore(ctx, *k) + err := v11.MigrateStore(ctx, *k)on both line 61 and line 89.
Also applies to: 89-89
🧹 Nitpick comments (15)
x/crosschain/types/keys.go (1)
32-32: Add documentation for the new constant.The constant
UsableRemainingFeesPercentageis a crucial parameter for the gas fee refund mechanism, but lacks documentation on its purpose and implications.Consider adding a comment that explains:
- What this percentage represents
- How it's used in the refund calculation process
- Why 95% was chosen as the value
+// UsableRemainingFeesPercentage defines the percentage of remaining gas fees that can be +// refunded to users. The remaining 5% is kept in the stability pool to ensure system solvency. UsableRemainingFeesPercentage = uint64(95)x/observer/types/chain_params.go (1)
150-152: Validation logic for stability pool percentage.The implementation properly validates that the stability pool percentage does not exceed 100%, which is appropriate for a percentage value. The error message is specific and descriptive.
Consider adding a lower bound check if negative percentages should be invalid. If zero is a valid value (e.g., to disable stability pool contributions), then the current implementation is sufficient.
if cp.StabilityPoolPercentage > 100 { return ErrParamsStabilityPoolPercentage } +// Optional: Add validation for negative values if needed +// if cp.StabilityPoolPercentage < 0 { +// return ErrParamsNegativeStabilityPoolPercentage +// }docs/openapi/openapi.swagger.yaml (1)
58520-58525: Schema Update: Addition ofstabilityPoolPercentageField
The propertystabilityPoolPercentageis introduced with astringtype and auint64format to represent the percentage of unused tokens transferred to the stability pool. There is a minor typographical error in the title description ("are are") which should be corrected for clarity. Additionally, please ensure that the type choice is consistent with the corresponding proto field (stability_pool_percentage) and the intended numerical representation.proto/zetachain/zetacore/observer/params.proto (1)
41-44:Details
❓ Verification inconclusive
New field added for stability pool percentage
The new
stability_pool_percentagefield is properly defined with appropriate documentation. This field will track the percentage of unused tokens for outbound transactions that are directed to the stability pool.A few considerations:
- Ensure that any code working with this field validates that the percentage is within an expected range (0-100).
- Update any existing code that processes chain parameters to handle this new field.
🏁 Script executed:
#!/bin/bash # Check if there's code that validates the percentage range (0-100) rg -A 5 -B 5 "stability_pool_percentage" --type goLength of output: 50
Action Required: Verify Range Validation for New Field
The new
stability_pool_percentagefield is correctly added and documented in the protobuf file. However, our initial search did not reveal any code enforcing that the percentage remains within the expected range (0–100). Please ensure that:
- Any logic processing the chain parameters includes proper validation for this field.
- All sections of the code that read or manipulate chain parameters are updated to handle the new field.
Since automated verification did not return definitive results, a manual review of the parameter handling code is recommended.
docs/zetacore/managment_for_unused_gas_fee.md (4)
1-1: Filename contains a spelling error.The filename "managment_for_unused_gas_fee.md" is missing an 'e' and should be "management_for_unused_gas_fee.md".
30-32: Add language specifiers to code blocks.For better syntax highlighting and documentation consistency, add language specifiers to all code blocks.
- ``` + ```go actualFee = receipt.GasUsed * transaction.GasPrice()
totalRemainingFees = userGasFeePaid - actualFee
remainingFees = 95% of totalRemainingFeesAlso applies to: 37-39, 41-43 <details> <summary>🧰 Tools</summary> <details> <summary>🪛 markdownlint-cli2 (0.17.2)</summary> 30-30: Fenced code blocks should have a language specified null (MD040, fenced-code-language) </details> </details> --- `45-47`: **Fix list indentation and grammar.** The unordered list items are using incorrect indentation, and there's a grammar issue in the description. ```diff - - The 5% of tokens that are not minted back are retained by the TSS address - - This creates a safety buffer since we burn the total amount of tokens when initiating the transaction, which creates a deficit + - The 5% of tokens that are not minted back are retained by the TSS address + - This creates a safety buffer since we burn the total number of tokens when initiating the transaction, which creates a deficit🧰 Tools
🪛 LanguageTool
[uncategorized] ~46-~46: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...a safety buffer since we burn the total amount of tokens when initiating the transacti...(AMOUNTOF_TO_NUMBEROF)
🪛 markdownlint-cli2 (0.17.2)
45-45: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
46-46: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
52-58: Add percentages to stability pool allocation for clarity.The documentation mentions a "configurable percentage" going to the stability pool, but doesn't specify the default value. Since the migration sets this to 60%, it would be helpful to add this information to the documentation.
1. **Stability Pool Allocation** - For non-zEVM chains or invalid addresses: 100% of this amount goes to the stability pool - - For zEVM chains with valid addresses: A configurable percentage (from chain parameters) goes to the stability pool + - For zEVM chains with valid addresses: A configurable percentage (from chain parameters, default 60%) goes to the stability pool 2. **User Refund** - - For zEVM chains with valid addresses: The remaining amount after stability pool allocation is refunded to the user + - For zEVM chains with valid addresses: The remaining amount (40% by default) after stability pool allocation is refunded to the user - Refunds are provided as ZRC20 gas tokens of the connected chainx/observer/migrations/v11/migrate.go (2)
24-28: Incorrect comment regarding field value assignment.The comment states that new fields are being set to the same value as 'confirmation_count', but the code is actually setting a hard-coded value of 60.
- // set new fields to the same value as 'confirmation_count' + // set the StabilityPoolPercentage field to 60% for all chain parameters
25-29: Consider making the stability pool percentage configurable.The current implementation sets a hard-coded value of 60 for the stability pool percentage. Consider making this configurable through a migration parameter or extracting it as a constant at the package level for better maintainability.
+// DefaultStabilityPoolPercentage is the default percentage of unused gas fees allocated to the stability pool +const DefaultStabilityPoolPercentage = 60 func MigrateStore(ctx sdk.Context, observerKeeper observerKeeper) error { // ... for _, chainParams := range allChainParams.ChainParams { if chainParams != nil { - chainParams.StabilityPoolPercentage = 60 + chainParams.StabilityPoolPercentage = DefaultStabilityPoolPercentage } } // ... }docs/zetacore/gas_fee.md (2)
24-27: Clarify the revert treatment for "Call" transactions
It might be beneficial to explicitly outline what happens if an error occurs during a "Call" transaction, given that revert is marked as "Not supported" in the table.
50-53: Include examples for each withdrawal type
Adding concrete illustrations or sample flows for each withdrawal scenario (e.g., how gas fees are actually calculated in a test or mainnet environment) can help new developers quickly grasp the process.x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (2)
25-85: Add boundary test scenario for 100%
While the current tests cover 0%, 40%, and 200%, consider adding a test for an exact 100% case to solidify boundary coverage.
188-421: Add test coverage for exact fee match
Consider including a test scenario whereuserGasFeePaidexactly equalsoutboundTxFeePaidto ensure all leftover computation paths are tested.x/crosschain/keeper/msg_server_vote_outbound_tx.go (1)
266-280: Reassess export scope forPercentOf
Since this function is exported, confirm it is intentionally exposed outside the package. Otherwise, consider renaming it to clarify its intended scope.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.tsis excluded by!**/*_pb.d.tstypescript/zetachain/zetacore/observer/params_pb.d.tsis excluded by!**/*_pb.d.tsx/crosschain/types/cross_chain_tx.pb.gois excluded by!**/*.pb.go,!**/*.pb.gox/observer/types/params.pb.gois excluded by!**/*.pb.go,!**/*.pb.go
📒 Files selected for processing (27)
docs/openapi/openapi.swagger.yaml(2 hunks)docs/zetacore/gas_fee.md(1 hunks)docs/zetacore/managment_for_unused_gas_fee.md(1 hunks)proto/zetachain/zetacore/crosschain/cross_chain_tx.proto(1 hunks)proto/zetachain/zetacore/observer/params.proto(1 hunks)testutil/keeper/mocks/crosschain/fungible.go(1 hunks)x/crosschain/keeper/cctx_gateway_observers.go(2 hunks)x/crosschain/keeper/cctx_test.go(3 hunks)x/crosschain/keeper/evm_hooks.go(2 hunks)x/crosschain/keeper/gas_payment.go(7 hunks)x/crosschain/keeper/initiate_outbound.go(1 hunks)x/crosschain/keeper/msg_server_vote_outbound_tx.go(5 hunks)x/crosschain/keeper/msg_server_vote_outbound_tx_test.go(3 hunks)x/crosschain/keeper/v2_zevm_inbound.go(1 hunks)x/crosschain/types/cctx.go(1 hunks)x/crosschain/types/errors.go(1 hunks)x/crosschain/types/expected_keepers.go(1 hunks)x/crosschain/types/inbound_parsing.go(1 hunks)x/crosschain/types/keys.go(1 hunks)x/fungible/keeper/gas_stability_pool.go(2 hunks)x/observer/keeper/migrator.go(2 hunks)x/observer/migrations/v11/migrate.go(1 hunks)x/observer/migrations/v11/migrate_test.go(1 hunks)x/observer/module.go(2 hunks)x/observer/types/chain_params.go(1 hunks)x/observer/types/chain_params_test.go(1 hunks)x/observer/types/errors.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.go`: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
x/crosschain/types/keys.gox/observer/types/errors.gox/crosschain/keeper/v2_zevm_inbound.gox/crosschain/types/errors.gox/crosschain/keeper/evm_hooks.gox/crosschain/types/inbound_parsing.gox/crosschain/keeper/gas_payment.gox/crosschain/keeper/cctx_gateway_observers.gox/crosschain/keeper/initiate_outbound.gox/crosschain/types/cctx.gox/observer/module.gox/observer/migrations/v11/migrate_test.gox/crosschain/types/expected_keepers.gox/observer/types/chain_params.gotestutil/keeper/mocks/crosschain/fungible.gox/fungible/keeper/gas_stability_pool.gox/observer/migrations/v11/migrate.gox/observer/keeper/migrator.gox/crosschain/keeper/cctx_test.gox/crosschain/keeper/msg_server_vote_outbound_tx.gox/observer/types/chain_params_test.gox/crosschain/keeper/msg_server_vote_outbound_tx_test.go
`**/*.proto`: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.
**/*.proto: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.
proto/zetachain/zetacore/crosschain/cross_chain_tx.protoproto/zetachain/zetacore/observer/params.proto
🧬 Code Definitions (10)
x/observer/types/errors.go (1)
x/observer/types/keys.go (1) (1)
ModuleName(12-12)
x/crosschain/types/errors.go (1)
x/crosschain/types/keys.go (1) (1)
ModuleName(13-13)
x/crosschain/types/inbound_parsing.go (3)
zetaclient/chains/evm/observer/inbound.go (1) (1)
gasLimit(320-320)x/crosschain/types/cmd_cctxs.go (1) (1)
gasLimit(177-177)zetaclient/chains/bitcoin/observer/event.go (2) (2)
event(53-76)event(80-133)
x/crosschain/keeper/gas_payment.go (1)
testutil/sample/crosschain.go (1) (1)
GasPrice(124-136)
x/crosschain/keeper/cctx_gateway_observers.go (5)
zetaclient/zetacore/client_vote.go (1) (1)
gasLimit(93-93)testutil/sample/crosschain.go (2) (2)
GasPrice(124-136)InboundParams(170-185)zetaclient/chains/evm/observer/observer_gas_test.go (2) (2)
gasPrice(35-35)gasPrice(72-72)x/crosschain/keeper/gas_price.go (2) (2)
gasPrice(52-52)priorityFee(53-53)x/crosschain/keeper/msg_server_vote_gas_price.go (1) (1)
gasPrice(88-88)
x/observer/module.go (3)
x/observer/types/keys.go (1) (1)
ModuleName(12-12)x/observer/keeper/migrator.go (1) (1)
m(21-23)x/observer/types/ballot.go (6) (6)
m(10-25)m(27-33)m(36-44)m(49-80)m(82-84)m(96-129)
x/observer/migrations/v11/migrate_test.go (2)
x/observer/migrations/v11/migrate.go (1) (1)
MigrateStore(18-40)x/observer/types/errors.go (2) (2)
ErrChainParamsNotFound(43-43)ErrInvalidChainParams(42-42)
x/observer/types/chain_params.go (1)
x/observer/types/errors.go (1) (1)
ErrParamsStabilityPoolPercentage(79-82)
x/fungible/keeper/gas_stability_pool.go (1)
x/crosschain/keeper/gas_payment.go (5) (5)
k(36-55)k(59-96)k(100-159)k(165-322)k(329-463)
x/crosschain/keeper/msg_server_vote_outbound_tx.go (4)
x/crosschain/keeper/cctx_orchestrator_validate_outbound.go (7) (7)
k(35-68)k(81-101)k(104-172)k(176-198)k(215-288)k(291-361)k(369-471)x/fungible/keeper/gas_stability_pool.go (5) (5)
k(13-21)k(24-35)k(38-59)k(62-82)k(85-106)x/crosschain/types/keys.go (1) (1)
UsableRemainingFeesPercentage(32-32)x/observer/types/errors.go (1) (1)
ErrChainParamsNotFound(43-43)
🪛 LanguageTool
docs/zetacore/managment_for_unused_gas_fee.md
[uncategorized] ~46-~46: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...a safety buffer since we burn the total amount of tokens when initiating the transacti...
(AMOUNTOF_TO_NUMBEROF)
🪛 markdownlint-cli2 (0.17.2)
docs/zetacore/managment_for_unused_gas_fee.md
30-30: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
37-37: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
41-41: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
45-45: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
46-46: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
🔇 Additional comments (36)
x/crosschain/keeper/v2_zevm_inbound.go (1)
128-128: Code formatting improvement approved.The addition of this whitespace improves readability by clearly separating the validation logic from the error handling section, which follows best practices for Go code organization.
x/crosschain/types/inbound_parsing.go (2)
225-226: Implement error handling for missing gas fees instead of leaving a TODO.This TODO comment correctly identifies a potential issue - proceeding when the user hasn't paid gas fees might lead to unexpected behavior. Since the purpose of this PR is to refund unused gas fees, robust validation of user-provided gas fees is essential.
I recommend implementing this error check now rather than deferring it. Consider using the new
ErrInvalidGasFeePaidByUsererror that was added in this PR.
227-230: Fix inconsistency in gas limit handling compared to other functions.The implementation in
NewWithdrawAndCallInbounddiffers from the pattern used inNewWithdrawalInboundandNewCallInbound. In those functions,gasLimitis assigned theUint64()value ofgasLimitQueried, but here we're directly assigninggasLimitQueriedtoevent.CallOptions.GasLimit.This inconsistency may cause issues since:
- We're still using
gasLimiton line 243 which hasn't been updated with the new value- The value is stored differently (as a big.Int vs uint64)
Recommend one of these approaches:
// Option 1: Maintain consistency with other functions if gasLimit == 0 { - event.CallOptions.GasLimit = gasLimitQueried + gasLimit = gasLimitQueried.Uint64() } // Option 2: Update both values if direct assignment is intended if gasLimit == 0 { event.CallOptions.GasLimit = gasLimitQueried + gasLimit = gasLimitQueried.Uint64() }x/observer/types/errors.go (1)
79-82: Well-structured error registration.The new error variable
ErrParamsStabilityPoolPercentageis correctly registered with a proper error code (1142) and a clear error message that enforces the logical constraint that a percentage cannot exceed 100. This addition follows the existing error registration pattern in the file.x/crosschain/keeper/initiate_outbound.go (1)
43-45: Clear documentation for gateway types.The added comments effectively document the two supported gateway types and their distinct behavior regarding gas fees. This information is essential for understanding the gas fee management flow in the system, particularly in the context of the new gas fee refund feature.
proto/zetachain/zetacore/crosschain/cross_chain_tx.proto (1)
127-131: Appropriate field addition for tracking user gas fees.The new
user_gas_fee_paidfield is correctly implemented with the proper type (cosmossdk.io/math.Uint) and necessary options. This field is essential for the gas fee refund feature as it tracks the original amount paid by users, enabling accurate calculation of refundable unused gas.x/crosschain/keeper/evm_hooks.go (2)
214-214: Informative comment about gas fee handling.This comment clarifies that for ZRC20 withdrawals, gas fees are already paid during event creation, which is important context for implementing the gas fee refund logic correctly.
298-298: Clarification of gas fee payment timing.This comment contrasts with the previous one by explaining that for Zeta sent events, gas fees are not yet paid and need to be processed during inbound validation. This distinction is critical for proper implementation of gas fee management across different transaction types.
x/crosschain/keeper/cctx_gateway_observers.go (2)
6-6: Appropriate SDK math import added.The addition of the
sdkmathpackage is necessary for the new gas fee calculation implemented in this PR.
73-83: Well-implemented gas fee calculation logic.The implementation correctly:
- Converts the gas limit to a
sdkmath.Uinttype- Calculates the total gas fee paid by multiplying gas limit with gas price
- Stores this value in the outbound parameters for later use
The added comments clearly explain that this calculation excludes protocol fees, which is an important distinction for stability pool and refund calculations.
x/observer/types/chain_params_test.go (1)
105-110: Good test coverage for new validation constraint.This test case properly verifies that the stability pool percentage cannot exceed 100%, which is a logical constraint for a percentage value. The test follows the established pattern in the file and correctly asserts that the specific error is returned when validation fails.
docs/openapi/openapi.swagger.yaml (1)
57816-57818: Schema Update: Addition ofuserGasFeePaidField
The new propertyuserGasFeePaidhas been added to track the original gas fee paid by the user. The field is defined as astring, which may be a deliberate design choice to handle large or highly precise numeric values. Please verify that this data type aligns with the corresponding proto field (user_gas_fee_paid) and overall API data model requirements.x/observer/keeper/migrator.go (2)
6-6: Updated import for v11 migrationsThe import statement has been updated to use the v11 migrations package. This aligns with the new migration function added below.
21-23:Details
❓ Verification inconclusive
New migration function added for v10 to v11
The new migration function is implemented correctly and follows the established pattern for migrations. According to the AI summary, this migration is expected to update the
StabilityPoolPercentagefield of all chain parameters to a fixed value of 60.Ensure corresponding tests are added for this migration function.
🏁 Script executed:
#!/bin/bash # Check if there are tests for the v11 migration rg -A 5 "TestMigrate10to11" --type goLength of output: 37
Manual Verification Needed for Migration Test Coverage
The migration function implementation in
x/observer/keeper/migrator.go(lines 21-23) correctly follows the established pattern for migrations. However, an automated search for test cases labeled"TestMigrate10to11"did not return any results. Please manually verify that appropriate tests—specifically one that confirms theStabilityPoolPercentagefield is set to a fixed value of 60—have been added. If such tests are missing, kindly add them to ensure complete coverage of the migration logic.x/crosschain/keeper/gas_payment.go (6)
131-132: Improved gas fee calculation clarityThe changes separate the gas fee calculation from the total outbound transaction gas fee by:
- First calculating the
gasFeeas the product of gas limit and gas price- Then computing the total
outTxGasFeeby adding the protocol flat feeThis separation improves code clarity and makes the relationship between these values more explicit.
155-157: Added tracking of original user gas fee paidThe code now tracks the original gas fee paid by the user separately from the total transaction fee (which includes protocol flat fee). This allows for potential refunds of unused gas to be calculated more accurately.
This addition aligns with the PR objective of refunding a portion of remaining unused tokens to the user.
197-198: Consistent gas fee calculation implementationThe same pattern of calculating
gasFeeandoutTxGasFeeis consistently implemented in thePayGasInERC20AndUpdateCctxmethod, which helps maintain code consistency across different payment methods.
318-320: Consistent tracking of user gas fee across payment methodsThe code consistently sets the
UserGasFeePaidfield with the appropriate value in the ERC20 payment flow, matching the pattern established in the previous method.
383-384: Clear comment about gas fee calculationThe added comment clarifies that this variable represents the gas fee in the outbound chain's gas token, which improves code readability and understanding.
459-461: Appropriate tracking of user gas fee for ZETA paymentsFor ZETA payments, the code correctly sets the
UserGasFeePaidto the ZETA amount that was swapped for gas ZRC20 and burned. This completes the implementation of user gas fee tracking across all payment methods.The clear comment explains the flow of funds, which enhances code maintainability.
x/crosschain/types/cctx.go (1)
193-194: Function name change provides better semantic clarity.The renaming from
AddOutboundtoUpdateCurrentOutboundmore accurately represents the function's purpose, as it updates the existing outbound transaction parameters rather than adding a new outbound transaction. This change improves code readability and maintains better alignment with the function's behavior.x/fungible/keeper/gas_stability_pool.go (1)
7-7: Clean import addition.Adding the Ethereum common address import for the refund functionality.
x/crosschain/keeper/cctx_test.go (3)
310-310: Test updated to use new function name.Test correctly updated to call
UpdateCurrentOutboundinstead ofAddOutboundto reflect the renamed function.
333-333: Test updated for failed ballot scenario.Test for failed ballot scenario correctly updated to use the new function name.
356-356: Error case test properly updated.Test that verifies the error condition when the amount doesn't match the value received has been correctly updated to use the new function name.
x/observer/module.go (2)
24-24: Consensus version updated appropriately.The consensus version increment from 10 to 11 aligns with the introduction of the new stability pool percentage feature. This ensures proper state migration handling.
133-133: Migration registration properly configured.The migration registration correctly references the new
Migrate10to11function and specifies version 10 as the source version. This ensures the proper migration path from version 10 to 11.docs/zetacore/managment_for_unused_gas_fee.md (1)
44-47: Clarify the fate of the 5% safety buffer.The documentation mentions that 5% of tokens are not minted back and retained by the TSS address, but it's not clear what happens to them afterward. Consider adding a brief explanation about whether these tokens are permanently removed from circulation, pooled for other purposes, or handled in some other way.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~46-~46: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...a safety buffer since we burn the total amount of tokens when initiating the transacti...(AMOUNTOF_TO_NUMBEROF)
🪛 markdownlint-cli2 (0.17.2)
45-45: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
46-46: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
x/observer/migrations/v11/migrate.go (2)
10-13: Interface definition appears appropriate.The
observerKeeperinterface is correctly defined with the necessary methods to retrieve and update chain parameters.
18-40: Migration function implementation is solid.The migration function correctly retrieves chain parameters, updates them, validates the updated parameters, and stores them back. The error handling is appropriate, using
errorsmod.Wrapto add context to the errors.x/observer/migrations/v11/migrate_test.go (3)
14-49: First test case looks good.The first test case correctly verifies that the migration updates the
StabilityPoolPercentagefield to 60 while preserving all other fields. The test structure with arrange, act, assert sections is clear and effective.
51-70: Error handling test case structure is good (but needs function fix).The test structure for the "chain params not found" scenario is well-designed, but it's using the wrong migration function as noted in the critical error above.
72-98: Validation failure test case structure is good (but needs function fix).The test structure for the "validation failure" scenario is well-designed, but it's using the wrong migration function as noted in the critical error above.
x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (1)
423-491: Well-structured table-driven tests
These table-driven tests are well-organized and straightforward.x/crosschain/keeper/msg_server_vote_outbound_tx.go (2)
118-122: Verify the newUpdateCurrentOutboundlogic
Confirm that fields such asUserGasFeePaidremain synchronized when updating the outbound parameters.Please ensure that all references to this updated logic have been validated across the codebase.
167-229: Inspect partial fee coverage edge case
If user fees only partially cover the actual gas used, confirm that leftover calculations accurately reflect the final distribution between the pool and the refund.Please verify the logic does not inadvertently short-credit or double-credit the user.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (7)
x/crosschain/types/keys.go (1)
32-32: New constant for unused fee refundsThe introduction of
UsableRemainingFeesPercentageis appropriate for the refund functionality being implemented. The value (95%) provides a reasonable balance, allowing users to receive most of their unused tokens while maintaining a small buffer.Consider adding a brief comment explaining the purpose of this constant to improve code readability and maintainability.
-UsableRemainingFeesPercentage = uint64(95) +// UsableRemainingFeesPercentage defines the percentage of remaining fees that can be refunded to the user +UsableRemainingFeesPercentage = uint64(95)changelog.md (1)
16-16: Clear changelog entry for the new featureThe changelog entry appropriately describes the feature being implemented - refunding unused tokens back to users upon outbound transaction finalization.
For enhanced clarity, consider a slight grammatical improvement:
-* [3734](https://github.com/zeta-chain/node/pull/3734) - refund a portion of remaining unused tokens to user when a outbound is finalized +* [3734](https://github.com/zeta-chain/node/pull/3734) - refund a portion of remaining unused tokens to user when an outbound is finalizedx/observer/migrations/v11/migrate.go (1)
27-27: Consider parameterizing the stability pool percentage valueThe implementation sets a hardcoded value of 60 for the
StabilityPoolPercentagefield across all chain parameters during migration.While this approach works for migration, consider whether this value should be configurable or exposed through module parameters, rather than hardcoded, to allow for more flexibility in the future.
- chainParams.StabilityPoolPercentage = 60 + chainParams.StabilityPoolPercentage = params.DefaultStabilityPoolPercentageThis would require defining a constant or default value in the params package.
proto/zetachain/zetacore/observer/params.proto (1)
41-44: Appropriate field addition for stability pool percentage.The addition of the
stability_pool_percentagefield to theChainParamsmessage is well-structured and appropriately documented. This field will enable the protocol to define what percentage of unused tokens from outbound transactions should be directed to the stability pool.However, consider adding a comment specifying the expected range (0-100) of this percentage value to improve self-documentation.
docs/openapi/openapi.swagger.yaml (1)
58520-58525: RefinestabilityPoolPercentageField DocumentationThe introduction of the
stabilityPoolPercentagefield—with typestring, formatuint64, and a descriptive title—enhances the clarity around unused token allocation to the stability pool. However, please remove the duplicated word ("are are") in the title to improve grammatical clarity. A suggested diff is as follows:- title: |- - Percentage of unused tokens for outbounds that are are sent to the - stability pool + title: |- + Percentage of unused tokens for outbounds that are sent to the + stability pooldocs/zetacore/gas_fee.md (1)
1-114: Well-Written and Comprehensive DocumentationThe newly added documentation provides clear guidance on gas fee mechanics under both V1 and V2 protocols, including deposit and withdrawal flows. The tables and bullet points are well-organized. For completeness, consider adding a brief real-world transaction example illustrating the calculation or a visual flow diagram to further enhance clarity.
x/observer/migrations/v11/migrate_test.go (1)
1-98: Tests Thoroughly Cover Migration ScenariosThe test suite diligently checks valid migrations, missing
ChainParams, and invalidChainParams. Test coverage is commendable. As a final nitpick, you could also add a corner case test whereStabilityPoolPercentageis already 60 to confirm idempotency.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.tsis excluded by!**/*_pb.d.tstypescript/zetachain/zetacore/observer/params_pb.d.tsis excluded by!**/*_pb.d.tsx/crosschain/types/cross_chain_tx.pb.gois excluded by!**/*.pb.go,!**/*.pb.gox/observer/types/params.pb.gois excluded by!**/*.pb.go,!**/*.pb.go
📒 Files selected for processing (29)
changelog.md(1 hunks)docs/openapi/openapi.swagger.yaml(2 hunks)docs/zetacore/gas_fee.md(1 hunks)docs/zetacore/managment_for_unused_gas_fee.md(1 hunks)proto/zetachain/zetacore/crosschain/cross_chain_tx.proto(1 hunks)proto/zetachain/zetacore/observer/params.proto(1 hunks)testutil/keeper/mocks/crosschain/fungible.go(1 hunks)x/crosschain/keeper/cctx_gateway_observers.go(2 hunks)x/crosschain/keeper/cctx_test.go(3 hunks)x/crosschain/keeper/evm_hooks.go(2 hunks)x/crosschain/keeper/gas_payment.go(7 hunks)x/crosschain/keeper/initiate_outbound.go(1 hunks)x/crosschain/keeper/msg_server_vote_outbound_tx.go(5 hunks)x/crosschain/keeper/msg_server_vote_outbound_tx_test.go(3 hunks)x/crosschain/keeper/v2_zevm_inbound.go(1 hunks)x/crosschain/types/cctx.go(1 hunks)x/crosschain/types/expected_keepers.go(1 hunks)x/crosschain/types/inbound_parsing.go(1 hunks)x/crosschain/types/keys.go(1 hunks)x/fungible/keeper/refund_gas_fee.go(1 hunks)x/fungible/keeper/refund_gas_fee_test.go(1 hunks)x/observer/keeper/migrator.go(2 hunks)x/observer/migrations/v10/migrate_test.go(0 hunks)x/observer/migrations/v11/migrate.go(3 hunks)x/observer/migrations/v11/migrate_test.go(1 hunks)x/observer/module.go(2 hunks)x/observer/types/chain_params.go(1 hunks)x/observer/types/chain_params_test.go(1 hunks)x/observer/types/errors.go(1 hunks)
💤 Files with no reviewable changes (1)
- x/observer/migrations/v10/migrate_test.go
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.go`: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
x/crosschain/keeper/v2_zevm_inbound.gox/crosschain/types/keys.gox/observer/module.gox/crosschain/keeper/cctx_gateway_observers.gox/observer/migrations/v11/migrate.gox/crosschain/keeper/evm_hooks.gox/observer/types/errors.gox/crosschain/types/expected_keepers.gox/crosschain/types/cctx.gox/observer/types/chain_params_test.gox/observer/types/chain_params.gox/fungible/keeper/refund_gas_fee_test.gox/observer/keeper/migrator.gotestutil/keeper/mocks/crosschain/fungible.gox/crosschain/keeper/gas_payment.gox/crosschain/types/inbound_parsing.gox/crosschain/keeper/initiate_outbound.gox/crosschain/keeper/msg_server_vote_outbound_tx_test.gox/crosschain/keeper/cctx_test.gox/fungible/keeper/refund_gas_fee.gox/observer/migrations/v11/migrate_test.gox/crosschain/keeper/msg_server_vote_outbound_tx.go
`**/*.proto`: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.
**/*.proto: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.
proto/zetachain/zetacore/crosschain/cross_chain_tx.protoproto/zetachain/zetacore/observer/params.proto
🧬 Code Definitions (10)
x/observer/module.go (3)
x/observer/types/keys.go (1) (1)
ModuleName(12-12)x/observer/keeper/migrator.go (1) (1)
m(22-24)x/observer/types/ballot.go (6) (6)
m(10-25)m(27-33)m(36-44)m(49-80)m(82-84)m(96-129)
x/crosschain/keeper/cctx_gateway_observers.go (5)
zetaclient/zetacore/client_vote.go (1) (1)
gasLimit(93-93)testutil/sample/crosschain.go (2) (2)
GasPrice(124-136)InboundParams(176-191)zetaclient/chains/evm/observer/observer_gas_test.go (2) (2)
gasPrice(35-35)gasPrice(72-72)x/crosschain/keeper/gas_price.go (2) (2)
gasPrice(52-52)priorityFee(53-53)x/crosschain/keeper/msg_server_vote_gas_price.go (1) (1)
gasPrice(88-88)
x/observer/types/errors.go (1)
x/observer/types/keys.go (1) (1)
ModuleName(12-12)
x/crosschain/types/cctx.go (3)
x/crosschain/types/status.go (5) (5)
m(15-18)m(20-23)m(26-37)m(40-53)m(55-63)x/crosschain/types/outbound_params.go (3) (3)
m(10-17)m(19-31)m(33-62)testutil/sample/crosschain.go (1) (1)
CrossChainTx(266-280)
x/observer/types/chain_params.go (1)
x/observer/types/errors.go (1) (1)
ErrParamsStabilityPoolPercentage(79-82)
testutil/keeper/mocks/crosschain/fungible.go (2)
x/crosschain/keeper/v2_zevm_inbound.go (1) (1)
receiver(33-33)x/crosschain/types/message_vote_inbound_test.go (1) (1)
receiver(486-486)
x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (1)
x/crosschain/keeper/msg_server_vote_outbound_tx.go (7) (7)
PercentOf(270-282)k(64-139)k(145-168)k(171-232)k(235-267)k(289-298)k(300-330)
x/fungible/keeper/refund_gas_fee.go (2)
x/fungible/keeper/gas_stability_pool.go (4) (4)
k(12-20)k(23-34)k(37-58)k(61-82)x/crosschain/keeper/msg_server_vote_outbound_tx.go (6) (6)
k(64-139)k(145-168)k(171-232)k(235-267)k(289-298)k(300-330)
x/observer/migrations/v11/migrate_test.go (2)
x/observer/migrations/v11/migrate.go (1) (1)
MigrateStore(18-40)x/observer/types/errors.go (2) (2)
ErrChainParamsNotFound(43-43)ErrInvalidChainParams(42-42)
x/crosschain/keeper/msg_server_vote_outbound_tx.go (7)
x/fungible/keeper/gas_stability_pool.go (4) (4)
k(12-20)k(23-34)k(37-58)k(61-82)x/fungible/keeper/refund_gas_fee.go (1) (1)
k(13-33)x/crosschain/keeper/cctx_orchestrator_validate_outbound.go (7) (7)
k(35-68)k(81-101)k(104-172)k(176-198)k(215-288)k(291-361)k(369-471)x/crosschain/keeper/msg_server_migrate_tss_funds.go (2) (2)
k(19-73)k(76-144)x/crosschain/keeper/cctx_orchestrator_validate_inbound.go (2) (2)
k(15-56)k(60-102)x/crosschain/types/keys.go (1) (1)
UsableRemainingFeesPercentage(32-32)x/observer/types/errors.go (1) (1)
ErrChainParamsNotFound(43-43)
🪛 GitHub Check: codecov/patch
x/crosschain/keeper/v2_zevm_inbound.go
[warning] 128-128: x/crosschain/keeper/v2_zevm_inbound.go#L128
Added line #L128 was not covered by tests
x/crosschain/keeper/msg_server_vote_outbound_tx.go
[warning] 148-157: x/crosschain/keeper/msg_server_vote_outbound_tx.go#L148-L157
Added lines #L148 - L157 were not covered by tests
[warning] 193-194: x/crosschain/keeper/msg_server_vote_outbound_tx.go#L193-L194
Added lines #L193 - L194 were not covered by tests
🪛 LanguageTool
docs/zetacore/managment_for_unused_gas_fee.md
[uncategorized] ~46-~46: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...a safety buffer since we burn the total amount of tokens when initiating the transacti...
(AMOUNTOF_TO_NUMBEROF)
🪛 markdownlint-cli2 (0.17.2)
docs/zetacore/managment_for_unused_gas_fee.md
30-30: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
37-37: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
41-41: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
45-45: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
46-46: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
🔇 Additional comments (42)
x/crosschain/keeper/v2_zevm_inbound.go (1)
128-128:Details
❓ Verification inconclusive
Added blank line for improved readability
The addition of this blank line improves code readability by creating a logical separation between the validation call and its error handling.
🏁 Script executed:
#!/bin/bash # Check if this line is covered by tests ast-grep --pattern $'cctx, err := k.ValidateInbound(ctx, inbound, false)\n\nif err != nil {'Length of output: 91
Action Required: Verify Blank Line Insertion for Readability
The insertion of a blank line between the
k.ValidateInboundcall and its subsequent error handling inx/crosschain/keeper/v2_zevm_inbound.go(around line 128) is intended to enhance readability. However, our automated check usingast-grepdid not return a conclusive match for the expected two-line pattern. Please manually review this file to ensure that the blank line is indeed present and that the logical separation is clear.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 128-128: x/crosschain/keeper/v2_zevm_inbound.go#L128
Added line #L128 was not covered by testsx/crosschain/keeper/initiate_outbound.go (1)
43-45: Clear documentation for gateway typesThe added comments provide valuable context about the supported gateways and their implications for gas fee handling. This documentation enhances code readability and aligns well with the overall objective of implementing a refund mechanism for unused tokens.
x/observer/types/errors.go (1)
79-82: Error registration follows established patternThe new error variable
ErrParamsStabilityPoolPercentageis properly registered with a unique error code and provides a clear error message regarding the constraint on stability pool percentage. This error will be used for validating that the stability pool percentage doesn't exceed 100%.proto/zetachain/zetacore/crosschain/cross_chain_tx.proto (1)
127-131: Well-structured field addition for gas fee trackingThe new
user_gas_fee_paidfield is appropriately positioned in the OutboundParams message and includes proper type annotations. This field is essential for implementing the refund mechanism by tracking the original gas fee paid by the user.The field definition follows the established pattern with proper customtype and nullable settings.
x/observer/migrations/v11/migrate.go (2)
1-1: Package name correctly updated to match migration versionThe package name has been updated from
v10tov11to accurately reflect the migration version being implemented.
15-16: Migration documentation clearly states purposeThe updated comments correctly reflect that this migration moves from version 10 to 11 and explicitly states what modification is being made (updating the 'StabilityPoolPercentage' field).
x/crosschain/keeper/cctx_gateway_observers.go (2)
6-6: Appropriate import for mathematical operations.The addition of the
sdkmathimport is necessary for the mathematical operations introduced in this change.
72-83: Well-implemented gas fee calculation and tracking.The implementation correctly calculates and tracks the user's gas fee payment by:
- Converting the gas limit to a
sdkmath.Uinttype- Calculating the gas fee by multiplying gas limit with gas price
- Storing this value in the outbound parameters
The comments effectively clarify that this value excludes the protocol fee, which is important for subsequent calculations.
x/observer/keeper/migrator.go (2)
6-6: Version update for migration package import.The import change from v10 to v11 correctly reflects the version update in the migration logic.
21-23: Appropriate migration function implementation.The
Migrate10to11function is correctly implemented to handle the migration from store v10 to v11, which will set up the new stability pool percentage feature.While the implementation is correct, this PR should include corresponding tests for this migration function to ensure it behaves as expected, especially with setting the default stability pool percentage value.
#!/bin/bash # Check if tests have been added for the v11 migration rg -A 5 "TestMigrate10to11|Migrate10to11.*test" --type gox/observer/types/chain_params_test.go (1)
105-110: Well-structured test for stability pool percentage validation.The test case correctly verifies that the
StabilityPoolPercentagefield is properly validated to not exceed 100%. This ensures the percentage remains within a valid range and prevents potential issues with incorrect percentage values.x/observer/types/chain_params.go (1)
150-152: Added validation for stability pool percentage - good changeThe new validation correctly ensures that the
StabilityPoolPercentagedoesn't exceed 100, which is a logical constraint for a percentage value. This ensures data integrity and prevents potential issues downstream.x/crosschain/keeper/evm_hooks.go (2)
214-215: Good documentation of gas fee payment flowThis comment clearly explains that the gas fee is already paid when creating the ZRC20Withdrawal event, which explains why the
ValidateInboundfunction is called withfalsefor the fee processing parameter.
298-299: Documentation clarifies fee processing strategyThis comment properly documents that the gas fee is not yet paid for ZetaSent events and should be processed during inbound validation, which corresponds with passing
trueto theValidateInboundfunction.x/crosschain/types/expected_keepers.go (1)
219-219: New method for refunding gas fees supports PR objectiveThe addition of
RefundRemainingGasFeesaligns well with the PR objective of refunding unused tokens to users. The method signature is appropriate with all necessary parameters for this operation.docs/openapi/openapi.swagger.yaml (1)
57816-57818: Addition ofuserGasFeePaidPropertyThe new
userGasFeePaidproperty is clearly added with the typestringand an appropriate description, effectively extending the schema to track the original gas fee paid by the user. Ensure that this change aligns with the corresponding protobuf adjustments and that any related validation logic is updated accordingly.x/fungible/keeper/refund_gas_fee.go (1)
12-33: Implementation looks correct and follows existing patterns.The function correctly handles the refund process by first querying the gas ZRC20 contract and then calling the deposit method to transfer the remaining gas fees to the receiver. This implementation nicely parallels the existing
FundGasStabilityPoolmethod structure, ensuring consistency across the codebase.x/crosschain/keeper/gas_payment.go (7)
131-132: Good separation of gas fee calculation.Separating the base gas fee from the total outbound transaction fee (which includes the protocol flat fee) improves code clarity and provides better tracking of the actual gas cost versus additional fees.
155-157: Clear comment for user gas fee tracking.The comment clearly explains the purpose of storing the user gas fee paid, which is essential for the refund mechanism being implemented.
197-198: Consistent implementation of gas fee calculation.This follows the same pattern established earlier, maintaining consistency across different payment methods.
318-320: Clear documentation for ERC20 gas fee tracking.The comment appropriately explains that this tracks the gas fee paid by the user in Gas ERC20.
358-359: Helpful comment on outbound chain usage.The comment clarifies that the gas price is calculated using the outbound chain ID, which is important context for understanding the implementation.
383-384: Improved clarity with comment on gas token.Adding this comment helps clarify that the fee is denominated in the outbound chain's gas token, which is important for understanding the cross-chain fee mechanics.
459-461: Clear documentation on the flow of ZETA gas fees.The comment clearly explains how the ZETA token is converted to gas and burned for fees, which is essential for understanding this payment flow.
testutil/keeper/mocks/crosschain/fungible.go (1)
633-649: Mock implementation correctly follows established patterns.The mock implementation of
RefundRemainingGasFeesfollows the same pattern as other mocked methods in this file, correctly handling parameters and return values.x/fungible/keeper/refund_gas_fee_test.go (2)
13-23: Good test for system contract dependency.This test case properly verifies that the refund operation fails when system contracts aren't deployed, which is an important error condition to validate.
25-50: Comprehensive happy path test with before/after validation.The test follows best practices by:
- Setting up the necessary preconditions
- Checking the initial state
- Performing the action
- Verifying the expected outcome
The balance check before and after the refund operation provides a strong verification of the functionality.
x/observer/module.go (2)
24-24: Consensus version incremented to support refund mechanism.The update from version 10 to 11 aligns with the introduction of the refund mechanism for unused tokens during outbound transactions.
133-133: Migration registration updated to support new version.The migration registration has been correctly updated to match the consensus version change, ensuring proper state migration from version 10 to 11.
docs/zetacore/managment_for_unused_gas_fee.md (1)
1-69: Well-structured documentation for gas fee management.This documentation provides a comprehensive explanation of the gas fee management process, particularly the refund mechanism for unused tokens. The breakdown of scenarios and detailed explanation of the fee calculation process will be valuable for users and developers.
However, there are a few formatting improvements that would enhance readability:
- Add language identifiers to code blocks for syntax highlighting:
- ``` - actualFee = receipt.GasUsed * transaction.GasPrice() - ``` + ```go + actualFee = receipt.GasUsed * transaction.GasPrice() + ```
- Fix list indentation for consistency (lines 45-46)
- Consider replacing "amount of tokens" with "number of tokens" on line 46 for grammatical precision
🧰 Tools
🪛 LanguageTool
[uncategorized] ~46-~46: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...a safety buffer since we burn the total amount of tokens when initiating the transacti...(AMOUNTOF_TO_NUMBEROF)
🪛 markdownlint-cli2 (0.17.2)
30-30: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
37-37: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
41-41: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
45-45: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
46-46: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
x/crosschain/keeper/cctx_test.go (3)
310-317: Method name updated for better semantic clarity.The method has been renamed from
AddOutboundtoUpdateCurrentOutboundto better reflect its purpose. The function parameters remain unchanged, maintaining compatibility with existing code while improving readability.
333-340: Method name consistently updated in all test cases.The renaming pattern is consistently applied throughout the test suite, ensuring all calls to the method use the new name.
356-363: Final instance of method rename with consistent parameter usage.The method rename has been completed consistently throughout the file. All test scenarios continue to validate the same functionality while using the updated method name.
x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (2)
25-85: Comprehensive test suite for percentage calculation.The
TestPercentOffunction implements a thorough table-driven test for thePercentOfutility function. It covers key scenarios including:
- Zero percent calculations
- Standard percentage calculations (40%)
- Rounding behavior with fractions
- Large percentages (>100%)
Each test case includes clear input values and expected outputs with detailed comments explaining the calculations.
188-491: Extensive test coverage for remaining gas fee distribution.The
TestKeeper_UseRemainingFeesfunction comprehensively tests the gas fee refund mechanism with a wide range of scenarios:
- Fee comparison conditions (when outbound fee exceeds user fee)
- Chain parameter validation
- Non-zEVM chain distributions (100% to stability pool)
- zEVM chain distributions with configurable percentages
- Error handling for stability pool funding failures
- Refund error handling
- Address validation for refunds
- Edge cases with 0% and 100% stability pool percentages
- Precise fee calculations with various input values
The tests effectively validate the business logic for refunding unused gas fees to users while maintaining appropriate portions for the stability pool.
x/crosschain/types/cctx.go (1)
193-223: Validate theValueReceivedvs.Amountcheck carefullyWhile this implementation prevents mismatches between
msg.ValueReceivedand the expectedAmount, consider logging or auditing the cause of such mismatches in production scenarios to help diagnose issues. Otherwise, the update logic and error handling appear appropriate for finalizing the outbound.x/crosschain/keeper/msg_server_vote_outbound_tx.go (6)
11-12: Import Statements UpdatedNo issues noted. Imports of
ethcommon,github.com/pkg/errors,github.com/zeta-chain/node/pkg/chains, andobservertypesappear correct and relevant to the new functionalities.Also applies to: 14-14, 18-18
118-118: Outbound Update MethodReplacing direct outbound addition with
UpdateCurrentOutboundis a neater, more centralized approach. The call is concise and integrates well with the context logic.
123-123: Unused Gas Fee ManagementCalling
ManageUnusedGasFeeafter updating the outbound ensures leftover fees are handled consistently. Good sequence.
141-168: Address Untested Code Paths forManageUnusedGasFeeThe logic appropriately distinguishes between legacy CCTX (with nil
UserGasFeePaid) and newer ones. However, static analysis indicates lines 148–157 have no test coverage. Adding a test scenario with a nilUserGasFeePaidto confirm this fallback behavior would improve reliability.Do you want me to generate a sample unit test method that forces a CCTX with no
UserGasFeePaidand verifies the behavior?🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 148-157: x/crosschain/keeper/msg_server_vote_outbound_tx.go#L148-L157
Added lines #L148 - L157 were not covered by tests
252-252: Safe Guard for Remaining Fees CalculationAdjusting for leftover gas in lines 252 and 255 looks fine. If the
gasLimitis only slightly larger thangasUsed, ensure boundary tests are present to confirm correct integer arithmetic, especially for minimal leftover amounts.Also applies to: 255-255
269-282:PercentOfUtility is ClearYour utility function for calculating percentages on
math.Uintis straightforward and well-documented. This fosters reusability in other fee calculations.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (9)
x/crosschain/types/keys.go (1)
31-32: Consider adding a descriptive comment for the new constant.The new
UsableRemainingFeesPercentageconstant has been added without an explanatory comment. Since this appears to play a crucial role in the refund mechanism for unused tokens, adding a concise comment would enhance code maintainability and help other developers understand its purpose.CCTXIndexLength = 66 MaxOutboundTrackerHashes = 5 + // UsableRemainingFeesPercentage represents the percentage of unused fees that + // can be refunded to users during outbound transactions (95%) UsableRemainingFeesPercentage = uint64(95)x/crosschain/types/inbound_parsing.go (1)
225-227: Remove temporary PR review comments before merging.These comments are intended for PR review purposes only and should be removed before merging. They contain valuable insights about the gas limit handling behavior, which should either be addressed or documented properly.
- // Temporary NOTE for PR review: Don't think this check is necessary as CallOptions.GasLimit is always set - // If its zero we should probably return as the event is directly from the smart contractdocs/openapi/openapi.swagger.yaml (2)
57816-57818: Review ofuserGasFeePaidPropertyThe new property
userGasFeePaidis correctly added with a clear and concise description. Please verify that thestringtype fully meets your expectations for representing gas fee values, particularly if any computations or validations are expected that might benefit from a numeric type.
58520-58525: Review ofstabilityPoolPercentagePropertyThe inclusion of the
stabilityPoolPercentageproperty is well defined with the specified type and format. However, note the duplicated word "are" in the title description. Consider rephrasing it to:
"Percentage of unused tokens for outbounds sent to the stability pool"
to improve clarity and readability. Additionally, ensure that using astringwith auint64format meets the data semantics for percentage values.docs/zetacore/managment_for_unused_gas_fee.md (1)
1-69: Well-structured documentation of the gas fee refund mechanism.The document clearly explains the gas fee management process and refund mechanism for outbound transactions. It provides a comprehensive overview of different scenarios and implementation details.
Consider these improvements for better documentation quality:
- Add language specifiers to code blocks:
- ``` + ```go actualFee = receipt.GasUsed * transaction.GasPrice()2. Fix indentation in bullet points (lines 45-46): ```diff - The 5% of tokens that are not minted back are retained by the TSS address - This creates a safety buffer since we burn the total amount of tokens when initiating the transaction, which creates a deficit + - The 5% of tokens that are not minted back are retained by the TSS address + - This creates a safety buffer since we burn the total number of tokens when initiating the transaction, which creates a deficit
- Fix spelling in the filename: "managment" should be "management"
🧰 Tools
🪛 LanguageTool
[uncategorized] ~46-~46: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...a safety buffer since we burn the total amount of tokens when initiating the transacti...(AMOUNTOF_TO_NUMBEROF)
🪛 markdownlint-cli2 (0.17.2)
30-30: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
37-37: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
41-41: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
45-45: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
46-46: Unordered list indentation
Expected: 2; Actual: 4(MD007, ul-indent)
x/crosschain/keeper/msg_server_vote_outbound_tx.go (2)
148-157: Add a test scenario for userGasFeePaid = nil.
Lines 148-157 are not covered in tests. Proposing a test helps confirm that cctxs created beforeuserGasFeePaidwas introduced correctly funnel fees to the stability pool or log relevant errors.// In x/crosschain/keeper/msg_server_vote_outbound_tx_test.go // For example, in a new or existing test function: +func TestManageUnusedGasFee_NoUserGasFeePaid(t *testing.T) { + k, ctx := setupKeeper(t) + cctx := setupCCTXWithoutUserGasFeePaid(t) + + require.Nil(t, cctx.GetCurrentOutboundParam().UserGasFeePaid) + + k.ManageUnusedGasFee(ctx, cctx) + // Assert that the function attempts to fund the stability pool + // and no panic or unexpected behavior occurs. +}🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 148-157: x/crosschain/keeper/msg_server_vote_outbound_tx.go#L148-L157
Added lines #L148 - L157 were not covered by tests
193-194: Increase test coverage for zero leftover scenario.
When the remaining fees after applying the 95% factor become zero or negligible, lines 193-194 exit early. A quick test case ensures that no fund/refund calls are triggered under these conditions.// In x/crosschain/keeper/msg_server_vote_outbound_tx_test.go, inside TestKeeper_UseRemainingFees // Insert a scenario in the tt slice that yields zero leftover after PercentOf: +{ + name: "no leftover after 95% usage", + receiverChainID: 42, + senderChainID: 7000, + senderZEVMAddress: "0x1234567890123456789012345678901234567890", + outboundTxActualGasUsed: 95, + outboundTxActualGasPrice: math.NewInt(10), + userGasFeePaid: math.NewUint(1000), // leftover is 1000 - 950=50, 95% of that is 47, intentionally set to test minimal leftover + stabilityPoolPercentage: 100, + chainParamsFound: true, + fundStabilityPoolReturn: nil, + expectGetChainParamsCall: true, + expectFundStabilityPoolCall: false, // leftover is effectively 0 after rounding + expectRefundRemainingFeesCall: false, + expectIsZetaChainCall: true, +},🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 193-194: x/crosschain/keeper/msg_server_vote_outbound_tx.go#L193-L194
Added lines #L193 - L194 were not covered by testsdocs/zetacore/gas_fee.md (1)
1-114: Comprehensive gas fee documentation provides clear understanding of fee mechanisms.This documentation thoroughly explains the gas fee structures for transactions on ZetaChain, covering both V2 and V1 protocol flows. The tables effectively summarize fee responsibilities for different transaction types.
A few suggestions for further enhancement:
- Consider adding numerical examples to illustrate fee calculations for each transaction type.
- Provide specific values or formulas for the "Protocol Flat Fee" mentioned throughout the document.
- Include a section on the new refund mechanism for unused gas fees to align with the PR objectives.
x/crosschain/keeper/gas_payment.go (1)
358-359: Zeta payment gas fee calculation and tracking improved with clarifying comments.The added comments enhance code readability by explicitly stating that gas prices are from the outbound chain and fees are calculated in the outbound chain's gas token. Setting
UserGasFeePaidto the Zeta amount used for gas is correct here, though it differs from the other payment methods wheregasFeeis used.For future maintainability, consider adding a comment explaining why
UserGasFeePaidis set to the Zeta amount (outTxGasFeeInZeta) rather than using the same pattern as the other payment methods.Also applies to: 383-384, 460-460
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
typescript/zetachain/zetacore/crosschain/cross_chain_tx_pb.d.tsis excluded by!**/*_pb.d.tstypescript/zetachain/zetacore/observer/params_pb.d.tsis excluded by!**/*_pb.d.tsx/crosschain/types/cross_chain_tx.pb.gois excluded by!**/*.pb.go,!**/*.pb.gox/observer/types/params.pb.gois excluded by!**/*.pb.go,!**/*.pb.go
📒 Files selected for processing (29)
changelog.md(1 hunks)docs/openapi/openapi.swagger.yaml(2 hunks)docs/zetacore/gas_fee.md(1 hunks)docs/zetacore/managment_for_unused_gas_fee.md(1 hunks)proto/zetachain/zetacore/crosschain/cross_chain_tx.proto(1 hunks)proto/zetachain/zetacore/observer/params.proto(1 hunks)testutil/keeper/mocks/crosschain/fungible.go(1 hunks)x/crosschain/keeper/cctx_gateway_observers.go(2 hunks)x/crosschain/keeper/cctx_test.go(3 hunks)x/crosschain/keeper/evm_hooks.go(2 hunks)x/crosschain/keeper/gas_payment.go(7 hunks)x/crosschain/keeper/initiate_outbound.go(1 hunks)x/crosschain/keeper/msg_server_vote_outbound_tx.go(5 hunks)x/crosschain/keeper/msg_server_vote_outbound_tx_test.go(3 hunks)x/crosschain/keeper/v2_zevm_inbound.go(1 hunks)x/crosschain/types/cctx.go(1 hunks)x/crosschain/types/expected_keepers.go(1 hunks)x/crosschain/types/inbound_parsing.go(1 hunks)x/crosschain/types/keys.go(1 hunks)x/fungible/keeper/refund_gas_fee.go(1 hunks)x/fungible/keeper/refund_gas_fee_test.go(1 hunks)x/observer/keeper/migrator.go(2 hunks)x/observer/migrations/v10/migrate_test.go(0 hunks)x/observer/migrations/v11/migrate.go(3 hunks)x/observer/migrations/v11/migrate_test.go(1 hunks)x/observer/module.go(2 hunks)x/observer/types/chain_params.go(1 hunks)x/observer/types/chain_params_test.go(1 hunks)x/observer/types/errors.go(1 hunks)
💤 Files with no reviewable changes (1)
- x/observer/migrations/v10/migrate_test.go
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.go`: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
x/crosschain/types/inbound_parsing.gox/crosschain/keeper/v2_zevm_inbound.gox/crosschain/keeper/initiate_outbound.gox/observer/types/errors.gox/crosschain/types/keys.gox/observer/types/chain_params_test.gox/crosschain/keeper/cctx_gateway_observers.gox/observer/types/chain_params.gox/observer/module.gox/fungible/keeper/refund_gas_fee_test.gox/crosschain/keeper/evm_hooks.gox/crosschain/types/expected_keepers.gotestutil/keeper/mocks/crosschain/fungible.gox/observer/migrations/v11/migrate_test.gox/observer/migrations/v11/migrate.gox/observer/keeper/migrator.gox/fungible/keeper/refund_gas_fee.gox/crosschain/keeper/msg_server_vote_outbound_tx_test.gox/crosschain/keeper/cctx_test.gox/crosschain/types/cctx.gox/crosschain/keeper/gas_payment.gox/crosschain/keeper/msg_server_vote_outbound_tx.go
`**/*.proto`: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.
**/*.proto: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.
proto/zetachain/zetacore/crosschain/cross_chain_tx.protoproto/zetachain/zetacore/observer/params.proto
🧬 Code Definitions (11)
x/observer/types/errors.go (1)
x/observer/types/keys.go (1) (1)
ModuleName(12-12)
x/crosschain/keeper/cctx_gateway_observers.go (3)
testutil/sample/crosschain.go (2) (2)
GasPrice(124-136)InboundParams(176-191)x/crosschain/keeper/gas_price.go (2) (2)
gasPrice(52-52)priorityFee(53-53)x/crosschain/keeper/msg_server_vote_gas_price.go (1) (1)
gasPrice(88-88)
x/observer/types/chain_params.go (1)
x/observer/types/errors.go (1) (1)
ErrParamsStabilityPoolPercentage(79-82)
x/observer/module.go (3)
x/observer/types/keys.go (1) (1)
ModuleName(12-12)x/observer/keeper/migrator.go (1) (1)
m(22-24)x/observer/types/ballot.go (6) (6)
m(10-25)m(27-33)m(36-44)m(49-80)m(82-84)m(96-129)
x/fungible/keeper/refund_gas_fee_test.go (3)
x/fungible/keeper/refund_gas_fee.go (1) (1)
k(13-33)x/crosschain/keeper/msg_server_vote_outbound_tx.go (6) (6)
k(64-139)k(145-168)k(171-232)k(235-267)k(289-298)k(300-330)x/crosschain/types/expected_keepers.go (1) (1)
FungibleKeeper(111-236)
testutil/keeper/mocks/crosschain/fungible.go (2)
x/crosschain/keeper/v2_zevm_inbound.go (1) (1)
receiver(33-33)x/crosschain/types/message_vote_inbound_test.go (1) (1)
receiver(486-486)
x/observer/migrations/v11/migrate_test.go (2)
x/observer/migrations/v11/migrate.go (1) (1)
MigrateStore(18-40)x/observer/types/errors.go (2) (2)
ErrChainParamsNotFound(43-43)ErrInvalidChainParams(42-42)
x/fungible/keeper/refund_gas_fee.go (2)
x/fungible/keeper/gas_stability_pool.go (4) (4)
k(12-20)k(23-34)k(37-58)k(61-82)x/crosschain/keeper/msg_server_vote_outbound_tx.go (6) (6)
k(64-139)k(145-168)k(171-232)k(235-267)k(289-298)k(300-330)
x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (1)
x/crosschain/keeper/msg_server_vote_outbound_tx.go (7) (7)
PercentOf(270-282)k(64-139)k(145-168)k(171-232)k(235-267)k(289-298)k(300-330)
x/crosschain/keeper/gas_payment.go (1)
testutil/sample/crosschain.go (1) (1)
GasPrice(124-136)
x/crosschain/keeper/msg_server_vote_outbound_tx.go (6)
x/fungible/keeper/gas_stability_pool.go (4) (4)
k(12-20)k(23-34)k(37-58)k(61-82)x/fungible/keeper/refund_gas_fee.go (1) (1)
k(13-33)x/crosschain/keeper/cctx_orchestrator_validate_outbound.go (7) (7)
k(35-68)k(81-101)k(104-172)k(176-198)k(215-288)k(291-361)k(369-471)x/crosschain/keeper/cctx_orchestrator_validate_inbound.go (2) (2)
k(15-56)k(60-102)x/crosschain/types/keys.go (1) (1)
UsableRemainingFeesPercentage(32-32)x/observer/types/errors.go (1) (1)
ErrChainParamsNotFound(43-43)
🪛 GitHub Check: codecov/patch
x/crosschain/keeper/v2_zevm_inbound.go
[warning] 128-128: x/crosschain/keeper/v2_zevm_inbound.go#L128
Added line #L128 was not covered by tests
x/crosschain/keeper/msg_server_vote_outbound_tx.go
[warning] 148-157: x/crosschain/keeper/msg_server_vote_outbound_tx.go#L148-L157
Added lines #L148 - L157 were not covered by tests
[warning] 193-194: x/crosschain/keeper/msg_server_vote_outbound_tx.go#L193-L194
Added lines #L193 - L194 were not covered by tests
🪛 LanguageTool
docs/zetacore/managment_for_unused_gas_fee.md
[uncategorized] ~46-~46: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...a safety buffer since we burn the total amount of tokens when initiating the transacti...
(AMOUNTOF_TO_NUMBEROF)
🪛 markdownlint-cli2 (0.17.2)
docs/zetacore/managment_for_unused_gas_fee.md
30-30: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
37-37: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
41-41: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
45-45: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
46-46: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
🔇 Additional comments (37)
x/crosschain/keeper/v2_zevm_inbound.go (1)
128-128:Details
❓ Verification inconclusive
Approve the addition of the blank line.
This blank line improves code readability by separating the function call from the error handling logic.
While this change is acceptable, it appears this line is not covered by tests according to static analysis.
🏁 Script executed:
#!/bin/bash # Description: Check test coverage for ProcessZEVMInboundV2 function # Find all test files that might test this function rg -l "TestProcessZEVMInboundV2" --type goLength of output: 42
Approval for Blank Line Addition – Manual Test Coverage Verification Required
The blank line addition improves readability by clearly separating the function call from the error handling logic. However, our static analysis did not locate any tests for the
ProcessZEVMInboundV2function (no output was returned by the test search script). Please verify manually whether this function is intentionally untested or if additional test coverage should be implemented to safeguard against potential issues.
- File:
x/crosschain/keeper/v2_zevm_inbound.go- Line: 128
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 128-128: x/crosschain/keeper/v2_zevm_inbound.go#L128
Added line #L128 was not covered by testsx/crosschain/types/inbound_parsing.go (1)
228-230:Details
❓ Verification inconclusive
Evaluate the necessity of this gas limit check.
The temporary comments suggest that this check might be unnecessary as
CallOptions.GasLimitis always set from the smart contract. Additionally, as noted in previous review comments, there's an inconsistency in how gas limit is handled compared toNewWithdrawalInboundandNewCallInbound.Consider one of these options:
- If the check is truly unnecessary, remove it
- If it should be kept, address the inconsistency noted in previous reviews where we're using
gasLimiton line 243 which may not have been updated
🏁 Script executed:
#!/bin/bash # Description: Validate whether CallOptions.GasLimit is always set in WithdrawnAndCalled events # Search for contract implementations that emit WithdrawnAndCalled events rg -A 10 "emit WithdrawnAndCalled" --type solidity # Check for test cases that verify this behavior rg -A 5 "WithdrawnAndCalled.*GasLimit" --type goLength of output: 136
Gas Limit Check Evaluation: Revisit Necessity and Consistency
Based on our initial investigation, the automated queries did not yield conclusive evidence that
CallOptions.GasLimitis always set from the smart contract. There is still potential for the gas limit check atx/crosschain/types/inbound_parsing.go:228-230to be redundant, as the temporary comments suggest, but we must also address the noted inconsistency with how gas limits are handled inNewWithdrawalInboundandNewCallInbound.
- Action Required:
- Manual Verification: Confirm that the smart contract reliably provides
CallOptions.GasLimitfor allWithdrawnAndCalledevents.- Consistency Check: Ensure that the gas limit initialization logic is consistent across all relevant functions (i.e., in both
NewWithdrawalInboundandNewCallInbound).- Based on Findings:
- If the check is indeed redundant, remove the conditional block.
- Otherwise, update the handling to align with the established logic in the other functions.
Please review these points and verify the behavior in your specific codebase.
x/crosschain/types/cctx.go (1)
193-193: Approve the method renaming for improved clarity.Renaming the method from
AddOutboundtoUpdateCurrentOutboundbetter reflects its actual functionality, which is to update the current outbound transaction using a given vote outbound message rather than adding a new outbound transaction.x/observer/types/errors.go (1)
79-82: Approve the addition of stability pool percentage validation error.This new error provides appropriate validation for the stability pool percentage feature being implemented as part of the refund mechanism. The error message clearly communicates that the percentage cannot exceed 100.
x/observer/migrations/v11/migrate.go (3)
1-1: Package updated to follow version increment.Package name has been correctly updated from
v10tov11to reflect the new migration version.
15-16: Documentation updated to reflect new migration version.The function documentation has been properly updated to reflect that it migrates from consensus version 10 to version 11, and clearly explains the purpose of the migration.
27-27:Details
✅ Verification successful
Hard-coded stability pool percentage value.
The migration sets a fixed stability pool percentage of 60 for all chain parameters. This value appears to be a carefully considered configuration parameter.
🏁 Script executed:
#!/bin/bash # Check if there are any references to stability pool percentage values in other files rg "StabilityPoolPercentage" --type go -A 2 -B 2Length of output: 3835
Migration confirms the intentional hard-coded value for StabilityPoolPercentage.
After reviewing the code and test outputs, it’s clear that the fixed value of 60 is deliberately set during migration and verified in the corresponding tests. The approach is consistent with the intended design and validation logic. There are no further action items.proto/zetachain/zetacore/crosschain/cross_chain_tx.proto (1)
127-131: Well-structured addition of user gas fee tracking.The new
user_gas_fee_paidfield is properly defined with appropriate documentation, type definition, and field numbering. This is an important addition for tracking the original gas fee paid by the user, which will enable the refund mechanism described in the PR objectives.x/observer/types/chain_params_test.go (1)
105-110: Added test for stability pool percentage validation.Good addition of a test case that verifies the validation logic rejects stability pool percentages greater than 100. This test helps ensure the integrity of this important constraint.
x/crosschain/keeper/initiate_outbound.go (1)
43-45: Improved documentation with gateway explanations.These comments provide valuable context about the different gateway types and their gas fee behavior, which clarifies the conditional dispatch mechanism in the function. This information is particularly relevant for the token refund feature being implemented.
x/observer/keeper/migrator.go (2)
6-6: Import statement updated from v10 to v11The import has been correctly updated to reference the v11 migrations package, aligning with the new migration function.
21-24:Details
❓ Verification inconclusive
New migration function follows established pattern
The implementation of
Migrate10to11correctly follows our established migration pattern by delegating to theMigrateStorefunction in the v11 package.
🏁 Script executed:
#!/bin/bash # Verify that tests have been added for the v10 to v11 migration rg -A 5 "TestMigrate10to11|Test.*v10.*v11" --type goLength of output: 54
Action Required: Verify Migration Test Coverage
The implementation ofMigrate10to11inx/observer/keeper/migrator.gocorrectly delegates tov11.MigrateStorefollowing our established migration pattern. However, our recent search for migration tests (e.g., forTestMigrate10to11or related patterns) yielded no results. Please manually verify that tests for the v10 to v11 migration have been added or add them if missing.proto/zetachain/zetacore/observer/params.proto (1)
42-44:Details
❓ Verification inconclusive
Well-defined stability pool percentage field
The new
stability_pool_percentagefield is properly defined with clear comments describing its purpose. This aligns with the PR's objective to refund a portion of remaining unused tokens to users.
🏁 Script executed:
#!/bin/bash # Check if validation is implemented for the stability_pool_percentage field rg -A 10 "StabilityPoolPercentage.*validate|validate.*StabilityPoolPercentage" --type goLength of output: 90
Stability Pool Percentage Field: Further Manual Verification Required
The
stability_pool_percentagefield defined inproto/zetachain/zetacore/observer/params.proto(lines 42–44) is clear and well-documented, aligning with the PR’s objective to refund unused tokens. However, the automated search for validation logic in the Go code returned no output. Please verify manually that:
- Any expected validation for this field is implemented elsewhere or that its absence is intentional based on design requirements.
- The lack of validation code does not lead to unintended behavior downstream.
x/crosschain/types/expected_keepers.go (1)
219-219:Details
✅ Verification successful
Interface extended with gas fee refund method
The
FungibleKeeperinterface has been correctly extended with theRefundRemainingGasFeesmethod, allowing for the refund of unused gas fees to users. The method signature is well-defined with appropriate parameters.
🏁 Script executed:
#!/bin/bash # Verify implementation of the RefundRemainingGasFees method rg -A 20 "func \(\w+ \*Keeper\) RefundRemainingGasFees" --type goLength of output: 67
Interface Extension Verified: RefundRemainingGasFees Signature Is Correctly Declared
The method signature for refunding unused gas fees is properly declared in the FungibleKeeper interface within
x/crosschain/types/expected_keepers.go. Note that this method is meant to be a part of the interface specification, so no standalone function implementation (using thefunckeyword) is expected in the codebase. To clarify:
- The original grep search aimed to locate an implementation pattern (
func (*Keeper) RefundRemainingGasFees), which naturally returned no results since the method is solely declared in the interface.- The interface declaration itself (as seen on line 219) correctly defines the method with the appropriate parameters.
Based on this understanding, the extension is correct. However, if your intent includes ensuring that all concrete keepers properly implement this new method in their respective implementations, a manual verification of those implementations might also be warranted.
x/crosschain/keeper/cctx_gateway_observers.go (1)
73-83:Details
❓ Verification inconclusive
Properly implemented gas fee tracking for refunds
The code now calculates and stores the user's gas fee contribution, which is essential for implementing the refund mechanism. The implementation correctly:
- Extracts the gas limit from outbound parameters
- Calculates the gas fee paid by multiplying gas limit and price
- Stores this in the UserGasFeePaid field for later refund calculations
🏁 Script executed:
#!/bin/bash # Check if priorityFee is considered in other gas fee calculation locations rg -A 5 "gasFeePaidByUser.*priorityFee|UserGasFeePaid.*priorityFee" --type go # Check where this UserGasFeePaid value is used for refunds rg -A 10 "UserGasFeePaid.*refund|refund.*UserGasFeePaid" --type goLength of output: 148
Action Required: Confirm Refund Mechanism Integration
The updated code correctly computes and assigns the user’s gas fee contribution by multiplying the gas limit and gas price, and it cleanly stores the result in the
UserGasFeePaidfield. However, our automated search did not reveal any direct references to this field in subsequent refund calculations or integrations. Please manually verify the following:
- Ensure that the
UserGasFeePaidvalue is consumed in the refund mechanism as intended.- Confirm that the separate
GasPriorityFeesetting is correctly accounted for, if required by the overall refund logic.x/crosschain/keeper/evm_hooks.go (2)
214-214: Clear documentation of gas fee handling.This comment provides important context about when gas fees are processed, clarifying that for ZRC20Withdrawal events, the user has already paid the gas fee during event creation.
298-298: Complementary documentation for gas fee workflow.This comment complements the earlier one by explicitly stating that in the ZetaSent event flow, gas fees have not been paid yet and should be processed during inbound validation.
changelog.md (1)
16-16: Well-documented feature addition to changelog.The changelog entry properly documents the new refund functionality for unused tokens, which aligns with the PR objectives of implementing a feature to refund a portion of unused tokens back to users.
testutil/keeper/mocks/crosschain/fungible.go (1)
633-649: Correctly implemented mock for new gas fee refund functionality.The mock implementation follows the established pattern in the codebase for testable keeper functions. The method properly handles error checking and return value management as required for testing the refund mechanism.
x/observer/types/chain_params.go (1)
150-152: Added validation for stability pool percentage.This validation ensures that the stability pool percentage cannot exceed 100%, enforcing a logical constraint for percentage values. The check uses the appropriate error type (
ErrParamsStabilityPoolPercentage) and follows the existing validation pattern.x/fungible/keeper/refund_gas_fee.go (1)
13-33: Implementation looks robust and complete.The
RefundRemainingGasFeesfunction is well-structured, with clear error handling and proper dependency usage. It follows the same pattern as other similar functions in the codebase (likeFundGasStabilityPoolandWithdrawFromGasStabilityPool), maintaining consistency in the API design.x/fungible/keeper/refund_gas_fee_test.go (2)
14-23: Test case properly covers the error scenario.This test case verifies that an error is returned when system contracts are not deployed, which is a critical edge case to verify.
25-50: Comprehensive happy path testing.The test thoroughly validates the refund functionality by checking the receiver's balance before and after the operation, ensuring the correct amount was transferred.
x/crosschain/keeper/cctx_test.go (3)
310-310: Method rename improves semantic clarity.Changing from
AddOutboundtoUpdateCurrentOutboundbetter reflects the actual operation being performed, which is updating the current outbound parameter rather than adding a new one.
333-333: Consistent method rename application.The method rename has been correctly applied across all test cases, maintaining consistency.
356-356: Error path validation maintained after rename.The test still properly validates that an error is returned when the amount does not match the value received, which is crucial for maintaining system integrity.
x/observer/migrations/v11/migrate_test.go (2)
13-98: Well-structured tests covering successful migration and error cases.The test suite thoroughly validates the v11 migration logic with comprehensive test cases:
- Successful migration updating StabilityPoolPercentage to 60
- Error handling when chain parameters are missing
- Error handling when chain parameters validation fails
The test implementation follows best practices with clear arrange-act-assert pattern and thorough verification of both direct outcomes and side effects.
60-61: Function calls correctly reference v11 migration.The implementation correctly calls
v11.MigrateStore()in all test cases, addressing an issue identified in a previous review.Also applies to: 88-89
x/crosschain/keeper/msg_server_vote_outbound_tx_test.go (3)
12-12: Import usage is fine.
No issues found with this import addition.
25-85: Comprehensive table-driven test for PercentOf.
The coverage of typical and boundary scenarios (0%, 40%, fractional, large percentages) is well-structured, ensuring the correctness of thePercentOffunction.
188-491: Thorough coverage in TestKeeper_UseRemainingFees.
Tests cover a variety of scenarios including chain param checks, zEVM vs. non-zEVM calculations, invalid addresses, and partial refunds to the user. The logic appears sound, and the table-driven approach is maintainable and easy to extend for future scenarios.x/crosschain/keeper/msg_server_vote_outbound_tx.go (2)
11-12: Imports are well-placed and relevant.
No issues found with the new import statements; they align with the usage throughout the file.Also applies to: 14-18
145-168: Revisit partial rollback handling in ManageUnusedGasFee.
Current error logging without rollback was previously noted. If refunds or stability pool funding fail, consider whether partial rollbacks or additional fallback logic would be appropriate.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 148-157: x/crosschain/keeper/msg_server_vote_outbound_tx.go#L148-L157
Added lines #L148 - L157 were not covered by testsx/observer/module.go (2)
24-24: Increment in consensus version aligns with migration logic.The consensus version has been correctly incremented to reflect the introduction of a new migration. This change is consistent with the migration from version 10 to 11.
133-133: Migration registration updated correctly.The migration registration has been appropriately updated to use
Migrate10to11function, which aligns with the incremented consensus version. This ensures proper state migration path consistency.x/crosschain/keeper/gas_payment.go (2)
131-132: Improved gas fee tracking in Native payment method.The introduction of a separate
gasFeevariable provides better clarity by distinguishing between the actual gas cost and the total fee including protocol flat fee. This change enables proper tracking of user-paid gas fees for potential refunds.Also applies to: 156-156
197-198: Enhanced fee tracking for ERC20 payments follows consistent pattern.The same gas fee calculation pattern has been applied to ERC20 payments, maintaining consistency across payment methods. This structured approach will facilitate the refund mechanism for unused gas.
Also applies to: 319-319
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* fix: ratelimiting race condition vuln (#4072) * fix: ratelimiting race condition vuln * fix: ratelimiting race condition vuln - Fix race condition in RateLimiter.Release() function - Replace non-atomic check-then-act with atomic decrement and bounds checking - Add comprehensive test suite to verify the fix - Update changelog with PR #4072 * fix: correct atomic implementation to prevent underflow - Replace flawed Add(-1) approach with proper CompareAndSwap - Fix underflow detection issue where uint32 wrap-around was missed - Add TestRateLimiterUnderflowProtection to verify the fix - Ensure Release() never causes negative counters or semaphore over-release * refactor: simplify rate limiter Release() implementation - Remove unnecessary infinite loop in CAS operation - Single CAS attempt is sufficient for race condition protection - Maintains thread-safety while being more efficient - All tests still pass with simplified implementation * fix: correct order of operations in rate limiter Release() - Fix race condition by decrementing counter before releasing semaphore - Ensure pending counter accurately reflects semaphore state - Simplify implementation by using correct operation order - All tests pass with cleaner, more logical approach * test: add tests that reproduce the original race condition vulnerability - Add BuggyRateLimiter that implements the original vulnerable code - Add TestBuggyRateLimiterRaceCondition to demonstrate the race condition - Add TestBuggyRateLimiterStressTest to stress test the vulnerability - Add TestVulnerabilityDemonstration to show before/after comparison - Add TestBuggyRateLimiterExcessiveReleases to show excessive release issues - These tests demonstrate the theoretical vulnerability even if timing makes it hard to reproduce consistently * fix: address race condition and underflow issues in RateLimiter - Fix race condition in Release() by reordering operations (decrement pending first, then release semaphore) - Fix Pending() function to handle negative atomic.Int32 values correctly - Add comprehensive tests to verify fixes - Remove buggy code from tests as requested by reviewers - Document original vulnerability in test comments The original race condition allowed multiple goroutines to release more permits than acquired. The Pending() function could return incorrect values due to negative atomic.Int32 conversion. Fixes: #4072 * refactor: rename test and update changelog to reflect actual improvements - Rename TestVulnerabilityDemonstration to TestRateLimiterRobustness - Update test description to reflect code quality improvements rather than vulnerability fixes - Update changelog entry to match actual changes - Tests still pass, confirming the improvements are working correctly The reviewer correctly pointed out that if tests pass on develop without fixes, then we're improving robustness rather than fixing vulnerabilities. * refactor: remove support for v1 revert address for BTC (#4070) * remove support for v1 revert address for BTC * add changelog --------- Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * feat: add support for withdraw using v2 connector contract (#4064) * update go mod * add a new message for migrating funds * add migrate funds to e2e * rebase from develop * add v2 e2e test to check flow * add zeta gateway deposit to zetaclient * add github workflow * update comments * fix code formating * fix code formating * fix code formating * fix unit tests * fix unit tests * revert to old command to start e2e test * remove message for migration and refactor to using contract directly * add changelog * generate files after removing new message * update generated files * update generated files * update go mod * update deposit * add unit tests * add unit tests * generate files * generate files * undo changes based on develop * update deposit and revert smart contract call * rename zeta deposit test file * rename zeta deposit test file * add abort and revert tests * add TestZetaDepositAndCallNoMessage * add TestZetaDepositAndCallNoMessage * remove payable from TestAbort contract * rename to LegacyZETADepositAndCallContract * improve unit test coverage * fix unit tests * add some delay in TestZetacore_SubscribeNewBlocks * update comment for handling zeta token zrc20 * add e2e test * add e2e test for withdraw * refactor ProcessZEVMInboundV2 * add core registry to setup * refactor e2e test helper functions * add unit test for zeta withdraw * add unit test for withdraw and call * resolve comments 1 * add unit test for ProcessRevert * add unit test for ProcessRevert * add unit test for ProcessRevert * improve abort tests * improve abort tests * resolve comments * resolve comments 2 * update upgrade height to 280 to allow the first test to run the entire cycle * wrap zeta mints in tmp context * wrap zeta mint in temp context * rebase * add changelog * add changelog * adjust comments * Update cmd/zetae2e/config/contracts.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix gas pool zeta calcualation * add unit test for executeWithMintedZeta * fix comments 1 * add unit tests * update test dapp to use zeta token for consuming gas * add core registry to zeta e2e post upgrade handler * revert legacy test * update changes based on comments 1 --------- Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: print error message in detail if unable to decode Bitcoin memo (#4090) * print error message detail when memo decoding failed * add changelog entry * keep invalid memo log on Info level --------- Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * test(e2e): update admin e2e tests to use v2 connector (#4071) * update go mod * add a new message for migrating funds * add migrate funds to e2e * rebase from develop * add v2 e2e test to check flow * add zeta gateway deposit to zetaclient * add github workflow * update comments * fix code formating * fix code formating * fix code formating * fix unit tests * fix unit tests * revert to old command to start e2e test * remove message for migration and refactor to using contract directly * add changelog * generate files after removing new message * update generated files * update generated files * update go mod * update deposit * add unit tests * add unit tests * generate files * generate files * undo changes based on develop * update deposit and revert smart contract call * rename zeta deposit test file * rename zeta deposit test file * add abort and revert tests * add TestZetaDepositAndCallNoMessage * add TestZetaDepositAndCallNoMessage * remove payable from TestAbort contract * rename to LegacyZETADepositAndCallContract * improve unit test coverage * fix unit tests * add some delay in TestZetacore_SubscribeNewBlocks * update comment for handling zeta token zrc20 * add e2e test * add e2e test for withdraw * refactor ProcessZEVMInboundV2 * add core registry to setup * refactor e2e test helper functions * add unit test for zeta withdraw * add unit test for withdraw and call * resolve comments 1 * add unit test for ProcessRevert * add unit test for ProcessRevert * add unit test for ProcessRevert * improve abort tests * improve abort tests * resolve comments * resolve comments 2 * update upgrade height to 280 to allow the first test to run the entire cycle * wrap zeta mints in tmp context * wrap zeta mint in temp context * rebase * add changelog * add changelog * adjust comments * Update cmd/zetae2e/config/contracts.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix gas pool zeta calcualation * add unit test for executeWithMintedZeta * fix comments 1 * add unit tests * update admin * revert unncessary changes * disable account balance verification for admin tests * improve naming for deposit functions * add changelog * update comments * update test legacy test zeta to use EVMAddress * remove skipping admin in upgrade setup --------- Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * test: fix eth deposit test to check balance after deposit (#4118) * check balance after eth deposit test * fix typo * fix import * test: fix flaky Solana depositAndCall tests (#4113) * fix flaky solana depositAndCall tests * add changelog entry * add wait logic inside AssertTestDAppEVMCalled * chore: bump cosmos evm to support querying legacy proposals of type MsgUpdateParams (#4094) * update zeta evm * update commit * fix: use evm chain id from eth config in rpc backend (#4096) * fix: cancel solana WaC if tx size is too large (#4098) * cancel solana WaC if tx size is too large * align the comments with the code * fix: nil reference in trace block (#4093) * update to commit be548f7691876e656ec61aa46e31ed337be92f4e , on branch release/v34 --------- Co-authored-by: skosito <skostic9242@gmail.com> Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> Co-authored-by: morde08 <peter@zetachain.com> * fix: error when deploying contracts on testnet (#4112) * dont return err if tx is not found in get tx receipt * fix tests * changelog * feat: support hostname in addition to public IP for zetaclient to connect to zetacore (#4068) * save initial work to remote * add unit test and live test for zetacore hostname support * add changelog entry; fix gosec and clean unused code * fix CI upgrade test --------- Co-authored-by: Tanmay <tanmay@zetachain.com> * fix: dbg trace block by number gas limit legacy (#4121) * fix dbg trace by block * PR comments * changelog * fix(cherry-pick): cancel solana WaC if tx size is too large (#4111) * cancel solana WaC if tx size is too large * add changelog entry * chore: remove tx suffix in vote inbound and outbound message names (#4110) * fix(`crosschain`): remove confirmation mode from outbound and inbound digest (#4116) * inbound * . * changelog * refactor(zetacore): overwrite consensus config values for all timeout deltas on startup. (#4097) * update 1 * add start-skip-consensus-overwrite-test * generate files * update tests * add unit tests * add unit tests for GenesisChainID * add unit tests for GenesisChainID * rename genesisChainID * fix typo * remove testnet from overwrite check * refactor: replace []byte(fmt.Sprintf) with fmt.Appendf (#4131) Signed-off-by: yinwenyu6 <yinwenyu6@outlook.com> * feat: Sui message context ID as dynamic field (#4087) * re-enable sui authenticated call * integrate message context ID as dynamic field * add changelog entry * make issueMessageContext function self-contained * fix unit test * remove --skip-dependency-verification in sui gateway upgrade test * cancel withdrawAndCall on invalid payload * adopt new increase_nonce signature to adopt gas refund logic when cancelling a CCTX * apply stringent check on Sui transaction's checkpoint * apply status check on Sui inbound * fix CI upgrade test * fix unit test * chore: fix some function names in comment (#4129) Signed-off-by: pxwanglu <pxwanglu@icloud.com> * chore: fix some observer message names (#4141) * test: fix flaky Solana SPL deposit balance check (#4142) * fix solana e2e SPL balance check by waiting maximum 30 seconds * add changelog entry * refactor: remove intx and outtx deprecated queries (#4150) * refactor: remove intx and outtx deprecated queries * fixes in e2e * chore: remove redundant word in comment (#4149) Signed-off-by: wmypku <wmypku@outlook.com> * test(`e2e`): improve logs for CCTX status assertion (#4147) * improve require status logs * update usage in tests * lint * cursor comment * chore: fix some typos in comment (#4146) Signed-off-by: tzchenxixi <tzchenxixi@icloud.com> * chore: set v35 as upgrade test reference and various clean up (#4115) * add back precompiles * add abci field to proposal * test * enable back * test no creating proposasl * disable zeta-ante * cleanup v33 upgrade helper * add v35 as reference * remove gas stability pool temporary * update to v36 and disable fast confirmation test * bitcoin fast confirmation * increase ersion for zeta * remove erc20 init handler * disable zevm to evm revert for older version * disable zevm to evm revert abort for older version * increase upgrade height * feat: make the gas limit used for gateway calls on ZEVM a configurable parameter (#4153) * add GatewayGasLimit to state * refactor function name from MustGetGatewayGasLimit to GetGatewayGasLimitSafe * update unit tests * update unit tests * update proto files * replace big int with uint64 * changelog * add check of older value * add v4 migration back for authority module * update setup handler to remove setting erc20 module * test changes * revert to using v32 as base branch for upgrades --------- Co-authored-by: lumtis <lucas.bertrand.22@gmail.com> * test(`e2e`): add a gas limit option for ZEVM to EVM call tests (#4145) * add gas limit option * use option for tests * increase further upgrade height * test: use pre-deployed example dapp V2 contract in e2e tests (#4158) * do not deploy example contract in e2e tests, use pre-deployed example dapp V2 instead * add changelog entry * clean up debugging log * remove commented code * add back extra zrc20 SPL balance check * chore(`e2e`): cleanup unused contracts (#4161) * remove contextapp * remove distribute * test: fix flaky depositAndCall test that failed on sender assertion (#4165) * fix flaky depositAndCall caused by sender assertion * add changelog entry * chore(deps): bump github.com/hashicorp/go-getter from 1.7.8 to 1.7.9 (#4148) Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.7.8 to 1.7.9. - [Release notes](https://github.com/hashicorp/go-getter/releases) - [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml) - [Commits](hashicorp/go-getter@v1.7.8...v1.7.9) --- updated-dependencies: - dependency-name: github.com/hashicorp/go-getter dependency-version: 1.7.9 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump github.com/ulikunitz/xz from 0.5.11 to 0.5.14 (#4172) Bumps [github.com/ulikunitz/xz](https://github.com/ulikunitz/xz) from 0.5.11 to 0.5.14. - [Commits](ulikunitz/xz@v0.5.11...v0.5.14) --- updated-dependencies: - dependency-name: github.com/ulikunitz/xz dependency-version: 0.5.14 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump github.com/go-viper/mapstructure/v2 from 2.2.1 to 2.4.0 (#4173) chore(deps): bump github.com/go-viper/mapstructure/v2 Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.2.1 to 2.4.0. - [Release notes](https://github.com/go-viper/mapstructure/releases) - [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md) - [Commits](go-viper/mapstructure@v2.2.1...v2.4.0) --- updated-dependencies: - dependency-name: github.com/go-viper/mapstructure/v2 dependency-version: 2.4.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * refactor: standardize zetaclient logging (#4144) * chore: remove unused DynamicTicker from zetaclient/types * refactor: remove Msgf and refactor zerolog uses * Replace Msgf for Msg * Use '_' instead of '.' * Start logs with lowercase instead of uppercase characters * Use the constants in the logs module * Use With().Logger() instead of log fields when possible * fix: improve zetatool (#4175) * scan gateway events by default for all inbound hashes * scan gateway events by default for all inbound hashes * test(`e2e`): add a E2E test to test depositAndCall with high gas consumption (#4177) * set gas limit to 4m in localnet * add high usage test * changelog * Update changelog.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update e2e/e2etests/e2etests.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * test(`e2e`): add all chains by default in `start-localnet` (#4163) * chore: add Solana to start-localnet to allow to run local tests * add sui and ton * Update cmd/zetae2e/local/local.go Co-authored-by: Tanmay <tanmay@zetachain.com> --------- Co-authored-by: Tanmay <tanmay@zetachain.com> * chore: remove redundant words (#4179) Signed-off-by: keeghcet <keeghcet@outlook.com> * refactor: omit unnecessary reassignment (#4184) Signed-off-by: fengyuchuanshen <fengyuchuanshen@outlook.com> * fix: force rescan if inbound vote monitoring fails (#4183) * add monitoringErr channel * update to InboundBlockHeight - 1 , for reseting the block * fix unit tests * implement error interface * rename to ErrTxMonitor * add forceResetLastScanned flag * add forceResetLastScanned flag * add mutex to force scan * add changelog * add changelog * update name to wasForceReset * wrap UpdateForceResetLastScanned in mutex * add a bound check to InboundBlockHeight to be safe * Update zetaclient/chains/base/confirmation.go Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * Update zetaclient/chains/base/observer.go Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * force update for in memory value if forceResetLastScanned is true * add a lock on reading block height * update error message * update changelog * wait till end of scan cycle to toggle the forceUpdateFlag --------- Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * fix: remove duplicate solana post-gas-price goroutine (#4194) * feat: observe inbound from previous gateway package after upgrade (#4138) * observe inbound from old gateway package optionally * add changelog entry * add sui inbound cursor migration; add post-upgrade deposit tests * improve comments, logs and naming; fix post-upgrade withdraw failure * protect anyStringMap * add support for <withdrawcap-id> to Sui gateway address * fix CI upgrade test failure * use name previousPackageID and keep name PairID; rename AnyString and cursor migration function; improve test, comments, etc. * replaced assert by require in sui unit test * add support for original packageID in Sui gateway address * avoid wrapping nil error * use previous package ID in post-upgrade Sui deposit test * add support for previous package deprecation and fix upgrade test * fix unit test * add a note to clarify the PackageID argument used for event query * add documents to explain Sui gateway address format in the chain params * refactor: remove unused loggers and log fields (#4180) * chore: remove unused Headers logger * refactor: remove (mostly) unused GasPrice logger * refactor: replace logs.FieldMethod with With().Caller() and standardize logs.FieldModule values * refactor: remove (mostly) unused log fields FieldTracker and FieldConfirmationMode * refactor: replace missed log instances of '.' for '_' * fix: unpack bitcoin revert message without considering 'CallOnRevert' flag (#4169) * enable bitcoin revertMessage and ignore CallOnRevert flag * add changelog entry * update standard memo doc; improve abort address validation * skip incompatible e2e test to allow CI upgrade test to pass * fix: add timeout to monitoring routine (#4196) * add a timeout for vote monitoring thread * add a timeout for vote monitoring thread * add comments * remove typo for cancel call * fix unit tests * Update zetaclient/zetacore/client_vote.go Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * Update zetaclient/chains/base/observer.go Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> --------- Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> * refactor: use maps.Copy for cleaner map handling (#4198) Signed-off-by: joemicky <joemickychang@outlook.com> * chore: fix some comments (#4208) Signed-off-by: zhoujiaweii <zjwustc@outlook.com> * fix: update evm version for missing tx types (#4216) * refactor: replace HasPrefix+TrimPrefix with CutPrefix (#4215) Signed-off-by: quantpoet <quantway@outlook.com> * refactor: remove `LastBlockHeight` state variable (#4200) * proto * remove other references * changelog * refactor: add documentation for ZetaClient logging fields (#4174) * refactor: use coin.CoinType for compliance logging * refactor: add documentation for zetaclient logging fields * fix: remove ZetaChain chain ID from GasStabilityPoolBalances query (#4217) * fix query * add test * changelog * add commment * lint * remove gas token address * change error type * refactor: remove index field in ballot (#4205) * refactor: remove index field in ballot * changelog * fix unit tests * refactor: remove `MsgUpdateERC20CustodyPauseStatus` and `MsgMigrateERC20CustodyFunds` (#4199) * make message legacy * remove other reference * changelog * refactor: rename whitelistERC20 into whitelistAsset (#4203) * refactor: rename whitelistERC20 into whitelistAsset * e2e test * e2e test * fix event * simulation * changelogs * update auth list * add migration script * apply comment * feat: provide error information in CCTX struct when Bitcoin deposit fail (#4211) * add error message to CCTX struct when Bitcoin deposit failed * add changelog entry * fix unit test; improve function naming * add unit test for inbound vote digest * exclude inbound observation error message from digest * fix: re-check for finalized ballot when executing inbound vote to create cctx (#4197) * check for finalized block after ballot is finalized * fix unit tests and add changelog * adjust comments * Apply suggestion from @lumtis Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * Apply suggestion from @lumtis Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * refactor check finalized ballot check to be done before adding the finalizing vote to the ballot * adjust comments * adjust comments * fix comments 2 --------- Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * fix: set zeta ante to true in upgrade tests (#4225) * add zeta ante * add to upgrade test regular * add to upgrade test regular * update out of gas test * update out of gas test * fix tss migration test * fix lint issues 1 * update v2 zeta version * chore: resync changelogs with v36 changes (#4223) * fix: skip writing config file to the filesystem (#4210) * comment out writing files to the state * ad changelog * remove commented code * return error from fetching FlagSkipConfigOverwrite * refactor(`observer`): remove deprecated code (#4192) * update proto * update code * changelogs * fix changelog * fix gas limit issue in upgrade test * use ante-zetae2e for admin upgrade tests * test fix * refactor: prepare the client interfaces used by the observer-signers for dry-mode (#4213) refactor: prepare the client interfaces of the observer-signers for dry-mode * feat: enable NoAssetCall from Bitcoin (#4218) * enable NoAssetCall from Bitcoin * add changelog entry * improve comment and log print * revert bitcoin NoAssetCall that carries large excessive funds * adjust btc inbound parsing order; fix test name * improve function and variable names * feat: multiple evm calls in single tx (#4157) * bump protocol contracts * use newer geth version with cancun support * e2e test with 2 deposits in same tx * e2e tests * inbound trackers for multiple events * changelog * generate * fix e2e tests * inbound trackers e2e test * bump protocol contracts * PR comments * PR comment * PR comments * PR comment * lower upgrade height in upgrade tests * try diff upgrade height * upgrade additional fee in upgrade v36 handler * chore: fix function name in comment (#4238) Signed-off-by: russcoss <russcoss@outlook.com> * revert: add timeout to monitoring routine" (#4244) Revert "fix: add timeout to monitoring routine (#4196)" This reverts commit 65f227b. * fix(e2e): check test contracts deployment (#4251) * fix(e2e): check test contracts deployment * add other contracts * changelog * fix chain to wait tx from * revert: force rescan if inbound vote monitoring fails (#4250) * feat: refund a portion of remaining unused tokens to user (#3734) * add new field to cctx structure to track user gas burned * add unit tests * add doc * add unit test for migration * add check for pre upgrade cctxs * add older logic for handling cctxs created before upgrade * remove LegacyChainParams * add unit test for refund gas fee * remove old migration * add temp note for PR review * fix typo * fix typo * generate files * add missing test case * add missing test case * refactor based on comments * update EtherWithdrawRestricted test * update EtherWithdrawRestricted test * update EtherWithdrawRestricted test * enable all tests * update module version for observer migration * generated docs * generated docs * remove deprecated comments * use older chainparams for upgrade tests * use older chainparams for upgrade tests * changes based on comments 1 * add addition param to CallZRC20Deposit * update comments for legacy cctx and refactor unit tests to use the parent function ManageUnusedGasFee * adjust non zevm chain test cases * fix lint errors * fix comments and rebase develop * add statement to ErrParamsStabilityPoolPercentage * Update x/crosschain/keeper/msg_server_vote_outbound.go Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * fix comments 3 * rebase develop 2 * rebase develop 2 * update admin test --------- Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * test: add zetaclient only upgrade tests (#4310) * add file based trigger for zetaclient binary download * update zetae2e * add new makefile commands * update comments * remove wait for upgrade height * upgrade contracts on zetaclient test * fixes 1 * add issue to track sui upgrade tests * add issue to track sui upgrade tests * add nosec * fix(`zetatool`): add missing networks (#4424) * add missing networks * add worldchain config * add world chain to unit tests * update tests * add zetaclient changes from main * disable e2e tests not working in the first test run * set light upgrade tests as default for zetaclient label * update rpc import * update contract copy * fix update for removing nonces only if the tx is finalized * fix update for removing nonces only if the tx is finalized * update changelog * rebase develop * rebase develop * generate files * reduced upgrade height for connector-migration-test * update comment for tss migration test --------- Signed-off-by: yinwenyu6 <yinwenyu6@outlook.com> Signed-off-by: pxwanglu <pxwanglu@icloud.com> Signed-off-by: wmypku <wmypku@outlook.com> Signed-off-by: tzchenxixi <tzchenxixi@icloud.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: keeghcet <keeghcet@outlook.com> Signed-off-by: fengyuchuanshen <fengyuchuanshen@outlook.com> Signed-off-by: joemicky <joemickychang@outlook.com> Signed-off-by: zhoujiaweii <zjwustc@outlook.com> Signed-off-by: quantpoet <quantway@outlook.com> Signed-off-by: russcoss <russcoss@outlook.com> Co-authored-by: 0xM3R <omer@zetachain.com> Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: morde08 <peter@zetachain.com> Co-authored-by: skosito <skostic9242@gmail.com> Co-authored-by: yinwenyu6 <yinwenyu6@outlook.com> Co-authored-by: pxwanglu <pxwanglu@icloud.com> Co-authored-by: wmypku <wmypku@outlook.com> Co-authored-by: tzchenxixi <tzchenxixi@icloud.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Renan <renan.061@gmail.com> Co-authored-by: keeghcet <keeghcet@outlook.com> Co-authored-by: fengyuchuanshen <fengyuchuanshen@outlook.com> Co-authored-by: Renan <renan@zetachain.com> Co-authored-by: joemicky <joemickychang@outlook.com> Co-authored-by: zhoujiaweii <zjwustc@outlook.com> Co-authored-by: quantpoet <quantway@outlook.com> Co-authored-by: russcoss <russcoss@outlook.com>
* fix: use evm chain id from eth config in rpc backend (#4096)
* fix: cancel solana WaC if tx size is too large (#4098)
* cancel solana WaC if tx size is too large
* align the comments with the code
* fix: nil reference in trace block (#4093)
* chore : bump cosmos evm to support querying legacy proposals of type MsgUpdateParams (#4095)
* update zeta evm
* update commit
* update to commit be548f7691876e656ec61aa46e31ed337be92f4e , on branch release/v34
---------
Co-authored-by: morde08 <peter@zetachain.com>
* fix: remove store initilization for erc20 module (#4103)
* fix(v34-only): use SAFE confirmation mode for all inbound votes (#4117)
* use SAFE confirmation mode for all inbound votes
* move confirmation mode update logic right before signing the inbound vote message
* fix: port Bitcoin memo decoding error log print to v34 (#4100)
port PR 4090 to v34
* fix: backport dbg trace block by number gas limit legacy (#4119)
* fix: backport error when deploying contracts on testnet (#4120)
* refactor(backport): overwrite consensus config values for all timeout deltas on startup (#4126)
* feat: add conditional logic for adding erc20 module based on chain id (#4125)
* add conditional logic for erc20 module upgrade
* bump cosmos version to run evm migration 6 to 7
* add unit tests
* update handler to panic
* add changelog
* format files
* update changelog
* bump cosmos/evm to release/v35
* add back comments for IBC
* add back comments for IBC
* feat(backport/v36): make the gas limit used for gateway calls on ZEVM a configurable parameter (#4154)
* cherry pick
* cherry pick
* update unit tests
* update unit tests
* cherry pick
* replace big int with uint64
* add check of older value
* update upgrade test and changelog
* fix function call
* add v4 migration back for authority module
* add v4 migration back for authority module
---------
Co-authored-by: Tanmay <tanmay.bhattacharya.smit@gmail.com>
* fix: skip writing config file to the filesystem (#4206)
* skip writing config file
* use the value of skip-config-overwrite flag without restrictions for mainnet
* add comments
* remove unused functions
* remove unit tests for unused functions
* fix(backport/v36): unpack bitcoin revert message without considering 'CallOnRevert' flag (#4181)
* unpack revert message from Bitcoin memo without considering flag
* skip incompatible e2e test to allow CI upgrade test to pass
* fix(backport): force rescan if inbound vote monitoring fails using a context that can timeout (#4202)
* backport changes for rescan logic
* remove changelog
* format files
* use context with timeout
* change error message
* cherry pick changes for context with timeout
* format package and fix lint
---------
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* chore(backport/v36): cherry pick e2e tests changes for live networks (#4220)
* fix: add a simple check for finalizing vote (#4236)
* revert: add a simple check for finalizing vote (#4240)
Revert "fix: add a simple check for finalizing vote (#4236)"
This reverts commit d8dc5bac363cbfeb8267705a378fc5a7803e24df.
* revert: force rescan if inbound vote monitoring fails using a context that can timeout (#4241)
Revert "fix(backport): force rescan if inbound vote monitoring fails using a…"
This reverts commit 70ab2a724f96bcf48d2ece29674a8bfbf9bb4469.
* fix(e2e): check test contracts deployment (#4252)
* fix(e2e): check test contracts deployment
* add other contracts
* fix chain to wait tx from
* fix check
* docs: add release lifecycle in the documentation (#4265)
* add a note for releases
* add release lifecycle docs
* refactor: omit unnecessary reassignment (#4264)
Signed-off-by: letreturn <letreturn@outlook.com>
Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com>
* refactor(backport): standardize zetaclient logging (#4144) (#4267)
* chore: remove unused DynamicTicker from zetaclient/types
* refactor: remove Msgf and refactor zerolog uses
* Replace Msgf for Msg
* Use '_' instead of '.'
* Start logs with lowercase instead of uppercase characters
* Use the constants in the logs module
* Use With().Logger() instead of log fields when possible
* fix(backport): remove duplicate solana post-gas-price goroutine (#4194) (#4268)
* refactor(backport): remove unused loggers and log fields (#4180) (#4269)
* chore: remove unused Headers logger
* refactor: remove (mostly) unused GasPrice logger
* refactor: replace logs.FieldMethod with With().Caller() and standardize logs.FieldModule values
* refactor: remove (mostly) unused log fields FieldTracker and FieldConfirmationMode
* refactor: replace missed log instances of '.' for '_'
* refactor(backport): add documentation for ZetaClient logging fields (… (#4270)
refactor(backport): add documentation for ZetaClient logging fields (#4174)
* refactor: use coin.CoinType for compliance logging
* refactor: add documentation for zetaclient logging fields
* chore: fix some function names (#4273)
Signed-off-by: yajianggroup <yajianggroup@outlook.com>
* refactor(backport): prepare the client interfaces used by the observe… (#4271)
refactor(backport): prepare the client interfaces used by the observer-signers for dry-mode (#4213)
refactor: prepare the client interfaces of the observer-signers for dry-mode
* refactor: replace the deprecated function in the ioutil package (#4275)
Signed-off-by: mickychang9 <mickychang9@outlook.com>
* feat: multiple evm calls (#4274)
* multiple evm calls in single tx
* gen testdappv2
* cleanup after merge
* ensure gateway proxy is deployed in e2e tests
* fix upgrade tests
* changelog
* PR comments
* feat: add dry-mode support for TON (#4277)
* feat: add dry-mode support for TON
* fix: address review comments
* ci: increase timeout for solana e2e tests (#4276)
* Increase timeout for solana e2e tests
* Remove timeout, but run the test one hour earlier.
* extend timeout for solana
* feat: add feature flag for multiple evm calls (#4288)
* add feature flag for multiple evm calls
* add feature flag to inbound tracker processing
* fix e2e test inbound trackers
* PR review and refactoring
* add todo with issue
* changelog
* use zetae2e ante for upgrade tests
* chore: increase upgrade test height (#4303)
* chore: increase upgrade test height
* test even higher block
* try 300 block height
* refactor: add `zrepo` package to zetaclient with dry-mode (#4296)
refactor: add zrepo package to zetaclient with dry-mode
* ci: remove upgrade tests from merge queue ci (#4309)
* test(`e2e`): improve local stress tests to replicate better live networks (#4293)
* update params
* fix gas limit
* set gas limit to 4m in localnet
* add high usage test
* typo
* set mem pool
* add stress zevm test
* some tests
* send zevm stress tx as batch
* add batch support
* revert back local config
* chore: add Solana to start-localnet to allow to run local tests
* add sui and ton
* improve eth withdraw stress
* use batch model for deposit stress tests
* improve retry logic
* remove unnecessary logs
* fix lint
* fix deposit
* changelogs
* add nosec
* Update changelog.md
Co-authored-by: skosito <skostic9242@gmail.com>
* apply comments
* use deposit and call
* fix last comments
* use 50m for block size
* revert back 30m block
---------
Co-authored-by: skosito <skostic9242@gmail.com>
* chore: fix inconsistent function name in comment (#4297)
Signed-off-by: russcoss <russcoss@outlook.com>
* fix: stop ProcessOutboundTrackers from breaking when it finds an error (#4305)
* feat: localnet monitoring and observability improvements (#4314)
* make PR against develop branch
* add monitoring profile to makefile
* update dashboards
* update grafana image
* fix dashboards
* update namespace to cometbft
* fix dashboard typo
* update dashboard defaults
* fix: adjust inbound retry gas limit; stop broadcasting tx if mempool is congested or base fee too high (#4291)
* adjust inbound retry gas limit; stop broadcasting tx if mempool is congested
* add changelog entry
* use write lock for delete
* add unconfirmed txs count to config and AppContext; skip observation if mempool is congested
* rename functions
* improve naming and documentation; add log print when skipping observation
* add detailed description for inbound retry gas limit adjustment
* do not consider zetacore mempool congestion by default
* consolidate observation skipper functions; print sampled Info logger when observation is skipped
* unit test observation skipper
* rename Bitcoin mempool monitoring goroutine and improve observation skipper description
* configure maximum base fee
* fix gas price observation skipper
* convert Gwei to wei for the max base fee check
* add changelog description for MaxBaseFee
* fix unit test compile
* fix unit test
* feat: add support for Solana Address Lookup Table in withdraw and call (#4266)
* add support for ALT
* split legacy withdraw and call alt to separate test
* fix compile after merge
* add spl e2e test
* ci fixes
* add outbound tests for alt msgs
* PR comments coderabbit
* PR comments
* add feature flag for solana alt
* lint
* fix e2e test
* fix e2e test
* PR comments
* Trigger rebuild
* feat: monitor failed inbound vote and add to an inbound tracker cache (#4295)
* partially cherry-pick PR 4183 and 4196 to monitor failed inbound vote
* implement the backlog for failed inbound vote
* add changelog entry
* fix changelog grammar
* use the internal tracker terminology; use separate goroutine to process internal trackers
* fix internal tracker unit test and update changelog description
* put a limit on number of inbound trackers to process per ticker
* remove unused constant
* fix generte
* remove internal tracker if it was already voted by the observer
* fix unit test
---------
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* feat: add dry-mode to Sui and add client wrappers to Sui and TON (#4313)
* feat: add dry-mode to Sui
* refactor: add client wrappers to Sui and TON
* refactor: improve logging messages and code comments
* feat: add dry-mode to Solana (#4317)
* chore: adding ABI used by precompiles. (#4311)
* Adding ABI for precompiles
* added readmes
* refactor: use maps.Clone to simplify code (#4319)
Signed-off-by: yajianggroup <yajianggroup@outlook.com>
* chore: fix some comments (#4331)
Signed-off-by: letreturn <letreturn@outlook.com>
* test(e2e): update local chain params for more performant outbound processing (#4318)
* remove useless comment
* improve parameters
* update for local bitcoin
* increase max block size
* revert chain param changes
* update chain params in e2e setup
* feat: add dry-mode to Bitcoin (#4325)
* feat: add dry-mode to EVM (#4326)
* feat: add TSS client dry-wrapper (#4330)
* chore: upgrade cometbft patch version (#4337)
* chore: upgrade cometbft patch version
* chore: run go mod tidy
* refactor: set verbose logs for event parsing error as debug (#4345)
* change invalid event to debug
* skip ton log if zero logs
* generate
* chore(deps): bump github.com/go-viper/mapstructure/v2 from 2.2.1 to 2.4.0 (#4334)
chore(deps): bump github.com/go-viper/mapstructure/v2
Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.2.1 to 2.4.0.
- [Release notes](https://github.com/go-viper/mapstructure/releases)
- [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.4.0)
---
updated-dependencies:
- dependency-name: github.com/go-viper/mapstructure/v2
dependency-version: 2.4.0
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps): bump github.com/ulikunitz/xz from 0.5.11 to 0.5.14 (#4333)
Bumps [github.com/ulikunitz/xz](https://github.com/ulikunitz/xz) from 0.5.11 to 0.5.14.
- [Commits](https://github.com/ulikunitz/xz/compare/v0.5.11...v0.5.14)
---
updated-dependencies:
- dependency-name: github.com/ulikunitz/xz
dependency-version: 0.5.14
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps): bump github.com/hashicorp/go-getter from 1.7.8 to 1.7.9 (#4332)
Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.7.8 to 1.7.9.
- [Release notes](https://github.com/hashicorp/go-getter/releases)
- [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml)
- [Commits](https://github.com/hashicorp/go-getter/compare/v1.7.8...v1.7.9)
---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-getter
dependency-version: 1.7.9
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* test: skip spawning Solana and Sui for ETH stress tests (#4346)
* update docker compose
* update init condition
* fix: update zetachain-exporter to v4.11.0 for localnet support (#4341)
* update zetachain-exporter to v4.11.0 for localnet support
* Update Makefile
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* chore: add precompile metadata for blockscout explorer (#4350)
* Adding ABI for precompiles
* added readmes
* updated metadata for bs
* fixed precompile version in metadata
* fixed abi format
* fixed compiler version
* test: fix eth stress test timeout (#4321)
* fix eth stress test timeout
* decrease default mempool threshold
* add minimum retry interval logic to internal tracker
* set PostVoteInboundGasLimit back to 500K; set block max gas to 50M
* avoid adding finalized or voted ballot to internal tracker cache
* rename DefaultMempoolSize as DefaultAppMempoolSize
* add changelog entry
* update time stamp only for first MaxInboundTrackersPerScan internal trackers
* print RPC error logs from ballotIsFinalizedOrVoted instead of ignore
* chore: upgrade cometbft patch version (#4337)
* chore: upgrade cometbft patch version
* chore: run go mod tidy
* refactor: set verbose logs for event parsing error as debug (#4345)
* change invalid event to debug
* skip ton log if zero logs
* generate
* chore(deps): bump github.com/go-viper/mapstructure/v2 from 2.2.1 to 2.4.0 (#4334)
chore(deps): bump github.com/go-viper/mapstructure/v2
Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.2.1 to 2.4.0.
- [Release notes](https://github.com/go-viper/mapstructure/releases)
- [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.4.0)
---
updated-dependencies:
- dependency-name: github.com/go-viper/mapstructure/v2
dependency-version: 2.4.0
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps): bump github.com/ulikunitz/xz from 0.5.11 to 0.5.14 (#4333)
Bumps [github.com/ulikunitz/xz](https://github.com/ulikunitz/xz) from 0.5.11 to 0.5.14.
- [Commits](https://github.com/ulikunitz/xz/compare/v0.5.11...v0.5.14)
---
updated-dependencies:
- dependency-name: github.com/ulikunitz/xz
dependency-version: 0.5.14
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps): bump github.com/hashicorp/go-getter from 1.7.8 to 1.7.9 (#4332)
Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.7.8 to 1.7.9.
- [Release notes](https://github.com/hashicorp/go-getter/releases)
- [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml)
- [Commits](https://github.com/hashicorp/go-getter/compare/v1.7.8...v1.7.9)
---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-getter
dependency-version: 1.7.9
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* test: skip spawning Solana and Sui for ETH stress tests (#4346)
* update docker compose
* update init condition
* fix: update zetachain-exporter to v4.11.0 for localnet support (#4341)
* update zetachain-exporter to v4.11.0 for localnet support
* Update Makefile
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* chore: add precompile metadata for blockscout explorer (#4350)
* Adding ABI for precompiles
* added readmes
* updated metadata for bs
* fixed precompile version in metadata
* fixed abi format
* fixed compiler version
* renan comments
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: morde08 <peter@zetachain.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Charlie <31941002+CharlieMc0@users.noreply.github.com>
* feat: add dry-wrappers to zetacore client (#4323)
* feat: add dry-wrappers to zetacore client
* fix: address reviews
* fix: iterate all sui outbound tracker hashes (#4340)
* iterate all sui outbound tracker hashes
* add changelog entry
* remove log message by using Send
* feat: missing fields in msg hash for solana outbounds (#4328)
* missing fields in msg hash for solana outbounds
* changelog
* lint
* update gateway so file
* feat: add dry-mode configuration (#4348)
* feat: add mode option in ZetaClient configuration
* fix: address reviews
* test: fix too many internal trackers in 'start-stress-test-eth' (#4351)
* fix many internal trackers in eth stress test
* add changelog entry
* add description for newly added constant for readibility; improve changelog
* test: add tests related to dry-mode (#4347)
* feat: add metrics for monitoring inbound voting through blockscan and trackers (internal / external) (#4342)
* update metric definations
* add metrics update
* update comments for evm
* add unit test for metrics
* add changelog
* update comments
* format files
* update naming
* add a grafana dashboard for localnet
* update dashboard
* add section for internal trackers
* update docker compose
* update prometheus to scrape data from all zetaclient nodes
* update susccess rate
* use absent in success rate
* make success rate simpler
* remove monitoring for e2e test
---------
Co-authored-by: Renan <renan@zetachain.com>
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* ci: create a separate release workflow for zetaclient and zetacore (#4329)
* publish release actions
* gorelease new files
* fix security warning
* fix coderabbit comments
* reorganize workflow
* Update .github/workflows/release-template.yml
Co-authored-by: semgrep-code-zeta-chain[bot] <181804379+semgrep-code-zeta-chain[bot]@users.noreply.github.com>
* Update .github/workflows/release-template.yml
Co-authored-by: semgrep-code-zeta-chain[bot] <181804379+semgrep-code-zeta-chain[bot]@users.noreply.github.com>
---------
Co-authored-by: semgrep-code-zeta-chain[bot] <181804379+semgrep-code-zeta-chain[bot]@users.noreply.github.com>
* chore: fix function name in comment (#4364)
Signed-off-by: vastonus <vastonus@outlook.com>
* feat: add support for zetaclient external DNS name (#4254)
* add support for zetaclient external DNS name
* add changelog entry
* point to go-tss tag; fix changelog PR # and add zetaclient config description
* add zetaclient config file validation method
* chore: Update Twitter link to new handle (#4366)
* refactor: set propose/prevote/precommit delta timeouts to 200ms (#4360)
* Initial plan
* consensus: set timeout_*_delta to 200ms in test/localnet configs
Co-authored-by: CharlieMc0 <31941002+CharlieMc0@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: CharlieMc0 <31941002+CharlieMc0@users.noreply.github.com>
Co-authored-by: morde08 <peter@zetachain.com>
* feat: Sui message context ID as dynamic field (#4127)
* backport PR 4087 to v35
* fix CI upgrade test
* fix unit test
* avoid wrapping nil error
* update the TODO comment for broken Sui e2e test in the upgrade
* feat: observe inbound from previous gateway package after upgrade (#4182)
* backport PR 4087 to v35
* fix CI upgrade test
* fix unit test
* avoid wrapping nil error
* backport PR 4138
* fix compile error
* add support for previous package deprecation; fix upgrade test and unit test
* add a note to clarify the PackageID argument used for event query
* add documents to explain Sui gateway address format in the chain params
* update the TODO comment for broken Sui e2e test in the upgrade
* chore: remove repetitive words in comment (#4353)
Signed-off-by: withtimezone <with_timezone@outlook.com>
Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com>
* chore: combine metadata file for precompile ABI (#4369)
* adding combined file for BS
* adding combined file for BS
* docs: add documentation for ZetaClient execution modes (#4358)
* docs: add documentation for ZetaClient execution modes
* fix: address reviews
* docs: add version table and update release process (#4365)
* revamp version file
* update links
* add a few links
* update release lifecycle do
* Apply suggestion from @coderabbitai[bot]
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* apply comments
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* refactor: replace mock generation with (broadned) Go file generation (#4367)
* fix(monitoring): update zetachain-exporter to fix bug with localnet mode (#4370)
add signer sync localnet dashboard, fix bug with localnet mode for zetachain-exporter
* fix: upgrade test on develop (#4375)
* remove default gas limit from genesis
* fix keygen in upgrade test
* fix lint
---------
Co-authored-by: Charlie Chen <charliec@zetachain.com>
* test(e2e): json rpc checks during e2e and upgrade tests (#4357)
* add e2e test to check most important rpc methods before and after upgrade
* ci fixes
* lint
* PR comments
* PR comments
* test(backport): add zetaclient only upgrade tests (#4376)
* add zetaclient upgrade tests
* update comment
* use temp file
* refactor: upgrade protocol contract to repo `protocol-contracts-evm` and v15 (#4356)
* update go mod
* update all imports
* update go mod
* fix binding and comment some tests
* conflicts fixes
* changelogs
* disable zeta v2 e2e tests
* disable e2e test for zeta v2
* conflict fixes
* upgrade contract version
* update commit -
* update commit with release
* feat: disable TSS service in dry mode (#4384)
* fix: filter out nil address to prevent error logs (#4386)
* filter out nil address to filter nil connections
* add changelog
* feat: add chaos mode (#4359)
* feat: add chaos mode
* fix: address reviews (kingpinXD)
* fix: address reviews (lumtis)
* ci: fix duplicate env in the release workflow (#4385)
fix env error
* feat: shutdown zetaclient if zetacore is in syncing status (#4362)
* add a listner to check sync status
* add oncomplete
* add changelog
* add unit test
* add comments
* rebase develop
* rebase develop
* update function name to wait until syncing
* update function name to wait until syncing
* add unit test
shutdown cancelled if zetacore stops syncing before timeout
* increase assert timer for test
* Update zetaclient/maintenance/shutdown_listener.go
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
---------
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* feat: add number of connected peers to tss keygen log (#4378)
* add number of peers to keygen log
* update pr id
* update log output
* update log output
* reset to older log lines
* generate files
* refactor: base validation on zetaclient config file (#4361)
* add support for zetaclient external DNS name
* add changelog entry
* point to go-tss tag; fix changelog PR # and add zetaclient config description
* add zetaclient config file validation method
* add basic validation on zetaclient config file
* add changelog entry
* add description to zetaclient config unit test and minor improvement
* standardize config file error message format
* configure cosmos sdk config in zetaclient supervisor and unit test
* fix format
* fix CI simulation test
* feat: Add test binaries build workflow (#4383)
* feat: Add test build release workflow
* test
* fix: make
* feat: add checks and notifs
* fix: refactor
* feat: refactor into multiple jobs
* fix: refactor
* fix: add description comment
* fix: remove bucket name from summary
* test: update e2e to set higher timeouts when running stress test (#4395)
* update to using higher timeouts when running stress tests
* add changelog
* docs: update matrix table with new released versions (#4390)
* update matrix table
* add note for release
* update last updated
* comments
* chore: remove repetitive words (#4388)
* chore: remove repetitive words
Signed-off-by: findmyhappy <findhappy@sohu.com>
* Update .github/workflows/semgrep.yml
Co-authored-by: Renan <renan.061@gmail.com>
---------
Signed-off-by: findmyhappy <findhappy@sohu.com>
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
Co-authored-by: Renan <renan.061@gmail.com>
Co-authored-by: Renan <renan@zetachain.com>
* feat: add new dry zetaclient to localnet (#4387)
* feat: add new dry zetaclient to localnet
* fix: address reviews (lumtis)
* fix: address reviews (skosito)
* refactor: change client mode config (#4391)
* refactor: change client mode config
* fix: address reviews (skosito)
* fix: address reviews (lumtis)
* fix: address reviews (coderabbitai)
* fix: address reviews (lumtis)
* ci: fix branch name rule to include all release branches (#4398)
ci(backport/zetaclient_v37): fix branch name rule to include all release branches
* docs: add documentation for gas and fees with ZetaChain (#4394)
* recreate docs
* add link to readme
* start deposit sections
* add bitcoin fee
* Update docs/zetacore/gas_and_fees.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Update docs/zetacore/gas_and_fees.md
Co-authored-by: Renan <renan@zetachain.com>
* Update docs/zetacore/gas_and_fees.md
Co-authored-by: Tanmay <tanmay@zetachain.com>
* apply comments
* add Solana network fees
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Renan <renan@zetachain.com>
Co-authored-by: Tanmay <tanmay@zetachain.com>
* fix: wrong error usage for aborted cctx error message (#4405)
* chore: fix some typos in comments (#4409)
Signed-off-by: claudecodering <claudecoder@outlook.com>
* test: add chaos mode capabilities to zetaclient localnet (#4408)
* feat: add chaos mode capabilities to zetaclient localnet
* fix: address reviews (coderabbitai)
* fix: address reviews (lumtis)
* feat: Add ref to test binaries workflow (#4410)
* feat: Add ref to test binaries workflow
* docs: move to further reading section
* fix: load inbound cursors for each supported packages from db (#4403)
* load inbound cursors for each packages from database
* add changelog entry
* fix: retry Sui inbound if the inbound vote RPC failed (#4401)
* do not skip inbound when vote inbound RPC failed
* add changelog entry
* wraps two errors into one without convert the second into string
* chore(deps): bump github.com/consensys/gnark-crypto from 0.16.0 to 0.18.1 (#4404)
chore(deps): bump github.com/consensys/gnark-crypto
Bumps [github.com/consensys/gnark-crypto](https://github.com/consensys/gnark-crypto) from 0.16.0 to 0.18.1.
- [Release notes](https://github.com/consensys/gnark-crypto/releases)
- [Changelog](https://github.com/Consensys/gnark-crypto/blob/v0.18.1/CHANGELOG.md)
- [Commits](https://github.com/consensys/gnark-crypto/compare/v0.16.0...v0.18.1)
---
updated-dependencies:
- dependency-name: github.com/consensys/gnark-crypto
dependency-version: 0.18.1
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore: fix the inconsistent method names in the comments (#4421)
Signed-off-by: rustversion <rustverion@outlook.com>
* feat: add devnet command to create a fork from existing node data (#4419)
* refactor start command
* update error messages
* update error messages
* generate files
* modify slashing info
* update node shutdown to add grace duration
* add changelog
* add changelog
* generate files
* start json rpc server in sync
* add python script to start a forked node
* replace fmt.Errorf with error.wrap
* rename import to codectypes
* rename testnet to devnet
* rename testnet to devnet
* generate files
* fix gosec warnings
* ignore close error for cleanup
* chore: fix a large number of spelling issues (#4432)
* chore: fix a large number of spelling issues
Signed-off-by: tinyfoolish <tinyfoolish@outlook.com>
* Update cmd/zetatool/cli/cctx_tracker.go
* Update e2e/e2etests/test_bitcoin_deposit_and_withdraw_with_dust.go
* Update e2e/e2etests/test_bitcoin_deposit_and_withdraw_with_dust.go
---------
Signed-off-by: tinyfoolish <tinyfoolish@outlook.com>
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* fix: temporarily disable zetaclient public DNS usage to avoid start failure (#4434)
* temporarily disable zetaclient public DNS usage
* add changelog entry
* Update changelog.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* chore: bump sol contracts with remove max payload check change (#4416)
bump sol contracts to remove max payload check
* refactor: replace interface{} with any for clarity and modernization (#4435)
Signed-off-by: sunnyraindy <sunnyraindy@outlook.com>
* fix: resolve IP address from public DNS and then pass it to go-tss (#4437)
* resolve IP address from public DNS and then pass it to go-tss
* add changelog entry
* sort IP addresses to be deterministic
* return error if both public IP or DNS are missing
* clean up TODO github link
* feat: add an option to trigger upgrade script after forking a network (#4428)
* refactor start command
* update error messages
* update error messages
* generate files
* modify slashing info
* update node shutdown to add grace duration
* add changelog
* add changelog
* generate files
* start json rpc server in sync
* add optional upgrade trigger
* add python script to start a forked node
* replace fmt.Errorf with error.wrap
* rename import to codectypes
* update python script to include upgrade trigger
* cache testnet snapshot for testing
* add upgrade scheduling to devnet
* use dvent for upgrade script
* add unit test for download info
* suppress nosec warnings
* ignore error on cleanup
* add os to the downloadInfo json
* add a constant for DefaultUpgradeHeighOffset
* fixes for comments
* added checksum to the sample script
* fix: update effective gas price calculation (#4443)
* update effective gas price calcualtion
* fix unit tests
* add changelog
* update comments
* add explicit error handling for all tx types that support EIP 1559 style gas prices
* set nil value for effective gas price
* undo setting effective gas price to nil
* test: add new chaos mode profiles (#4440)
* test profiles
* fix solana chaos test
* add back generated files
* add back generated files
* add changelog
* use any instead of interface
* fix naming
* add chaos stress test
* fix: fix Sui example deployment by removing gateway object reference (#4414)
* remove gateway object reference from Sui example package
* add changelog entry
* remove unused error from sui example
* feat: a sequential batch TSS keysign scheduler for EVM chain (#4427)
* initial PoC of batch keysign for eth chain
* add comments in functions; consolidate AddKeysignInfo and GetSignature into one method
* improved code quality using separate files; refined batch keysign logic
* refined batch keysign logic to achieve stable performance
* use TSS nonce as starting point for keysign; improve code description
* use artificial height for batch keysign
* remove cctx height from keysign information
* improve function name and comments
* add changelog entry and update existing unit tests
* fix gosec and lint
* remove unused height; remove unused context from evm signer methods; improve comment
* add unit tests for batch keysign and tss service
* add a few more log messages in batch keysign
* add a few more fields to batch keysign log messages
* loop directly on nonce range other than on map
* split func PrepareForKeysign into two separate method, one for reading one for writing
* refactor: omit unnecessary reassignment (#4447)
Signed-off-by: liuyueyangxmu <liuyueyangxmu@outlook.com>
* test: update tss migration test migrate btc fund in two chunks (#4463)
* migrate btc funds twice
* update spacing to fix lint
* add comment to explain reason for chunking BTC funds migration
* fix: accept uppercase receiver address in Bitcoin withdrawal (#4471)
* allow uppercase receiver address in Bitcoin withdrawal
* add changelog entry
* test: add separate versions for zetaclient ,zetacore and zetae2e binaries when used in e2e tests (#4476)
* create an optional alternate version for zetaclient in upgrade tests
* create an optional alternate version for zetaclient in upgrade tests
* Update changelog.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* use old version for zetacored version directly
* ignore overwrite errors for config file
* split versioning for zetacored ,zetaclient and zetae2e
* simplify second run check
* update changelog
* update changelog
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* test: prevent zetaclient from running if minimum version check failed (#4474)
* add e2e test for zetaclient minimum version
* block zetaclient to run if minimum version is not set
* revert the check on empty minimum version
* add changelog entry
* continue monitoring if operational flags RPC query failed
* docs: update protocol contracts EVM link in readme (#4458)
* feat: add MsgRemoveObserver (#4479)
* add tss migration for remove obdservers
* update tests and add changelog
* use uint for len of observer set
* remove stree for add observers
* set last update height for observer set
* add check for len of observer set in e2e test
* make TSS_MIGRATION_FLAG optional
* feat: add an option to create zetaclient dry node for tesntet/mainnet (#4453)
* add shell script to demonstrate zetaclient-dry
* verify zetacore and zetaclient binaries
* docker testnet node
* refactor zetaclient dry to use python entrypoint and make it configurable
* remove config
* add rpc nodes
* add changelog
* add changelog
* update comments
* update puthon scripts to use toml files directly
* simplify logic in scripts
* simplify logic in scripts
* copy scripts into docker container directly
* add profile to testnet and mainnet nodes
* add separate versioning for dry containers
* chore: fix some spelling issues in comments (#4480)
Signed-off-by: xiaolinny <xiaolincode@outlook.com>
Co-authored-by: morde08 <peter@zetachain.com>
* test: add sui to tss migration tests (#4488)
* add tss migration for sui
* add changelog
* debug changes
* update message context
* update comments
* remove unused functions
* feat: change params for 2s block time (#4484)
* change params for 2s block time
* changelog
* remove todo
* change default params
* test fixes
* fix migration test
* fix distributions test
* feat: Add action to build & push zetanode image internally (#4482)
* feat: Add action to build zetanode and deploy in dry-run mode
* Add pr trigger
* fix: remove snapshotter
* add pr trigger
* try new flow
* test docker availability
* fix variables and refactor
* add test to tag
* update action
* trigger
* push latest only if no version
* revert to version
* fix: remove PR trigger
* fix: concurrency and fallback
* fix: Add timeout and cleanup
* feat: enable ALT in solana inbounds (#4493)
* enable ALT in solana inbounds
* lint
* changelog
* PR comments
* fmt
* run ci
* fix: bring back the support for tracerConfig object in zevm debug API (#4490)
* bring back the support for tracerConfig object in evm debug API
* add changelog entry
* add unit test for traceConfig object
* fix: port sui outbound schedule interval (#4509)
* fix: sui outbound schedule interval (#4506)
* changelog
* fix: false mempool is congested warning (#4511)
* fix false mempool is congested warning
* changelog
* PR comment
* PR comment
* fix(backport): reindex txlogs if duplicate indexes are present (#4498)
* update needs reindex function to check for log index across all groups
* add changelog
* use uint for index
* test: add e2e test to replace observer (#4503)
* add e2e test to replace observer
* update changelog
* add replace observer label check
* fix: Add solana image dependency
* Update cmd/zetae2e/local/replace_observer.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* add a comments to improve readibilty
---------
Co-authored-by: Hazim <hazim_malik@hotmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* test: add-ton-tss-migration (#4491)
* add tss migration for sui
* add changelog
* debug changes
* update message context
* update comments
* remove unused functions
* add ton to tss migration
* update comments
* update backoff
* update wait blocks for sui
* chore: fix function name in comment for batchLogger (#4504)
Signed-off-by: boqishan <boqishan@126.com>
Co-authored-by: Tanmay <tanmay@zetachain.com>
* feat: add migration script to add an authorization for MsgRemoveObserver (#4492)
* add migration script
* updae changelog
* feat: add a tool to list tss balances across all supported chains (#4507)
* add tss balance check
* update to using supported chains list from network
* update comments
* remove sample config file from repository
* update identifier chainRpc to chainRPC
* feat: move gas price multiplier to chain params (#4485)
* move gas price multiplier to chain params
* add changelog entry
* add breaking change description in changelog
* fix nil chainParams check in migration script; fix typo and make gas multiplier validation less strict; update changelog
* describe the impact of newly added field gas multiplier; fix typo in zetatool inbound
* fix unit test
* chore: merge main into develop (#4512)
* fix: ratelimiting race condition vuln (#4072)
* fix: ratelimiting race condition vuln
* fix: ratelimiting race condition vuln
- Fix race condition in RateLimiter.Release() function
- Replace non-atomic check-then-act with atomic decrement and bounds checking
- Add comprehensive test suite to verify the fix
- Update changelog with PR #4072
* fix: correct atomic implementation to prevent underflow
- Replace flawed Add(-1) approach with proper CompareAndSwap
- Fix underflow detection issue where uint32 wrap-around was missed
- Add TestRateLimiterUnderflowProtection to verify the fix
- Ensure Release() never causes negative counters or semaphore over-release
* refactor: simplify rate limiter Release() implementation
- Remove unnecessary infinite loop in CAS operation
- Single CAS attempt is sufficient for race condition protection
- Maintains thread-safety while being more efficient
- All tests still pass with simplified implementation
* fix: correct order of operations in rate limiter Release()
- Fix race condition by decrementing counter before releasing semaphore
- Ensure pending counter accurately reflects semaphore state
- Simplify implementation by using correct operation order
- All tests pass with cleaner, more logical approach
* test: add tests that reproduce the original race condition vulnerability
- Add BuggyRateLimiter that implements the original vulnerable code
- Add TestBuggyRateLimiterRaceCondition to demonstrate the race condition
- Add TestBuggyRateLimiterStressTest to stress test the vulnerability
- Add TestVulnerabilityDemonstration to show before/after comparison
- Add TestBuggyRateLimiterExcessiveReleases to show excessive release issues
- These tests demonstrate the theoretical vulnerability even if timing makes it hard to reproduce consistently
* fix: address race condition and underflow issues in RateLimiter
- Fix race condition in Release() by reordering operations (decrement pending first, then release semaphore)
- Fix Pending() function to handle negative atomic.Int32 values correctly
- Add comprehensive tests to verify fixes
- Remove buggy code from tests as requested by reviewers
- Document original vulnerability in test comments
The original race condition allowed multiple goroutines to release more permits than acquired.
The Pending() function could return incorrect values due to negative atomic.Int32 conversion.
Fixes: #4072
* refactor: rename test and update changelog to reflect actual improvements
- Rename TestVulnerabilityDemonstration to TestRateLimiterRobustness
- Update test description to reflect code quality improvements rather than vulnerability fixes
- Update changelog entry to match actual changes
- Tests still pass, confirming the improvements are working correctly
The reviewer correctly pointed out that if tests pass on develop without fixes,
then we're improving robustness rather than fixing vulnerabilities.
* refactor: remove support for v1 revert address for BTC (#4070)
* remove support for v1 revert address for BTC
* add changelog
---------
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* feat: add support for withdraw using v2 connector contract (#4064)
* update go mod
* add a new message for migrating funds
* add migrate funds to e2e
* rebase from develop
* add v2 e2e test to check flow
* add zeta gateway deposit to zetaclient
* add github workflow
* update comments
* fix code formating
* fix code formating
* fix code formating
* fix unit tests
* fix unit tests
* revert to old command to start e2e test
* remove message for migration and refactor to using contract directly
* add changelog
* generate files after removing new message
* update generated files
* update generated files
* update go mod
* update deposit
* add unit tests
* add unit tests
* generate files
* generate files
* undo changes based on develop
* update deposit and revert smart contract call
* rename zeta deposit test file
* rename zeta deposit test file
* add abort and revert tests
* add TestZetaDepositAndCallNoMessage
* add TestZetaDepositAndCallNoMessage
* remove payable from TestAbort contract
* rename to LegacyZETADepositAndCallContract
* improve unit test coverage
* fix unit tests
* add some delay in TestZetacore_SubscribeNewBlocks
* update comment for handling zeta token zrc20
* add e2e test
* add e2e test for withdraw
* refactor ProcessZEVMInboundV2
* add core registry to setup
* refactor e2e test helper functions
* add unit test for zeta withdraw
* add unit test for withdraw and call
* resolve comments 1
* add unit test for ProcessRevert
* add unit test for ProcessRevert
* add unit test for ProcessRevert
* improve abort tests
* improve abort tests
* resolve comments
* resolve comments 2
* update upgrade height to 280 to allow the first test to run the entire cycle
* wrap zeta mints in tmp context
* wrap zeta mint in temp context
* rebase
* add changelog
* add changelog
* adjust comments
* Update cmd/zetae2e/config/contracts.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* fix gas pool zeta calcualation
* add unit test for executeWithMintedZeta
* fix comments 1
* add unit tests
* update test dapp to use zeta token for consuming gas
* add core registry to zeta e2e post upgrade handler
* revert legacy test
* update changes based on comments 1
---------
Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* fix: print error message in detail if unable to decode Bitcoin memo (#4090)
* print error message detail when memo decoding failed
* add changelog entry
* keep invalid memo log on Info level
---------
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* test(e2e): update admin e2e tests to use v2 connector (#4071)
* update go mod
* add a new message for migrating funds
* add migrate funds to e2e
* rebase from develop
* add v2 e2e test to check flow
* add zeta gateway deposit to zetaclient
* add github workflow
* update comments
* fix code formating
* fix code formating
* fix code formating
* fix unit tests
* fix unit tests
* revert to old command to start e2e test
* remove message for migration and refactor to using contract directly
* add changelog
* generate files after removing new message
* update generated files
* update generated files
* update go mod
* update deposit
* add unit tests
* add unit tests
* generate files
* generate files
* undo changes based on develop
* update deposit and revert smart contract call
* rename zeta deposit test file
* rename zeta deposit test file
* add abort and revert tests
* add TestZetaDepositAndCallNoMessage
* add TestZetaDepositAndCallNoMessage
* remove payable from TestAbort contract
* rename to LegacyZETADepositAndCallContract
* improve unit test coverage
* fix unit tests
* add some delay in TestZetacore_SubscribeNewBlocks
* update comment for handling zeta token zrc20
* add e2e test
* add e2e test for withdraw
* refactor ProcessZEVMInboundV2
* add core registry to setup
* refactor e2e test helper functions
* add unit test for zeta withdraw
* add unit test for withdraw and call
* resolve comments 1
* add unit test for ProcessRevert
* add unit test for ProcessRevert
* add unit test for ProcessRevert
* improve abort tests
* improve abort tests
* resolve comments
* resolve comments 2
* update upgrade height to 280 to allow the first test to run the entire cycle
* wrap zeta mints in tmp context
* wrap zeta mint in temp context
* rebase
* add changelog
* add changelog
* adjust comments
* Update cmd/zetae2e/config/contracts.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* fix gas pool zeta calcualation
* add unit test for executeWithMintedZeta
* fix comments 1
* add unit tests
* update admin
* revert unncessary changes
* disable account balance verification for admin tests
* improve naming for deposit functions
* add changelog
* update comments
* update test legacy test zeta to use EVMAddress
* remove skipping admin in upgrade setup
---------
Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* test: fix eth deposit test to check balance after deposit (#4118)
* check balance after eth deposit test
* fix typo
* fix import
* test: fix flaky Solana depositAndCall tests (#4113)
* fix flaky solana depositAndCall tests
* add changelog entry
* add wait logic inside AssertTestDAppEVMCalled
* chore: bump cosmos evm to support querying legacy proposals of type MsgUpdateParams (#4094)
* update zeta evm
* update commit
* fix: use evm chain id from eth config in rpc backend (#4096)
* fix: cancel solana WaC if tx size is too large (#4098)
* cancel solana WaC if tx size is too large
* align the comments with the code
* fix: nil reference in trace block (#4093)
* update to commit be548f7691876e656ec61aa46e31ed337be92f4e , on branch release/v34
---------
Co-authored-by: skosito <skostic9242@gmail.com>
Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com>
Co-authored-by: morde08 <peter@zetachain.com>
* fix: error when deploying contracts on testnet (#4112)
* dont return err if tx is not found in get tx receipt
* fix tests
* changelog
* feat: support hostname in addition to public IP for zetaclient to connect to zetacore (#4068)
* save initial work to remote
* add unit test and live test for zetacore hostname support
* add changelog entry; fix gosec and clean unused code
* fix CI upgrade test
---------
Co-authored-by: Tanmay <tanmay@zetachain.com>
* fix: dbg trace block by number gas limit legacy (#4121)
* fix dbg trace by block
* PR comments
* changelog
* fix(cherry-pick): cancel solana WaC if tx size is too large (#4111)
* cancel solana WaC if tx size is too large
* add changelog entry
* chore: remove tx suffix in vote inbound and outbound message names (#4110)
* fix(`crosschain`): remove confirmation mode from outbound and inbound digest (#4116)
* inbound
* .
* changelog
* refactor(zetacore): overwrite consensus config values for all timeout deltas on startup. (#4097)
* update 1
* add start-skip-consensus-overwrite-test
* generate files
* update tests
* add unit tests
* add unit tests for GenesisChainID
* add unit tests for GenesisChainID
* rename genesisChainID
* fix typo
* remove testnet from overwrite check
* refactor: replace []byte(fmt.Sprintf) with fmt.Appendf (#4131)
Signed-off-by: yinwenyu6 <yinwenyu6@outlook.com>
* feat: Sui message context ID as dynamic field (#4087)
* re-enable sui authenticated call
* integrate message context ID as dynamic field
* add changelog entry
* make issueMessageContext function self-contained
* fix unit test
* remove --skip-dependency-verification in sui gateway upgrade test
* cancel withdrawAndCall on invalid payload
* adopt new increase_nonce signature to adopt gas refund logic when cancelling a CCTX
* apply stringent check on Sui transaction's checkpoint
* apply status check on Sui inbound
* fix CI upgrade test
* fix unit test
* chore: fix some function names in comment (#4129)
Signed-off-by: pxwanglu <pxwanglu@icloud.com>
* chore: fix some observer message names (#4141)
* test: fix flaky Solana SPL deposit balance check (#4142)
* fix solana e2e SPL balance check by waiting maximum 30 seconds
* add changelog entry
* refactor: remove intx and outtx deprecated queries (#4150)
* refactor: remove intx and outtx deprecated queries
* fixes in e2e
* chore: remove redundant word in comment (#4149)
Signed-off-by: wmypku <wmypku@outlook.com>
* test(`e2e`): improve logs for CCTX status assertion (#4147)
* improve require status logs
* update usage in tests
* lint
* cursor comment
* chore: fix some typos in comment (#4146)
Signed-off-by: tzchenxixi <tzchenxixi@icloud.com>
* chore: set v35 as upgrade test reference and various clean up (#4115)
* add back precompiles
* add abci field to proposal
* test
* enable back
* test no creating proposasl
* disable zeta-ante
* cleanup v33 upgrade helper
* add v35 as reference
* remove gas stability pool temporary
* update to v36 and disable fast confirmation test
* bitcoin fast confirmation
* increase ersion for zeta
* remove erc20 init handler
* disable zevm to evm revert for older version
* disable zevm to evm revert abort for older version
* increase upgrade height
* feat: make the gas limit used for gateway calls on ZEVM a configurable parameter (#4153)
* add GatewayGasLimit to state
* refactor function name from MustGetGatewayGasLimit to GetGatewayGasLimitSafe
* update unit tests
* update unit tests
* update proto files
* replace big int with uint64
* changelog
* add check of older value
* add v4 migration back for authority module
* update setup handler to remove setting erc20 module
* test changes
* revert to using v32 as base branch for upgrades
---------
Co-authored-by: lumtis <lucas.bertrand.22@gmail.com>
* test(`e2e`): add a gas limit option for ZEVM to EVM call tests (#4145)
* add gas limit option
* use option for tests
* increase further upgrade height
* test: use pre-deployed example dapp V2 contract in e2e tests (#4158)
* do not deploy example contract in e2e tests, use pre-deployed example dapp V2 instead
* add changelog entry
* clean up debugging log
* remove commented code
* add back extra zrc20 SPL balance check
* chore(`e2e`): cleanup unused contracts (#4161)
* remove contextapp
* remove distribute
* test: fix flaky depositAndCall test that failed on sender assertion (#4165)
* fix flaky depositAndCall caused by sender assertion
* add changelog entry
* chore(deps): bump github.com/hashicorp/go-getter from 1.7.8 to 1.7.9 (#4148)
Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.7.8 to 1.7.9.
- [Release notes](https://github.com/hashicorp/go-getter/releases)
- [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml)
- [Commits](https://github.com/hashicorp/go-getter/compare/v1.7.8...v1.7.9)
---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-getter
dependency-version: 1.7.9
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps): bump github.com/ulikunitz/xz from 0.5.11 to 0.5.14 (#4172)
Bumps [github.com/ulikunitz/xz](https://github.com/ulikunitz/xz) from 0.5.11 to 0.5.14.
- [Commits](https://github.com/ulikunitz/xz/compare/v0.5.11...v0.5.14)
---
updated-dependencies:
- dependency-name: github.com/ulikunitz/xz
dependency-version: 0.5.14
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(deps): bump github.com/go-viper/mapstructure/v2 from 2.2.1 to 2.4.0 (#4173)
chore(deps): bump github.com/go-viper/mapstructure/v2
Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.2.1 to 2.4.0.
- [Release notes](https://github.com/go-viper/mapstructure/releases)
- [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.4.0)
---
updated-dependencies:
- dependency-name: github.com/go-viper/mapstructure/v2
dependency-version: 2.4.0
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* refactor: standardize zetaclient logging (#4144)
* chore: remove unused DynamicTicker from zetaclient/types
* refactor: remove Msgf and refactor zerolog uses
* Replace Msgf for Msg
* Use '_' instead of '.'
* Start logs with lowercase instead of uppercase characters
* Use the constants in the logs module
* Use With().Logger() instead of log fields when possible
* fix: improve zetatool (#4175)
* scan gateway events by default for all inbound hashes
* scan gateway events by default for all inbound hashes
* test(`e2e`): add a E2E test to test depositAndCall with high gas consumption (#4177)
* set gas limit to 4m in localnet
* add high usage test
* changelog
* Update changelog.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Update e2e/e2etests/e2etests.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* test(`e2e`): add all chains by default in `start-localnet` (#4163)
* chore: add Solana to start-localnet to allow to run local tests
* add sui and ton
* Update cmd/zetae2e/local/local.go
Co-authored-by: Tanmay <tanmay@zetachain.com>
---------
Co-authored-by: Tanmay <tanmay@zetachain.com>
* chore: remove redundant words (#4179)
Signed-off-by: keeghcet <keeghcet@outlook.com>
* refactor: omit unnecessary reassignment (#4184)
Signed-off-by: fengyuchuanshen <fengyuchuanshen@outlook.com>
* fix: force rescan if inbound vote monitoring fails (#4183)
* add monitoringErr channel
* update to InboundBlockHeight - 1 , for reseting the block
* fix unit tests
* implement error interface
* rename to ErrTxMonitor
* add forceResetLastScanned flag
* add forceResetLastScanned flag
* add mutex to force scan
* add changelog
* add changelog
* update name to wasForceReset
* wrap UpdateForceResetLastScanned in mutex
* add a bound check to InboundBlockHeight to be safe
* Update zetaclient/chains/base/confirmation.go
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* Update zetaclient/chains/base/observer.go
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* force update for in memory value if forceResetLastScanned is true
* add a lock on reading block height
* update error message
* update changelog
* wait till end of scan cycle to toggle the forceUpdateFlag
---------
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* fix: remove duplicate solana post-gas-price goroutine (#4194)
* feat: observe inbound from previous gateway package after upgrade (#4138)
* observe inbound from old gateway package optionally
* add changelog entry
* add sui inbound cursor migration; add post-upgrade deposit tests
* improve comments, logs and naming; fix post-upgrade withdraw failure
* protect anyStringMap
* add support for <withdrawcap-id> to Sui gateway address
* fix CI upgrade test failure
* use name previousPackageID and keep name PairID; rename AnyString and cursor migration function; improve test, comments, etc.
* replaced assert by require in sui unit test
* add support for original packageID in Sui gateway address
* avoid wrapping nil error
* use previous package ID in post-upgrade Sui deposit test
* add support for previous package deprecation and fix upgrade test
* fix unit test
* add a note to clarify the PackageID argument used for event query
* add documents to explain Sui gateway address format in the chain params
* refactor: remove unused loggers and log fields (#4180)
* chore: remove unused Headers logger
* refactor: remove (mostly) unused GasPrice logger
* refactor: replace logs.FieldMethod with With().Caller() and standardize logs.FieldModule values
* refactor: remove (mostly) unused log fields FieldTracker and FieldConfirmationMode
* refactor: replace missed log instances of '.' for '_'
* fix: unpack bitcoin revert message without considering 'CallOnRevert' flag (#4169)
* enable bitcoin revertMessage and ignore CallOnRevert flag
* add changelog entry
* update standard memo doc; improve abort address validation
* skip incompatible e2e test to allow CI upgrade test to pass
* fix: add timeout to monitoring routine (#4196)
* add a timeout for vote monitoring thread
* add a timeout for vote monitoring thread
* add comments
* remove typo for cancel call
* fix unit tests
* Update zetaclient/zetacore/client_vote.go
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* Update zetaclient/chains/base/observer.go
Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com>
---------
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com>
* refactor: use maps.Copy for cleaner map handling (#4198)
Signed-off-by: joemicky <joemickychang@outlook.com>
* chore: fix some comments (#4208)
Signed-off-by: zhoujiaweii <zjwustc@outlook.com>
* fix: update evm version for missing tx types (#4216)
* refactor: replace HasPrefix+TrimPrefix with CutPrefix (#4215)
Signed-off-by: quantpoet <quantway@outlook.com>
* refactor: remove `LastBlockHeight` state variable (#4200)
* proto
* remove other references
* changelog
* refactor: add documentation for ZetaClient logging fields (#4174)
* refactor: use coin.CoinType for compliance logging
* refactor: add documentation for zetaclient logging fields
* fix: remove ZetaChain chain ID from GasStabilityPoolBalances query (#4217)
* fix query
* add test
* changelog
* add commment
* lint
* remove gas token address
* change error type
* refactor: remove index field in ballot (#4205)
* refactor: remove index field in ballot
* changelog
* fix unit tests
* refactor: remove `MsgUpdateERC20CustodyPauseStatus` and `MsgMigrateERC20CustodyFunds` (#4199)
* make message legacy
* remove other reference
* changelog
* refactor: rename whitelistERC20 into whitelistAsset (#4203)
* refactor: rename whitelistERC20 into whitelistAsset
* e2e test
* e2e test
* fix event
* simulation
* changelogs
* update auth list
* add migration script
* apply comment
* feat: provide error information in CCTX struct when Bitcoin deposit fail (#4211)
* add error message to CCTX struct when Bitcoin deposit failed
* add changelog entry
* fix unit test; improve function naming
* add unit test for inbound vote digest
* exclude inbound observation error message from digest
* fix: re-check for finalized ballot when executing inbound vote to create cctx (#4197)
* check for finalized block after ballot is finalized
* fix unit tests and add changelog
* adjust comments
* Apply suggestion from @lumtis
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* Apply suggestion from @lumtis
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* refactor check finalized ballot check to be done before adding the finalizing vote to the ballot
* adjust comments
* adjust comments
* fix comments 2
---------
Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com>
* fix: set zeta ante to true in upgrade tests (#4225)
* add zeta ante
* add to upgrade test regular
* add to upgrade test regular
* update out of gas test
* update out of gas test
* fix tss migration test
* fix lint issues 1
* update v2 zeta version
* chore: resync changelogs with v36 changes (#4223)
* fix: skip writing config file to the filesystem (#4210)
* comment out writing files to the state
* ad changelog
* remove commented code
* return error from fetching FlagSkipConfigOverwrite
* refactor(`observer`): remove deprecated code (#4192)
* update proto
* update code
* changelogs
* fix changelog
* fix gas limit issue in upgrade test
* use ante-zetae2e for admin upgrade tests
* test fix
* refactor: prepare the client interfaces used by the observer-signers for dry-mode (#4213)
refactor: prepare the client interfaces of the observer-signers for dry-mode
* feat: enable NoAssetCall from Bitcoin (#4218)
* enable NoAssetCall from Bitcoin
* add changelog entry
* improve comment and log print
* revert bitcoin NoAssetCall that carries large excessive funds
* adjust btc inbound parsing order; fix test name
* improve function and variable names
* feat: multiple evm calls in single tx (#4157)
* bump protocol contracts
* use newer geth version with cancun support
* e2e test with 2 deposits in same tx
* e2e tests
* inbound trackers for multiple events
* changelog
* generate
* fix e2e tests
* inbound trackers e2e test
* bump protocol contracts
* PR comments
* PR comment
* PR comments
* PR comment
* lower upgrade height in upgrade tests
* try diff upgrade height
* upgrade additional fee in upgrade v36 handler
* chore: fix function name in comment (#4238)
Signed-off-by: russcoss <russcoss@outlook.com>
* revert: add timeout to monitoring routine" (#4244)
Revert "fix: add timeout to monitoring routine (#4196)"
This reverts commit 65f227bbfa585adb408f31d15a5bcf71243d1e52.
* fix(e2e): check test contracts deployment (#4251)
* fix(e2e): check test contracts deployment
* add other contracts
* changelog
* fix chain to wait tx from
* revert: force rescan if inbound vote monitoring fails (#4250)
* feat: refund a portion of remaining unused tokens to user (#3734)
* add new field to cctx structure to track user gas burned
* add unit tests
* add doc
* add unit test for migration
* add check for pre upgrade cctxs
* add older logic for handling cctxs created before upgrade
* remove LegacyChainParams
* add unit test for refund gas fee
* remove old migration
* add temp note for PR review
* fix typo
* fix typo
* generate files
* add missing test case
* add missing test case
* refactor based on comments
* update EtherWithdrawRestricted test
* update EtherWithdrawRest…
Description
Closes : #2966
Document for more details :
https://github.com/zeta-chain/node/blob/3daaba6b8725ba25a57e648f9fb38e549a2a57ff/docs/zetacore/managment_for_unused_gas_fee.md
How Has This Been Tested?
Summary by CodeRabbit
New Features
Documentation