Skip to content

Commit

Permalink
chore: remove trailing null bytes from printed graffiti (#7320)
Browse files Browse the repository at this point in the history
* chore: remove trailing null bytes from printed graffiti

* Use replaceAll instead of regex
  • Loading branch information
nflaig authored Dec 20, 2024
1 parent ffdfb2e commit 6d20fe8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/beacon-node/src/util/graffiti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export function toGraffitiBuffer(graffiti: string): Buffer {
* Converts a graffiti from 32 bytes buffer back to a UTF-8 string
*/
export function fromGraffitiBuffer(graffiti: Uint8Array): string {
return Buffer.from(graffiti.buffer, graffiti.byteOffset, graffiti.byteLength).toString("utf8");
return Buffer.from(graffiti.buffer, graffiti.byteOffset, graffiti.byteLength)
.toString("utf8")
.replaceAll("\u0000", "");
}

export function getDefaultGraffiti(
Expand Down

0 comments on commit 6d20fe8

Please sign in to comment.