Skip to content

Commit

Permalink
Add test to check p256Verify is enabled from arbOS 30
Browse files Browse the repository at this point in the history
  • Loading branch information
anodar committed Apr 30, 2024
1 parent c74d874 commit ddd35d0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arbos/arbosState/arbosstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ var (
)

// Returns a list of precompiles that only appear in Arbitrum chains (i.e. ArbOS precompiles) at the genesis block
func getArbitrumOnlyGenesisPrecompiles(chainConfig *params.ChainConfig) []common.Address {
func GetArbitrumOnlyGenesisPrecompiles(chainConfig *params.ChainConfig) []common.Address {
rules := chainConfig.Rules(big.NewInt(0), false, 0, chainConfig.ArbitrumChainParams.InitialArbOSVersion)
arbPrecompiles := vm.ActivePrecompiles(rules)
rules.IsArbitrum = false
Expand Down Expand Up @@ -204,7 +204,7 @@ func InitializeArbosState(stateDB vm.StateDB, burner burn.Burner, chainConfig *p

// Solidity requires call targets have code, but precompiles don't.
// To work around this, we give precompiles fake code.
for _, genesisPrecompile := range getArbitrumOnlyGenesisPrecompiles(chainConfig) {
for _, genesisPrecompile := range GetArbitrumOnlyGenesisPrecompiles(chainConfig) {
stateDB.SetCode(genesisPrecompile, []byte{byte(vm.INVALID)})
}

Expand Down
33 changes: 33 additions & 0 deletions system_tests/outbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,46 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/offchainlabs/nitro/arbos/arbosState"
"github.com/offchainlabs/nitro/gethhook"
"github.com/offchainlabs/nitro/solgen/go/node_interfacegen"
"github.com/offchainlabs/nitro/solgen/go/precompilesgen"
"github.com/offchainlabs/nitro/util/arbmath"
"github.com/offchainlabs/nitro/util/merkletree"
)

func TestP256VerifyEnabled(t *testing.T) {
gethhook.RequireHookedGeth()
for _, tc := range []struct {
arbOSVersion uint64
wantP256Verify bool
}{
{
arbOSVersion: 20,
wantP256Verify: false,
},
{
arbOSVersion: 30,
wantP256Verify: true,
},
} {
addresses := arbosState.GetArbitrumOnlyGenesisPrecompiles(&params.ChainConfig{
ArbitrumChainParams: params.ArbitrumChainParams{
EnableArbOS: true,
InitialArbOSVersion: tc.arbOSVersion,
},
})
got := false
for _, a := range addresses {
got = got || (a == common.BytesToAddress([]byte{0x01, 0x00}))
}
if got != tc.wantP256Verify {
t.Errorf("Got P256Verify enabled: %t, want: %t", got, tc.wantP256Verify)
}
}
}

func TestOutboxProofs(t *testing.T) {
t.Parallel()
gethhook.RequireHookedGeth()
Expand Down

0 comments on commit ddd35d0

Please sign in to comment.