Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions arbos/programs/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type StylusParams struct {
KeepaliveDays uint16
BlockCacheSize uint16
MaxWasmSize uint32
MaxFragmentCount uint16
MaxFragmentCount uint8
}

// Provides a view of the Stylus parameters. Call Save() to persist.
Expand Down Expand Up @@ -113,7 +113,7 @@ func (p Programs) Params() (*StylusParams, error) {
stylusParams.MaxWasmSize = initialMaxWasmSize
}
if p.ArbosVersion >= params.ArbosVersion_StylusContractLimit {
stylusParams.MaxFragmentCount = arbmath.BytesToUint16(take(2))
stylusParams.MaxFragmentCount = arbmath.BytesToUint8(take(1))
} else {
stylusParams.MaxFragmentCount = 0
}
Expand Down Expand Up @@ -147,7 +147,7 @@ func (p *StylusParams) Save() error {
data = append(data, arbmath.Uint32ToBytes(p.MaxWasmSize)...)
}
if p.arbosVersion >= params.ArbosVersion_StylusContractLimit {
data = append(data, arbmath.Uint16ToBytes(p.MaxFragmentCount)...)
data = append(data, arbmath.Uint8ToBytes(p.MaxFragmentCount)...)
}

slot := uint64(0)
Expand Down
2 changes: 1 addition & 1 deletion arbos/programs/programs.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func handleClassicStylus(data []byte, maxSize uint32) ([]byte, error) {
return arbcompress.DecompressWithDictionary(wasm, int(maxSize), dict)
}

func handleRootStylus(statedb vm.StateDB, data []byte, maxSize uint32, maxFragments uint16, isActivation bool) ([]byte, error) {
func handleRootStylus(statedb vm.StateDB, data []byte, maxSize uint32, maxFragments uint8, isActivation bool) ([]byte, error) {
root, err := state.NewStylusRoot(data)
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions changelog/kolbyml-nit-4404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Internal
- Changed the max stylus contract fragments from uint16 to uint8 in ArbOwner and ArbOwnerPublic precompiles to not waste storage space.
2 changes: 1 addition & 1 deletion contracts-local/src/precompiles
2 changes: 1 addition & 1 deletion precompiles/ArbOwner.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ func (con ArbOwner) SetMultiGasPricingConstraints(
return nil
}

func (con ArbOwner) SetMaxStylusContractFragments(c ctx, evm mech, maxFragments uint16) error {
func (con ArbOwner) SetMaxStylusContractFragments(c ctx, evm mech, maxFragments uint8) error {
params, err := c.State.Programs().Params()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion precompiles/ArbOwnerPublic.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (con ArbOwnerPublic) GetParentGasFloorPerToken(c ctx, evm mech) (uint64, er
return c.State.L1PricingState().ParentGasFloorPerToken()
}

func (con ArbOwnerPublic) GetMaxStylusContractFragments(c ctx, evm mech) (uint16, error) {
func (con ArbOwnerPublic) GetMaxStylusContractFragments(c ctx, evm mech) (uint8, error) {
params, err := c.State.Programs().Params()
if err != nil {
return 0, err
Expand Down
8 changes: 4 additions & 4 deletions system_tests/stylus_contract_limit_increase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func TestArbOwnerModifyingMaxFragmentCount(t *testing.T) {
// Verify initial
count, err := arbOwnerPublic.GetMaxStylusContractFragments(callOpts)
Require(t, err)
require.Equal(t, uint16(2), count)
require.Equal(t, uint8(2), count)

// Change to 1
tx, err := arbOwner.SetMaxStylusContractFragments(&auth, 1)
Expand All @@ -326,7 +326,7 @@ func TestArbOwnerModifyingMaxFragmentCount(t *testing.T) {

count, err = arbOwnerPublic.GetMaxStylusContractFragments(callOpts)
Require(t, err)
require.Equal(t, uint16(1), count)
require.Equal(t, uint8(1), count)

// Change to 3
tx, err = arbOwner.SetMaxStylusContractFragments(&auth, 3)
Expand All @@ -336,7 +336,7 @@ func TestArbOwnerModifyingMaxFragmentCount(t *testing.T) {

count, err = arbOwnerPublic.GetMaxStylusContractFragments(callOpts)
Require(t, err)
require.Equal(t, uint16(3), count)
require.Equal(t, uint8(3), count)
}

func TestArbOwnerPublicReturnsCorrectMaxFragmentCount(t *testing.T) {
Expand All @@ -351,7 +351,7 @@ func TestArbOwnerPublicReturnsCorrectMaxFragmentCount(t *testing.T) {

count, err := arbOwnerPublic.GetMaxStylusContractFragments(&bind.CallOpts{Context: builder.ctx})
Require(t, err)
require.Equal(t, uint16(2), count)
require.Equal(t, uint8(2), count)
}

// Generic Runners for Limit Decrease Scenarios
Expand Down
Loading