Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

refactor(signing): remove polar and eth_secp256k1 #1191

Merged
merged 9 commits into from
Oct 7, 2023
Merged

Conversation

itsdevbear
Copy link
Contributor

@itsdevbear itsdevbear commented Oct 7, 2023

Summary by CodeRabbit

  • Refactor: Removed unused golines target from Makefile and updated the format target.
  • Refactor: Removed two struct types and associated functions from i_bank_module.abigen.go.
  • Refactor: Removed two functions from Bank.sol.
  • New Feature: Introduced a new function NewMinimalHandler in minimal.go.
  • Refactor: Modified SdkProposalToGovProposal function in conversions.go for better error handling.
  • Refactor: Updated package name and added a new function ProvideNoopGetSigners in signers.go.
  • New Feature: Introduced a new package libtx that provides a TxSerializer interface and its implementation.
  • Refactor: Updated Miner struct to include a field of type EthTxSerializer.
  • Refactor: Removed two functions from bank.go.
  • Refactor: Updated test cases in bank_test.go and governance_test.go.
  • Refactor: Changed bond denomination in testutil.go.
  • Refactor: Updated address prefixes in setup.go.
  • Refactor: Renamed methods in handler.go and mempool.go.
  • Refactor: Updated test cases in handler_test.go and mempool_test.go.
  • Refactor: Updated methods in tx_serializer.go.
  • Refactor: Simplified Bech32 prefix setting in config.go.
  • Refactor: Removed commented-out code in genesis.go.
  • Refactor: Updated EthTransaction function in msg_server.go.
  • Refactor: Renamed functions and modified return types in tx.go.
  • Documentation: Added a new section titled "Hive Clients" in README.md.
  • Refactor: Updated scripts in hive-init.sh, start-node.sh, docker-init.sh, init.sh, seed0-init-step1.sh, seed0-init-step2.sh, seed1-init-step1.sh, val0-init-step1.sh, val1-init-step1.sh, and entrypoint.sh.
  • Refactor: Updated configuration and initialization process in app.go and app_config.go.
  • Refactor: Updated scripts in root.go, proto_generate.sh, and proto_generate_pulsar.sh.
  • Chore: Removed import of the "github.com/segmentio/golines" package from tools.go.

@codecov
Copy link

codecov bot commented Oct 7, 2023

Codecov Report

Merging #1191 (a044c88) into main (5a93af9) will increase coverage by 0.46%.
The diff coverage is 9.37%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1191      +/-   ##
==========================================
+ Coverage   50.36%   50.83%   +0.46%     
==========================================
  Files          93       85       -8     
  Lines        5168     4855     -313     
==========================================
- Hits         2603     2468     -135     
+ Misses       2373     2212     -161     
+ Partials      192      175      -17     
Files Coverage Δ
cosmos/precompile/bank/bank.go 75.67% <ø> (-1.73%) ⬇️
cosmos/precompile/governance/testutil.go 62.50% <100.00%> (ø)
cosmos/txpool/handler.go 72.85% <100.00%> (ø)
cosmos/txpool/mempool.go 50.00% <100.00%> (ø)
cosmos/types/config.go 30.00% <ø> (-16.67%) ⬇️
cosmos/x/evm/genesis.go 28.00% <ø> (ø)
e2e/localnet/network/fixture.go 0.00% <ø> (ø)
e2e/localnet/network/node.go 0.00% <ø> (ø)
cosmos/x/evm/keeper/msg_server.go 0.00% <0.00%> (ø)
cosmos/miner/miner.go 0.00% <0.00%> (ø)
... and 2 more

@itsdevbear itsdevbear marked this pull request as ready for review October 7, 2023 22:43
@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2023

Walkthrough

The changes primarily focus on refactoring and cleaning up the codebase. Key modifications include removal of unused functions, updating package imports, renaming methods, and adjusting function parameters. The code also introduces new interfaces and their implementations for transaction serialization. Additionally, there are updates to test cases and scripts, reflecting the changes made in the main code.

Changes

Files Summary
Makefile, tools/tools.go Removed usage of golines tool from build process.
contracts/bindings/cosmos/precompile/bank/i_bank_module.abigen.go, contracts/src/cosmos/precompile/Bank.sol, cosmos/precompile/bank/bank.go, cosmos/precompile/bank/bank_test.go Removed two struct types and associated functions related to coin denomination metadata and send status.
cosmos/lib/ante/minimal.go, cosmos/lib/conversions.go, cosmos/lib/signing/signers.go, cosmos/lib/tx/serializer.go, cosmos/miner/miner.go, cosmos/txpool/handler.go, cosmos/txpool/mocks/tx_serializer.go Introduced new interfaces and their implementations for transaction serialization. Updated existing methods to reflect these changes.
cosmos/precompile/governance/governance_test.go, cosmos/precompile/governance/testutil.go, e2e/precompile/contracts/gov/governance_test.go Made changes related to the denomination of coins.
cosmos/types/config.go, cosmos/types/config_test.go, e2e/testapp/app_config.go Updated Bech32 prefixes and simplified prefix setting logic.
cosmos/x/evm/genesis.go, cosmos/x/evm/keeper/msg_server.go, cosmos/x/evm/types/tx.go Removed commented-out code, added TODO comments, and modified methods related to Ethereum transactions.
e2e/hive/clients/README.md, e2e/hive/clients/polard/hive-init.sh, e2e/hive/clients/polard/Dockerfile Added documentation for Hive clients and made changes to the Dockerfile and initialization script.
scripts/proto_generate.sh, scripts/proto_generate_pulsar.sh Updated scripts for generating gogo proto code and moved directories.

"A rabbit hopped through the code, 🐇
Cleaning up as it strode. 🧹
With each leap and bound, 🦘
Refactoring was found. 🔍
Now the codebase is a smoother road!" 🛣️


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 11

Commits Files that changed from the base of the PR and between 5a93af9 and 37aa368.
Files ignored due to filter (20)
  • cosmos/crypto/keys/ethsecp256k1/keys.pb.go
  • cosmos/go.mod
  • cosmos/go.sum
  • e2e/hive/clients/polard/config/genesis.json
  • e2e/localnet/go.mod
  • e2e/localnet/go.sum
  • e2e/precompile/polard/config/addrbook.json
  • e2e/precompile/polard/config/app.toml
  • e2e/precompile/polard/config/client.toml
  • e2e/precompile/polard/config/config.toml
  • e2e/precompile/polard/config/genesis.json
  • e2e/precompile/polard/config/gentx/gentx-4354a78701907c06155caf2bf230ba7988115799.json
  • e2e/precompile/polard/config/node_key.json
  • e2e/precompile/polard/config/priv_validator_key.json
  • e2e/precompile/polard/config/priv_validator_state.json
  • e2e/testapp/go.mod
  • e2e/testapp/go.sum
  • go.work.sum
  • tools/go.mod
  • tools/go.sum
Files selected for processing (43)
  • Makefile (3 hunks)
  • contracts/bindings/cosmos/precompile/bank/i_bank_module.abigen.go (2 hunks)
  • contracts/bindings/testing/governance/governance_wrapper.abigen.go (1 hunks)
  • contracts/src/cosmos/precompile/Bank.sol (1 hunks)
  • cosmos/lib/ante/minimal.go (1 hunks)
  • cosmos/lib/conversions.go (2 hunks)
  • cosmos/lib/signing/signers.go (1 hunks)
  • cosmos/lib/tx/serializer.go (1 hunks)
  • cosmos/miner/miner.go (3 hunks)
  • cosmos/precompile/bank/bank.go (2 hunks)
  • cosmos/precompile/bank/bank_test.go (3 hunks)
  • cosmos/precompile/governance/governance_test.go (1 hunks)
  • cosmos/precompile/governance/testutil.go (1 hunks)
  • cosmos/testing/utils/setup.go (2 hunks)
  • cosmos/txpool/handler.go (2 hunks)
  • cosmos/txpool/handler_test.go (2 hunks)
  • cosmos/txpool/mempool.go (1 hunks)
  • cosmos/txpool/mempool_test.go (2 hunks)
  • cosmos/txpool/mocks/tx_serializer.go (1 hunks)
  • cosmos/types/config.go (2 hunks)
  • cosmos/types/config_test.go (1 hunks)
  • cosmos/x/evm/genesis.go (1 hunks)
  • cosmos/x/evm/keeper/msg_server.go (1 hunks)
  • cosmos/x/evm/types/tx.go (1 hunks)
  • e2e/hive/clients/README.md (1 hunks)
  • e2e/hive/clients/polard/hive-init.sh (2 hunks)
  • e2e/localnet/network/fixture.go (2 hunks)
  • e2e/precompile/contracts/bank/bank_test.go (3 hunks)
  • e2e/precompile/contracts/gov/governance_test.go (3 hunks)
  • e2e/precompile/contracts/staking/staking_test.go (2 hunks)
  • e2e/precompile/polard/start-node.sh (1 hunks)
  • e2e/testapp/app.go (5 hunks)
  • e2e/testapp/app_config.go (1 hunks)
  • e2e/testapp/docker/local/docker-init.sh (2 hunks)
  • e2e/testapp/docker/seed/init.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/seed0-init-step1.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/seed0-init-step2.sh (1 hunks)
  • e2e/testapp/docker/seed/scripts/seed1-init-step1.sh (1 hunks)
  • e2e/testapp/docker/validator/scripts/val0-init-step1.sh (1 hunks)
  • e2e/testapp/docker/validator/scripts/val1-init-step1.sh (1 hunks)
  • e2e/testapp/entrypoint.sh (3 hunks)
  • e2e/testapp/polard/cmd/root.go (3 hunks)
  • tools/tools.go (1 hunks)
Files not summarized due to errors (1)
  • contracts/bindings/testing/governance/governance_wrapper.abigen.go: Error: Message exceeds token limit
Files skipped from review due to trivial changes (25)
  • Makefile
  • contracts/bindings/cosmos/precompile/bank/i_bank_module.abigen.go
  • contracts/src/cosmos/precompile/Bank.sol
  • cosmos/lib/conversions.go
  • cosmos/lib/signing/signers.go
  • cosmos/precompile/bank/bank.go
  • cosmos/precompile/bank/bank_test.go
  • cosmos/txpool/mempool.go
  • cosmos/types/config.go
  • cosmos/types/config_test.go
  • cosmos/x/evm/genesis.go
  • e2e/hive/clients/README.md
  • e2e/hive/clients/polard/hive-init.sh
  • e2e/localnet/network/fixture.go
  • e2e/precompile/contracts/gov/governance_test.go
  • e2e/testapp/app_config.go
  • e2e/testapp/docker/seed/init.sh
  • e2e/testapp/docker/seed/scripts/seed0-init-step1.sh
  • e2e/testapp/docker/seed/scripts/seed0-init-step2.sh
  • e2e/testapp/docker/seed/scripts/seed1-init-step1.sh
  • e2e/testapp/docker/validator/scripts/val0-init-step1.sh
  • e2e/testapp/docker/validator/scripts/val1-init-step1.sh
  • e2e/testapp/polard/cmd/root.go
  • tools/tools.go
  • contracts/bindings/testing/governance/governance_wrapper.abigen.go (diff too large)
Additional comments (Suppressed): 37
cosmos/lib/ante/minimal.go (2)
  • 21-22: The package name has been changed from "hd" to "antelib". Ensure that all references to this package throughout the codebase have been updated accordingly.

  • 28-32: The function NewMinimalHandler is introduced, which returns an sdk.AnteHandler. This function seems to be replacing the previous testing function. Make sure that this change aligns with your project's requirements and that the new function is properly tested.

cosmos/x/evm/keeper/msg_server.go (1)
  • 37-42: The method AsTransaction() has been replaced with Unwrap(). Ensure that the new method provides the same functionality as the old one and that it is compatible with the rest of the codebase.
cosmos/precompile/governance/testutil.go (1)
  • 80-86: The denomination for staking has been changed from "abgt" to "abera". Ensure that this change is reflected throughout the codebase and does not break any functionality. Also, consider handling the error in a more graceful way than just panicking.
-  	stakingParams.BondDenom = "abgt"
+  	stakingParams.BondDenom = "abera"
cosmos/txpool/mocks/tx_serializer.go (2)
  • 26-49: The method ToSdkTx has been updated to include a new parameter gasLimit. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the gasLimit is being used correctly within the function.

  • 81-104: The method ToSdkTxBytes has been updated to include a new parameter gasLimit. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the gasLimit is being used correctly within the function.

cosmos/precompile/governance/governance_test.go (1)
  • 506-513: The MsgSubmitProposal struct has been extended with additional fields: InitialDeposit, Proposer, Metadata, and Title. Ensure that these new fields are correctly populated and used wherever this struct is utilized. Also, verify if these changes have any impact on the existing functionality or tests.
cosmos/testing/utils/setup.go (1)
  • 89-94: The Bech32 prefixes have been updated from "polar" to "cosmos". Ensure that this change is reflected across the entire codebase and does not break any functionality.
cosmos/lib/tx/serializer.go (3)
  • 33-35: The TxSerializer interface has been updated with two new methods: ToSdkTx and ToSdkTxBytes. Ensure that all implementations of this interface have been updated accordingly.

  • 42-50: The NewSerializer function is introduced to create a new instance of TxSerializer. It takes a txConfig and a wrapFn as parameters. The wrapFn is a function that wraps the input into an output of type sdk.Msg. This is a good use of dependency injection, which improves testability and maintainability.

  • 87-100: The ToSdkTxBytes method first converts the input into a Cosmos SDK transaction using the ToSdkTx method, then encodes the transaction into bytes using the txConfig.TxEncoder(). This method provides a convenient way to convert the input directly into byte format suitable for CometBFT.

cosmos/txpool/mempool_test.go (2)
  • 43-63: The test case for the "insert" function when the txpool does not error has been updated. The evmtypes.NewFromTransaction method has been replaced with evmtypes.WrapTx. Ensure that this change is intentional and aligns with the new implementation of the Insert method in the Mempool struct.

  • 67-73: The test case for the "insert" function when the txpool errors has also been updated to use evmtypes.WrapTx instead of evmtypes.NewFromTransaction. Confirm that this change is consistent with the new implementation of the Insert method in the Mempool struct.

e2e/testapp/entrypoint.sh (2)
  • 31-31: The key algorithm has been changed from eth_secp256k1 to secp256k1. Ensure that this change is compatible with the rest of your system and that all dependencies are updated accordingly.

  • 92-92: The Bech32 prefix has been changed from "polar" to "cosmos". Make sure that this change is reflected everywhere in your codebase where addresses are generated or validated.

cosmos/x/evm/types/tx.go (1)
  • 34-44: The function WrapTx is a replacement for the old NewFromTransaction. It performs the same operation but now returns an error instead of panicking when the transaction cannot be marshalled. This is a good practice as it allows for better error handling.
e2e/precompile/contracts/bank/bank_test.go (3)
  • 74-76: The number of denominations has been reduced from 8 to 7. Ensure that this change is intentional and does not affect other parts of the codebase.

  • 93-98: The evmDenomMetadata object and its associated checks have been removed. If this metadata is no longer needed, this change is fine. However, if it's still required elsewhere, consider restoring it or handling it in a different way.

  • 137-141: The calls to GetDenomMetadata and GetSendEnabled have been removed. If these functions are no longer part of the BankModule contract, this change is acceptable. Otherwise, ensure that their removal doesn't impact the functionality of the contract.

e2e/testapp/docker/local/docker-init.sh (2)
  • 32-32: The key algorithm has been changed from eth_secp256k1 to secp256k1. Ensure that this change is compatible with the rest of your system and doesn't introduce any breaking changes.

  • 80-80: The Bech32 prefix has been updated from "polar" to "cosmos". Make sure all instances of the old prefix have been replaced throughout the codebase, and verify that this change doesn't affect any functionality or compatibility.

e2e/precompile/contracts/staking/staking_test.go (2)
  • 55-75: The initialization of the validator variable has been changed from validator = tf.ValAddr() to fetching the first bonded validator from the stakingPrecompile.GetBondedValidators function. Ensure that this change doesn't affect the test cases where the validator variable is used, especially if the first bonded validator isn't always the same as the one returned by tf.ValAddr().
-		validator = tf.ValAddr()
+		validators, _, err := stakingPrecompile.GetBondedValidators(nil, bindings.CosmosPageRequest{})
+		Expect(err).ToNot(HaveOccurred())
+		Expect(validators).To(HaveLen(1))
+		validator = common.BytesToAddress(validators[0].OperatorAddr[:])
  • 85-90: The call to stakingPrecompile.GetBondedValidators has been removed from this test case. If the purpose of this test case is to verify the functionality of GetBondedValidators, then this removal might be an issue. However, if the focus of the test case is only on GetDelegation, then this change should be fine.
-		validators, _, err := stakingPrecompile.GetBondedValidators(nil, bindings.CosmosPageRequest{})
-		Expect(err).ToNot(HaveOccurred())
-		Expect(validators[0].OperatorAddr).To(Equal(validator))
cosmos/txpool/handler.go (2)
  • 51-55: The method signatures in the TxSerializer interface have been updated. Ensure that all implementations of this interface throughout the codebase have been updated to match the new signatures.
-	SerializeToSdkTx(signedTx *coretypes.Transaction) (sdk.Tx, error)
-	SerializeToBytes(signedTx *coretypes.Transaction) ([]byte, error)
+	ToSdkTx(signedTx *coretypes.Transaction, gasLimit uint64) (sdk.Tx, error)
+	ToSdkTxBytes(signedTx *coretypes.Transaction, gasLimit uint64) ([]byte, error)
  • 163-169: The ToSdkTxBytes method now requires a second argument for the gas limit. This change is consistent with the updated interface definition. However, ensure that the gas limit passed here (signedEthTx.Gas()) is correctly calculated and does not introduce any potential issues related to transaction execution or cost.
-		txBytes, err := h.serializer.SerializeToBytes(signedEthTx)
+		txBytes, err := h.serializer.ToSdkTxBytes(signedEthTx, signedEthTx.Gas())
cosmos/miner/miner.go (5)
  • 34-35: The import paths have been updated. Ensure that the new paths are correct and the packages exist at those locations.

  • 41-45: The EthTxSerializer interface has been introduced, replacing the previous evmtypes.TxSerializer. This change affects the serializer field in the Miner struct and the Init method. Make sure all implementations of this interface correctly implement both methods (ToSdkTx and ToSdkTxBytes).

  • 48-52: The serializer field type in the Miner struct has been changed from evmtypes.TxSerializer to EthTxSerializer. Ensure that all references to this field throughout the codebase have been updated accordingly.

  • 62-64: The Init method now accepts an EthTxSerializer instead of an evmtypes.TxSerializer. Verify that all calls to this method have been updated to pass an EthTxSerializer.

  • 132-135: The call to m.serializer.SerializeToBytes(&tx) has been replaced with m.serializer.ToSdkTxBytes(&tx, tx.Gas()). Ensure that the additional tx.Gas() argument is correctly handled in the ToSdkTxBytes method implementation.

cosmos/txpool/handler_test.go (2)
  • 43-57: The GinkgoT() function is moved inside the BeforeEach block. This change should not affect the functionality, but it's important to ensure that all tests still pass after this modification.

  • 82-103: The method SerializeToBytes has been replaced with ToSdkTxBytes. Ensure that the new method provides the same functionality as the old one. Also, the coretypes.LegacyTx now includes a Gas field in addition to Nonce. Make sure this additional field is handled correctly in your application.

- serializer.On("SerializeToBytes", mock.Anything).Return([]byte{123}, nil).Once()
+ serializer.On("ToSdkTxBytes", mock.Anything, mock.Anything).Return([]byte{123}, nil).Once()

- coretypes.NewTx(&coretypes.LegacyTx{Nonce: 5})
+ coretypes.NewTx(&coretypes.LegacyTx{Nonce: 5, Gas: 10})
e2e/testapp/app.go (5)
  • 43-48: The import of "github.com/cosmos/cosmos-sdk/x/auth/ante" has been removed. Ensure that this does not affect any functionality where the ante handler was used.

  • 55-68: Several changes in imports are observed. The package ethcryptocodec is no longer imported, and new packages antelib, signinglib, libtx, and coretypes are introduced. Make sure these changes align with the intended functionality and do not introduce any breaking changes.

  • 134-142: The function signinglib.ProvideNoopGetSigners[*evmv1alpha1.WrappedEthereumTransaction] is now provided to the dependency injection system instead of evmtypes.ProvideEthereumTransactionGetSigners. Verify that this change is intentional and correctly implemented across the codebase.

  • 209-214: The AnteHandler setup has been simplified to use antelib.NewMinimalHandler(). This is a significant change from the previous version which used evmante.NewAnteHandler. Ensure that this new handler meets all requirements and doesn't break any existing functionality.

  • 272-279: The transaction serializer is now created using libtx.NewSerializer[*coretypes.Transaction](apiSvr.ClientCtx.TxConfig, evmtypes.WrapTx). Previously, it was created using evmtypes.NewSerializer(apiSvr.ClientCtx.TxConfig). Confirm that this change is correct and doesn't affect the serialization process.

cosmos/testing/utils/setup.go Show resolved Hide resolved
cosmos/lib/tx/serializer.go Show resolved Hide resolved
cosmos/x/evm/types/tx.go Show resolved Hide resolved
e2e/precompile/polard/start-node.sh Show resolved Hide resolved
e2e/precompile/polard/start-node.sh Show resolved Hide resolved
e2e/precompile/polard/start-node.sh Show resolved Hide resolved
e2e/precompile/polard/start-node.sh Show resolved Hide resolved
e2e/precompile/polard/start-node.sh Show resolved Hide resolved
cosmos/lib/conversions.go Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 37aa368 and 714017a.
Files ignored due to filter (6)
  • polaris/cosmos/x/evm/types/tx.pb.go
  • proto/buf.gen.gogo.yaml
  • proto/buf.gen.pulsar.yaml
  • proto/buf.lock
  • proto/buf.yaml
  • x/evm/types/tx.pb.go
Files selected for processing (3)
  • Makefile (5 hunks)
  • scripts/proto_generate.sh (2 hunks)
  • scripts/proto_generate_pulsar.sh (1 hunks)
Files skipped from review due to trivial changes (1)
  • Makefile
Additional comments (Suppressed): 6
scripts/proto_generate.sh (3)
  • 32-33: The directory change from cosmos/proto to proto might affect the path where the script looks for .proto files. Ensure that this change is intentional and that it doesn't break the proto generation process.

  • 47-48: The copy command now copies all contents of pkg.berachain.dev/polaris/* instead of pkg.berachain.dev/polaris/cosmos/*. This could potentially include unwanted files or directories in the destination. Verify if this broader scope is intended.

  • 52-52: The script proto_generate_pulsar.sh has been moved from proto/scripts/ to scripts/. Confirm that this script exists at the new location and that all invocations of this script have been updated accordingly.

scripts/proto_generate_pulsar.sh (3)
  • 34-35: The script is deleting all files with extensions .pulsar.go, .pb.go, .cosmos_orm.go, and .pb.gw.go in the cosmos/api directory. Ensure that this operation does not unintentionally remove any necessary files.

  • 38-38: The buf generate --template buf.gen.pulsar.yaml command is being run in the proto directory. Verify that the buf.gen.pulsar.yaml file exists in this location and contains the correct configuration for your project.

  • 40-40: The api directory is being moved to cosmos/. This could potentially break any absolute paths referencing the api directory in your codebase. Make sure to update all such references to reflect this change.

- mv api cosmos/
+ mv cosmos/api cosmos/

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 714017a and 42fc034.
Files selected for processing (1)
  • cosmos/lib/conversions.go (2 hunks)
Additional comments (Suppressed): 2
cosmos/lib/conversions.go (2)
  • 242-248: The new hunk is identical to the old one. No changes have been made in these lines.

  • 252-277: The time fields SubmitTime, DepositEndTime, VotingStartTime, and VotingEndTime are now being checked for nil before conversion to Unix timestamp. This is a good practice as it prevents potential runtime panics due to dereferencing a nil pointer.

-		SubmitTime:      uint64(proposal.SubmitTime.Unix()),
-		DepositEndTime:  uint64(proposal.DepositEndTime.Unix()),
-		VotingStartTime: uint64(proposal.VotingStartTime.Unix()),
-		VotingEndTime:   uint64(proposal.VotingEndTime.Unix()),
+	if proposal.SubmitTime != nil {
+		output.SubmitTime = uint64(proposal.SubmitTime.Unix())
+	}
+
+	if proposal.DepositEndTime != nil {
+		output.DepositEndTime = uint64(proposal.DepositEndTime.Unix())
+	}
+
+	if proposal.VotingStartTime != nil {
+		output.VotingStartTime = uint64(proposal.VotingStartTime.Unix())
+	}
+
+	if proposal.VotingEndTime != nil {
+		output.VotingEndTime = uint64(proposal.VotingEndTime.Unix())
+	}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 714017a and 84b87d9.
Files selected for processing (1)
  • cosmos/lib/conversions.go (2 hunks)
Additional comments (Suppressed): 4
cosmos/lib/conversions.go (4)
  • 242-248: The assignment of values to the output variable is done correctly. The error handling for the previous operations is also appropriate.

  • 252-261: The assignment of values to the output variable continues correctly here. The fields are being populated as expected.

  • 263-277: The addition of nil checks before assigning time-related fields is a good practice to avoid potential runtime errors due to null dereferencing. This change improves the robustness of the code.

-		SubmitTime:      uint64(proposal.SubmitTime.Unix()),
-		DepositEndTime:  uint64(proposal.DepositEndTime.Unix()),
-		VotingStartTime: uint64(proposal.VotingStartTime.Unix()),
-		VotingEndTime:   uint64(proposal.VotingEndTime.Unix()),
+	if proposal.SubmitTime != nil {
+ 		output.SubmitTime = uint64(proposal.SubmitTime.Unix())
+ 	}
+ 
+ 	if proposal.DepositEndTime != nil {
+ 		output.DepositEndTime = uint64(proposal.DepositEndTime.Unix())
+ 	}
+ 
+ 	if proposal.VotingStartTime != nil {
+ 		output.VotingStartTime = uint64(proposal.VotingStartTime.Unix())
+ 	}
+ 
+ 	if proposal.VotingEndTime != nil {
+ 		output.VotingEndTime = uint64(proposal.VotingEndTime.Unix())
+ 	}
  • 279-279: The function now returns the output variable instead of directly returning a struct literal. This change allows for more flexibility in modifying the output variable before it's returned, which is utilized in the new nil checks for time-related fields.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 84b87d9 and a044c88.
Files ignored due to filter (2)
  • e2e/hive/clients/polard/config/app.toml
  • e2e/hive/clients/polard/config/genesis.json
Files selected for processing (3)
  • e2e/hive/clients/polard/Dockerfile (1 hunks)
  • e2e/hive/clients/polard/hive-init.sh (3 hunks)
  • e2e/localnet/network/node.go (1 hunks)
Files skipped from review due to trivial changes (3)
  • e2e/hive/clients/polard/Dockerfile
  • e2e/hive/clients/polard/hive-init.sh
  • e2e/localnet/network/node.go

@itsdevbear itsdevbear added the merge me daddy Trigger Beradozer to bulldoze the PR label Oct 7, 2023
@itsdevbear itsdevbear removed the request for review from BrickBera October 7, 2023 23:30
@mergify mergify bot merged commit 8af2321 into main Oct 7, 2023
16 checks passed
@mergify mergify bot deleted the signing-changes branch October 7, 2023 23:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
merge me daddy Trigger Beradozer to bulldoze the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants