From ce9abdddd66a8567eb000e0b18a161762d86b374 Mon Sep 17 00:00:00 2001 From: mbaxter Date: Thu, 10 Oct 2024 18:05:45 -0400 Subject: [PATCH] cannon: Use 4-byte alignment for memory.SetUint32 --- cannon/mipsevm/memory/memory.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cannon/mipsevm/memory/memory.go b/cannon/mipsevm/memory/memory.go index 209d1d431e6f..d09c588198c0 100644 --- a/cannon/mipsevm/memory/memory.go +++ b/cannon/mipsevm/memory/memory.go @@ -9,9 +9,10 @@ import ( "slices" "sort" - "github.com/ethereum-optimism/optimism/cannon/mipsevm/arch" "github.com/ethereum/go-ethereum/crypto" "golang.org/x/exp/maps" + + "github.com/ethereum-optimism/optimism/cannon/mipsevm/arch" ) // Note: 2**12 = 4 KiB, the min phys page size in the Go runtime. @@ -193,8 +194,8 @@ func (m *Memory) pageLookup(pageIndex Word) (*CachedPage, bool) { } func (m *Memory) SetUint32(addr Word, v uint32) { - // addr must be aligned to WordSizeBytes bytes - if addr&arch.ExtMask != 0 { + // addr must be aligned to 4-byte (32-bit) boundaries + if addr&3 != 0 { panic(fmt.Errorf("unaligned memory access: %x", addr)) }