-
Notifications
You must be signed in to change notification settings - Fork 21.5k
eth/tracers: use atomic type #27031
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: use atomic type #27031
Changes from 2 commits
923d6b7
f961626
13a0adc
a9f03cf
40acb1a
cea9d65
e663c09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -835,8 +835,8 @@ func TestTraceChain(t *testing.T) { | |
| signer := types.HomesteadSigner{} | ||
|
|
||
| var ( | ||
| ref uint32 // total refs has made | ||
| rel uint32 // total rels has made | ||
| ref atomic.Uint32 // total refs has made | ||
| rel atomic.Uint32 // total rels has made | ||
| nonce uint64 | ||
| ) | ||
| backend := newTestBackend(t, genBlocks, genesis, func(i int, b *core.BlockGen) { | ||
|
|
@@ -849,8 +849,8 @@ func TestTraceChain(t *testing.T) { | |
| nonce += 1 | ||
| } | ||
| }) | ||
| backend.refHook = func() { atomic.AddUint32(&ref, 1) } | ||
| backend.relHook = func() { atomic.AddUint32(&rel, 1) } | ||
| backend.refHook = func() { ref.Add(1) } | ||
| backend.relHook = func() { rel.Add(1) } | ||
| api := NewAPI(backend) | ||
|
|
||
| single := `{"result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}` | ||
|
|
@@ -863,7 +863,7 @@ func TestTraceChain(t *testing.T) { | |
| {10, 20, nil}, // the middle chain range, blocks [11, 20] | ||
| } | ||
| for _, c := range cases { | ||
| ref, rel = 0, 0 // clean up the counters | ||
| ref, rel = atomic.Uint32{}, atomic.Uint32{} // clean up the counters | ||
|
|
||
| from, _ := api.blockByNumber(context.Background(), rpc.BlockNumber(c.start)) | ||
| to, _ := api.blockByNumber(context.Background(), rpc.BlockNumber(c.end)) | ||
|
|
@@ -889,7 +889,7 @@ func TestTraceChain(t *testing.T) { | |
| t.Error("Missing tracing block") | ||
| } | ||
| if ref != rel { | ||
| t.Errorf("Ref and deref actions are not equal, ref %d rel %d", ref, rel) | ||
| t.Errorf("Ref and deref actions are not equal, ref %d rel %d", ref.Load(), rel.Load()) | ||
|
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,8 +62,8 @@ type prestateTracer struct { | |
| to common.Address | ||
| gasLimit uint64 // Amount of gas bought for the whole tx | ||
| config prestateTracerConfig | ||
| interrupt uint32 // Atomic flag to signal execution interruption | ||
| reason error // Textual reason for the interruption | ||
| interrupt atomic.Bool // Atomic flag to signal execution interruption | ||
| reason error // Textual reason for the interruption | ||
| created map[common.Address]bool | ||
| deleted map[common.Address]bool | ||
| } | ||
|
|
@@ -259,7 +259,7 @@ func (t *prestateTracer) GetResult() (json.RawMessage, error) { | |
| // Stop terminates execution of the tracer at the first opportune moment. | ||
| func (t *prestateTracer) Stop(err error) { | ||
| t.reason = err | ||
| atomic.StoreUint32(&t.interrupt, 1) | ||
| t.interrupt.Store(true) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized through your PR that prestateTracer is ignoring the |
||
| } | ||
|
|
||
| // lookupAccount fetches details of an account and adds it to the prestate | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.