Skip to content

Conversation

@abicky
Copy link
Contributor

@abicky abicky commented Apr 18, 2025

This PR adds support for tracing features using tracing bridges, one of which was introduced in hyperledger-labs/yui-relayer#162.
To allow us to try the feature with minimal effort, this PR only focuses on using tracing bridges and logger methods with the Context suffix.

Since the tracing bridge affects code that uses type assertions and type information (%T), so I have verified that there is no remaining code to be updated as follows:

$ git grep '\(\.(\|%T\)'
module/fork_spec.go:197:		if x, ok := spec.GetHeightOrTimestamp().(*ForkSpec_Height); ok {
module/fork_spec.go:215:	if condition, ok := currentForkSpec.GetHeightOrTimestamp().(*ForkSpec_Height); ok {
module/parlia.pb.go:98:	if x, ok := m.GetHeightOrTimestamp().(*ForkSpec_Height); ok {
module/parlia.pb.go:105:	if x, ok := m.GetHeightOrTimestamp().(*ForkSpec_Timestamp); ok {
module/prover.go:102:	header := latestFinalizedHeader.(*Header)
module/prover.go:244:	lastForkSpecTime, ok := lastForkSpec.GetHeightOrTimestamp().(*ForkSpec_Timestamp)
module/prover.go:246:		target, err := dstHeader.(*Header).Target()
module/prover.go:255:	dstHeader, err := pr.withValidators(ctx, dstHeader.GetHeight().GetRevisionHeight(), dstHeader.(*Header).Headers)
module/prover.go:260:	downcast := dstHeader.(*Header)
module/prover_test.go:144:	ts.prover = NewProver(ts.chain, &config).(*Prover)
module/setup.go:36:	if x, ok := latestCondition.(*ForkSpec_Timestamp); ok {
module/setup.go:145:		h.(*Header).TrustedHeight = &trustedHeight
module/setup.go:147:		logger.DebugContext(ctx, "setupHeadersForUpdate end", "target", h.GetHeight(), "trusted", trustedHeight, "headerSize", len(h.(*Header).Headers))
module/setup_test.go:61:			trusted := h.(*Header).TrustedHeight
module/setup_test.go:199:			trusted := h.(*Header).TrustedHeight
tests/prover_network_test.go:53:	ts.Require().Len(header.(*module.Header).Headers, 3)
tests/prover_network_test.go:54:	h := header.(*module.Header)
tests/prover_network_test.go:74:		ts.Require().Len(h.(*module.Header).Headers, 3)
tests/prover_network_test.go:83:	cs := s1.(*module.ClientState)
tests/prover_network_test.go:108:	consState := s2.(*module.ConsensusState)
tests/prover_network_test.go:159:	return module.NewProver(chain, &config).(*module.Prover)
tool/testdata/internal/common.go:22:	rpcAddr, ok := viper.Get("BSC_RPC_ADDR").(string)
tool/testdata/internal/common.go:62:	return module.NewProver(ec, &config).(*module.Prover), ec, nil
tool/testdata/internal/create_client.go:29:			protoClientState, err := codectypes.NewAnyWithValue(cs.(proto.Message))
tool/testdata/internal/create_client.go:33:			protoConsState, err := codectypes.NewAnyWithValue(consState.(proto.Message))
tool/testdata/internal/create_client.go:49:			log.Println("currentEpochHash", common.BytesToHash(consState.(*module.ConsensusState).CurrentValidatorsHash))
tool/testdata/internal/create_client.go:50:			log.Println("previousEpochHash", common.BytesToHash(consState.(*module.ConsensusState).PreviousValidatorsHash))
tool/testdata/internal/create_client.go:51:			log.Println("storageRoot", common.BytesToHash(consState.(*module.ConsensusState).StateRoot))
tool/testdata/internal/histroy.go:96:		blocks, err := prover.SetupHeadersForUpdateByLatestHeight(ctx, lastFinalized, header.(*module.Header))
tool/testdata/internal/histroy.go:141:	protoClientState, err := codectypes.NewAnyWithValue(cs.(proto.Message))
tool/testdata/internal/histroy.go:145:	protoConsState, err := codectypes.NewAnyWithValue(consState.(proto.Message))
tool/testdata/internal/membership/verify_membership.go:83:	prover := module.NewProver(module.NewChain(chain, chain.Config().IBCAddress(), chain.Client()), &config).(*module.Prover)
tool/testdata/internal/misbehavior.go:69:			target, err := header.(*module.Header).Target()
tool/testdata/internal/misbehavior.go:70:			updating, err := prover.SetupHeadersForUpdateByLatestHeight(cmd.Context(), types.NewHeight(header.GetHeight().GetRevisionNumber(), target.Number.Uint64()-1), header.(*module.Header))
tool/testdata/internal/misbehavior.go:78:				Header_1: updating[0].(*module.Header),
tool/testdata/internal/misbehavior.go:79:				Header_2: updating[0].(*module.Header),
tool/testdata/internal/misbehavior.go:89:			updating2, _ := prover.SetupHeadersForUpdateByLatestHeight(cmd.Context(), types.NewHeight(header2.GetHeight().GetRevisionNumber(), target.Number.Uint64()-1), header2.(*module.Header))
tool/testdata/internal/misbehavior.go:90:			target2, _ := updating2[0].(*module.Header).Target()
tool/testdata/internal/misbehavior.go:93:			updating2[0].(*module.Header).Headers[0] = &module.ETHHeader{Header: rlpTarget}
tool/testdata/internal/misbehavior.go:96:				Header_1: updating[0].(*module.Header),
tool/testdata/internal/misbehavior.go:97:				Header_2: updating2[0].(*module.Header),
tool/testdata/internal/misbehavior.go:104:			log.Println("Invalid block: current_validator_hash", common.Bytes2Hex(module.MakeEpochHash(header.(*module.Header).CurrentValidators, uint8(header.(*module.Header).CurrentTurnLength))))
tool/testdata/internal/misbehavior.go:105:			log.Println("Invalid block: previous_validator_hash", common.Bytes2Hex(module.MakeEpochHash(header.(*module.Header).PreviousValidators, uint8(header.(*module.Header).PreviousTurnLength))))
tool/testdata/internal/misbehavior.go:106:			log.Println("Invalid block: trusted_height", updating[0].(*module.Header).TrustedHeight)
tool/testdata/internal/misbehavior.go:145:	prover := module.NewProver(module.NewChain(chain, chain.Config().IBCAddress(), chain.Client()), &config).(*module.Prover)
tool/testdata/internal/misbehavior.go:154:	header := iHeader.(*module.Header)
tool/testdata/internal/update_client.go:82:			headers, err := prover.SetupHeadersForUpdateByLatestHeight(cmd.Context(), types.NewHeight(0, previousEpoch), target.(*module.Header))
tool/testdata/internal/update_client.go:129:			updating, err := prover.SetupHeadersForUpdateByLatestHeight(cmd.Context(), types.NewHeight(0, prevEpoch), header.(*module.Header))
tool/testdata/internal/update_client.go:137:			updating[0].(*module.Header).TrustedHeight = &newTrustedHeight
tool/testdata/internal/update_client.go:161:	header := iHeader.(*module.Header)
tool/testdata/internal/update_client.go:183:	trustedHeight := updating[0].(*module.Header).TrustedHeight.GetRevisionHeight()

⚠️ Breaking changes

This PR modifies the type of the embedded struct within ProvableChain, so modules that depends on type assertions need to use coreutil.UnwrapProver instead.

For example, the following code:

func someFunction(pc *core.ProvableChain) error {
	prover, ok := pc.Prover.(*relay.Prover)
	if !ok {
		return nil, fmt.Errorf("expected prover type is %T, but got %T", &relay.Prover{}, pc.Prover)
	}
	// -- snip --
}

must be updated to:

func someFunction(pc *core.ProvableChain) error {
	prover, err := coreutil.UnwrapProver[*relay.Prover](pc)
	if err != nil {
		return nil, err
	}
	// -- snip --
}

@abicky abicky marked this pull request as ready for review April 18, 2025 09:58
@abicky abicky marked this pull request as draft April 18, 2025 09:59
@abicky abicky marked this pull request as ready for review April 18, 2025 10:13
@abicky abicky marked this pull request as draft April 18, 2025 10:13
@abicky abicky marked this pull request as ready for review April 18, 2025 10:21
@abicky abicky marked this pull request as draft April 18, 2025 10:21
@abicky abicky marked this pull request as ready for review April 18, 2025 10:38
@abicky abicky marked this pull request as draft April 18, 2025 10:38
@abicky abicky marked this pull request as ready for review April 18, 2025 10:47
@abicky abicky marked this pull request as draft April 18, 2025 10:47
@abicky abicky marked this pull request as ready for review April 21, 2025 08:48
@abicky abicky marked this pull request as draft April 21, 2025 08:48
@abicky abicky marked this pull request as ready for review April 21, 2025 10:45
@abicky abicky marked this pull request as draft April 21, 2025 10:46
@abicky abicky force-pushed the enable-tracing branch from 4c2bcdf to e9fe3fa Compare May 8, 2025 08:31
@abicky abicky marked this pull request as ready for review May 8, 2025 08:31
@abicky abicky marked this pull request as draft May 8, 2025 08:31
@abicky abicky changed the title Enable tracing Support tracing feature May 8, 2025
@abicky abicky changed the base branch from main to fix_lorentz_height May 8, 2025 08:51
@abicky abicky marked this pull request as ready for review May 8, 2025 09:43
@abicky abicky marked this pull request as draft May 8, 2025 09:44
@abicky abicky force-pushed the enable-tracing branch from ae6ea63 to f1311e4 Compare May 8, 2025 10:02
@abicky abicky marked this pull request as ready for review May 8, 2025 10:09
@abicky abicky marked this pull request as draft May 8, 2025 10:09
Base automatically changed from fix_lorentz_height to main May 8, 2025 13:27
@abicky abicky changed the base branch from main to stabilize-e2e May 12, 2025 23:49
@abicky abicky marked this pull request as ready for review May 12, 2025 23:50
@abicky abicky marked this pull request as draft May 12, 2025 23:50
@abicky abicky marked this pull request as ready for review May 13, 2025 01:25
@abicky abicky marked this pull request as draft May 13, 2025 01:25
Base automatically changed from stabilize-e2e to main May 13, 2025 05:36
)

// See https://github.com/prysmaticlabs/grpc-gateway/issues/2
replace github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/prysmaticlabs/grpc-gateway/v2 v2.3.1-0.20230315201114-09284ba20446
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed this replace directive for the same reason as datachainlab/ethereum-ibc-relay-prover#38 (comment)

@abicky abicky force-pushed the enable-tracing branch 2 times, most recently from b4cb86a to 762522d Compare May 26, 2025 09:31
@abicky abicky changed the base branch from main to audit May 26, 2025 09:31
@abicky abicky marked this pull request as ready for review May 26, 2025 09:32
@abicky abicky marked this pull request as draft May 26, 2025 09:32
abicky added 2 commits May 29, 2025 13:16
Signed-off-by: Takeshi Arabiki <takeshi.arabiki@datachain.jp>
Signed-off-by: Takeshi Arabiki <takeshi.arabiki@datachain.jp>
@abicky abicky marked this pull request as ready for review May 29, 2025 05:35
@abicky abicky self-assigned this May 29, 2025
@abicky abicky requested a review from siburu May 29, 2025 06:00
@abicky abicky changed the base branch from audit to main May 29, 2025 06:00
Copy link
Contributor

@siburu siburu left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!!

@abicky abicky merged commit cdb39c7 into main Jun 4, 2025
4 checks passed
@abicky abicky deleted the enable-tracing branch June 4, 2025 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants