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

eth/tracers/js: add coinbase addr to ctx #30231

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

achmand
Copy link
Contributor

@achmand achmand commented Jul 26, 2024

Add coinbase address to javascript tracer context.

This PR adds the coinbase address to jsTracer.ctx, allowing access to the coinbase address (fee receipient) in custom JavaScript tracers.

Example usage:

result: function(ctx) {
  return toAddress(ctx.coinbase);
}

This change enables custom tracers to access coinbase address, previously unavailable, enhancing their capabilities to match built-in tracers.

@achmand achmand requested a review from s1na as a code owner July 26, 2024 11:58
Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

LGTM

@MRabenda
Copy link

MRabenda commented Aug 9, 2024

@lightclient what is required for this PR to be merged?

@fjl
Copy link
Contributor

fjl commented Aug 9, 2024

Since it is a change to tracing, I would prefer to get an approval from @s1na before merging.

@achmand
Copy link
Contributor Author

achmand commented Aug 12, 2024

@s1na would you be able to review this before merging?

@@ -154,6 +154,9 @@ func TestTracer(t *testing.T) {
want: "",
fail: "reached limit for padding memory slice: 1049568 at step (<eval>:1:83(20)) in server-side tracer function 'step'",
contract: []byte{byte(vm.PUSH1), byte(0xff), byte(vm.PUSH1), byte(0x00), byte(vm.MSTORE8), byte(vm.STOP)},
}, { // tests ctx.coinbase
code: "{lengths: [], step: function(log) { }, fault: function() {}, result: function(ctx) { var coinbase = ctx.coinbase; return toAddress(coinbase); }}",
want: `{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get it. What is this mapping? How does this correspond to return toAddress(coinbase); ?

Copy link
Member

Choose a reason for hiding this comment

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

The mapping seems to be "string index" -> decimal value of byte at index. It's weird. But that's how the other tracer tests work.

It maps to the default coinbase of 0x0. We could change it to a non-zero value, but I don't see much benefit. If this PR isn't working correctly, it will return nothing (bc no ctx value for coinbase).

Copy link
Contributor

@s1na s1na left a comment

Choose a reason for hiding this comment

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

LGTM

@s1na s1na merged commit 7a149a1 into ethereum:master Aug 15, 2024
3 checks passed
@fjl fjl added this to the 1.14.9 milestone Aug 15, 2024
@achmand achmand deleted the js_tracer_coinbase_ctx branch August 16, 2024 07:45
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.

6 participants