Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use generic signer interface #46

Merged
merged 7 commits into from
Jul 5, 2024

Conversation

dai1975
Copy link
Contributor

@dai1975 dai1975 commented Jun 4, 2024

Replace ethereum signer with bytes[] signer interface added in hyperledger-labs/yui-relayer#142

@dai1975 dai1975 marked this pull request as draft June 4, 2024 10:03
@dai1975 dai1975 marked this pull request as ready for review June 13, 2024 06:02
@dai1975 dai1975 requested a review from siburu June 13, 2024 06:02
Comment on lines +44 to +46
func (s *EthereumSigner) SetLogger(logger *log.RelayLogger) {
s.logger = logger
}
Copy link
Contributor

Choose a reason for hiding this comment

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

After calling SetLogger and finishing the processing, we need to reset the logger, right?

origLogger := c.ethereumSigner.GetLogger()
c.ethereumSigner.SetLogger(newLogger)

<... some processing ...>

c.ethereumSigner.SetLogger(origLogger)

or

c.ethereumSigner.PushLogger(newLogger)

<... some processing ...>

defer c.ethereumSigner.PopLogger()

In any case, we should define an interface that clearly indicates the section where the configured logger is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This EthereumSigner use logger only in Sign function and no need to have dedicate logger instance(such like use different output log file).
How abount Sign function get logger or ctx which has logger as an arument?

func (s *EthereumSigner) Sign(address common.Address, tx *gethtypes.Transaction, logger *log.RelayLogger) (*gethtypes.Transaction, error) {

Copy link
Contributor

Choose a reason for hiding this comment

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

@dai1975 Thank you. If the function signature of EthereumSigner::Sign could be changed, I would agree with the idea, but it can't.
The function signature must match go-ethereum's SignerFn, right?

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 see.
fixed by using defer SetLogger(oldlogger) pattern in tx.go

Signed-off-by: Daisuke Kanda <[email protected]>
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.

@siburu siburu merged commit 88aef91 into datachainlab:main Jul 5, 2024
1 check passed
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.

None yet

2 participants