Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Aug 28, 2024
1 parent 9d34042 commit 5dd302e
Show file tree
Hide file tree
Showing 10 changed files with 367 additions and 283 deletions.
273 changes: 136 additions & 137 deletions api/opinit/opchild/v1/query.pulsar.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions proto/opinit/opchild/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ service Query {

rpc ForceWithdrawalProofs(QueryForceWithdrawalProofsRequest) returns (QueryForceWithdrawalProofsResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/opinit/opchild/v1/withdrawals/{l2_sequence}/proofs";
option (google.api.http).get = "/opinit/opchild/v1/withdrawals/{sequence}/proofs";
}
}

Expand Down Expand Up @@ -140,8 +140,8 @@ message QueryBaseDenomResponse {

// QueryForceWithdrawalProofsRequest is request type for the Query/ForceWithdrawalProofs RPC method.
message QueryForceWithdrawalProofsRequest {
// l2_sequence is the sequence number of the l2 block.
uint64 l2_sequence = 1;
// sequence is the sequence number of the withdrawal.
uint64 sequence = 1;
}

// QueryForceWithdrawalProofsResponse is response type for the Query/ForceWithdrawalProofs RPC method.
Expand Down
3 changes: 2 additions & 1 deletion x/opchild/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func NewSetBridgeInfoCmd(ac address.Codec) *cobra.Command {
return err
}

origConfig := ophostcli.BridgeCliConfig{}
var origConfig ophostcli.BridgeCliConfig
err = json.Unmarshal(configBytes, &origConfig)
if err != nil {
return err
Expand Down Expand Up @@ -328,6 +328,7 @@ func NewSetBridgeInfoCmd(ac address.Codec) *cobra.Command {
SubmissionStartHeight: submissionStartHeight,
Metadata: []byte(origConfig.Metadata),
BatchInfo: origConfig.BatchInfo,
OracleEnabled: origConfig.OracleEnabled,
}

if err = bridgeConfig.ValidateWithNoAddrValidation(); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion x/opchild/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ func (s *CLITestSuite) TestNewSetBridgeInfo() {
"batch_info": {
"submitter": "init1q6jhwnarkw2j5qqgx3qlu20k8nrdglft5ksr0g",
"chain_type": "INITIA"
}
},
"oracle_enabled": true
}`)
s.NoError(err)

Expand Down
20 changes: 17 additions & 3 deletions x/opchild/keeper/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ func (q Querier) BaseDenom(ctx context.Context, req *types.QueryBaseDenomRequest
return &types.QueryBaseDenomResponse{BaseDenom: baseDenom}, nil
}

// ForceWithdrawalProofs returns the force withdrawal proofs
// ForceWithdrawalProofs returns the force withdrawal proofs.
//
// @dev: This query is not deterministic and should only be used for off-chain.
// @dev: The caller must use the height query to get the app hash and commitment proof at the specific height.
// The height should be the L2 block number contained in the output submitted to L1, and this height should be higher than the block where the withdrawal occurred.
func (q Querier) ForceWithdrawalProofs(ctx context.Context, req *types.QueryForceWithdrawalProofsRequest) (*types.QueryForceWithdrawalProofsResponse, error) {
if q.clientCtx == nil {
return nil, status.Error(codes.Internal, "client context is not set")
Expand All @@ -120,8 +122,20 @@ func (q Querier) ForceWithdrawalProofs(ctx context.Context, req *types.QueryForc
return nil, status.Error(codes.Internal, err.Error())
}

Check warning on line 123 in x/opchild/keeper/querier.go

View check run for this annotation

Codecov / codecov/patch

x/opchild/keeper/querier.go#L118-L123

Added lines #L118 - L123 were not covered by tests

sequence := req.L2Sequence
commitmentProof, err := types.QueryCommitmentProof(q.baseAppQuerier, height-1, types.WithdrawalCommitmentKey(sequence))
sequence := req.Sequence
if ok, err := q.Commitments.Has(ctx, sequence); err != nil {
return nil, status.Error(codes.Internal, err.Error())
} else if !ok {
return nil, status.Errorf(codes.NotFound, "withdrawal commitment %d not found at height %d", sequence, height)
}

Check warning on line 130 in x/opchild/keeper/querier.go

View check run for this annotation

Codecov / codecov/patch

x/opchild/keeper/querier.go#L125-L130

Added lines #L125 - L130 were not covered by tests

commitmentProof, err := types.QueryCommitmentProof(
q.baseAppQuerier,
// we should compute the `height-1` here because the app hash of a block is
// the one that is committed in the previous block.
height-1,
types.WithdrawalCommitmentKey(sequence),
)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

Check warning on line 141 in x/opchild/keeper/querier.go

View check run for this annotation

Codecov / codecov/patch

x/opchild/keeper/querier.go#L132-L141

Added lines #L132 - L141 were not covered by tests
Expand Down
154 changes: 77 additions & 77 deletions x/opchild/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5dd302e

Please sign in to comment.