eth/tracers: fix omitempty for memory and storage (#31289)

This fixes a regression in the opcode tracer API where we would log
empty memory and storage fields.
This commit is contained in:
Sina M 2025-03-04 09:30:03 +01:00 committed by GitHub
parent ebff2f42c0
commit 7405dc5c4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -177,14 +177,14 @@ func (s *StructLog) toLegacyJSON() json.RawMessage {
if len(s.ReturnData) > 0 {
msg.ReturnData = hexutil.Bytes(s.ReturnData).String()
}
if s.Memory != nil {
if len(s.Memory) > 0 {
memory := make([]string, 0, (len(s.Memory)+31)/32)
for i := 0; i+32 <= len(s.Memory); i += 32 {
memory = append(memory, fmt.Sprintf("%x", s.Memory[i:i+32]))
}
msg.Memory = &memory
}
if s.Storage != nil {
if len(s.Storage) > 0 {
storage := make(map[string]string)
for i, storageValue := range s.Storage {
storage[fmt.Sprintf("%x", i)] = fmt.Sprintf("%x", storageValue)