Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add new solady version to import erc20 and add permit2 #78

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a16cca5
chore: add new solady version and import it for erc20
0xDiscotech Oct 2, 2024
0938dd8
fix: undo forge std changes
0xDiscotech Oct 3, 2024
62235f7
Merge branch 'sc/superchain-erc20-redesign' into chore/erc20-new-sola…
0xDiscotech Oct 3, 2024
68dc9db
chore: re run pre pr script
0xDiscotech Oct 3, 2024
bd87a99
Merge branch 'sc/superchain-erc20-redesign' into chore/erc20-new-sola…
0xDiscotech Oct 4, 2024
9fb4bc6
Merge branch 'sc-feat/crosschain-erc20' into chore/erc20-new-solady-v…
0xDiscotech Oct 4, 2024
905ee60
Merge branch 'sc-feat/crosschain-erc20' into chore/erc20-new-solady-v…
0xDiscotech Oct 9, 2024
bdcd7f1
chore: run pre-pr and update vendor interface
0xDiscotech Oct 9, 2024
70e3570
feat: add permit2 on optimism superchain erc20
0xDiscotech Oct 9, 2024
8aaca99
Merge branch 'sc-feat/crosschain-erc20' into chore/erc20-new-solady-v…
0xDiscotech Oct 9, 2024
1fc614a
feat: add permit2
0xDiscotech Oct 9, 2024
553462d
chore: run pre-pr script
0xDiscotech Oct 9, 2024
a5d0e30
MT Cannon: add mips movf/movt tests (#12392)
GrapeBaBa Oct 11, 2024
0466b62
deployOpChain using OPCM (#12291)
maurelian Oct 11, 2024
0f4b1e3
feat(contracts-bedrock): remove old forge-std code (#12378)
jsvisa Oct 11, 2024
f259ee0
doc: add more security review info (#12429)
mds1 Oct 11, 2024
7bc9fd5
Merge branch 'sc-feat/crosschain-erc20' into chore/erc20-new-solady-v…
0xDiscotech Oct 11, 2024
39f5caf
chore: run pre-pr
0xDiscotech Oct 11, 2024
86c37b9
op-deployer: Fee Recipients and Gas Params added to intent (#12404)
blmalone Oct 11, 2024
1495f6d
feat(ci): add semgrep to contracts checks (#12395)
smartcontracts Oct 11, 2024
5c1e198
[batcher] derive.ChannelOut factory (#12344)
mdehoog Oct 11, 2024
bb2c99c
MTCannon: improve consistency & add EmptyThreadStack test (#12389)
joohhnnn Oct 11, 2024
1222534
op-service: Add optional headers to the signer client (#12407)
trianglesphere Oct 11, 2024
1f91054
fix: L1 blobs fetcher interface implementation assertion (#12403)
threewebcode Oct 11, 2024
9d9dc32
cannon: Add more load / store tests (#12432)
mbaxter Oct 11, 2024
14b437b
op-challenger: Set op-program log level based on the challenger level…
ajsutton Oct 14, 2024
33628f5
dependabot(gomod): bump github.com/urfave/cli/v2 from 2.27.4 to 2.27.…
dependabot[bot] Oct 14, 2024
1ac85ca
[batcher] Cleanup batcher channel inclusion block logic (#12363)
mdehoog Oct 14, 2024
d41e588
op-challenger: Support running multiple prestates the same game type …
ajsutton Oct 14, 2024
e7085e5
dependabot(gomod): bump github.com/minio/minio-go/v7 (#12446)
dependabot[bot] Oct 14, 2024
6f41bac
proofs-tools: Update challenger to include new vm runner options. (#1…
ajsutton Oct 15, 2024
ed4a80c
ci: Port some CI jobs to self-hosted runners (#12199)
mslipper Oct 15, 2024
f0d7738
Rename channel receiver (#12453)
mdehoog Oct 15, 2024
6ae28f5
op-node/rollup/derive: Add Holocene Channel Stage (#12334)
sebastianst Oct 15, 2024
34e8e69
op-e2e: Parallelize CGT tests (#12464)
mslipper Oct 15, 2024
c8edbe2
test: Remove exceptions for unlabelled fdg contracts (#12462)
maurelian Oct 15, 2024
cb2066b
feat: introduce SuperchainERC20 redesign + ICrosschainERC20 (#12321)
agusduha Oct 15, 2024
222e10c
Merge branch 'develop' into chore/erc20-new-solady-version
0xDiscotech Oct 15, 2024
c19f54d
chore: run pre-pr
0xDiscotech Oct 15, 2024
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
210 changes: 52 additions & 158 deletions .circleci/config.yml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@
[submodule "packages/contracts-bedrock/lib/openzeppelin-contracts-v5"]
path = packages/contracts-bedrock/lib/openzeppelin-contracts-v5
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "packages/contracts-bedrock/lib/solady-v0.0.245"]
path = packages/contracts-bedrock/lib/solady-v0.0.245
url = https://github.com/vectorized/solady
163 changes: 131 additions & 32 deletions cannon/mipsevm/tests/evm_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,69 +245,90 @@ func TestEVMSingleStep_Operators(t *testing.T) {
func TestEVMSingleStep_LoadStore(t *testing.T) {
var tracer *tracing.Hooks

loadMemVal := Word(0x11_22_33_44)
loadMemValNeg := Word(0xF1_F2_F3_F4)
rtVal := Word(0xaa_bb_cc_dd)
versions := GetMipsVersionTestCases(t)
cases := []struct {
name string
rs Word
rt Word
isUnAligned bool
base Word
imm uint32
opcode uint32
memVal Word
expectMemVal Word
expectRes Word
}{
{name: "lb", opcode: uint32(0x20), memVal: Word(0x12_00_00_00), expectRes: Word(0x12)}, // lb $t0, 4($t1)
{name: "lh", opcode: uint32(0x21), memVal: Word(0x12_23_00_00), expectRes: Word(0x12_23)}, // lh $t0, 4($t1)
{name: "lw", opcode: uint32(0x23), memVal: Word(0x12_23_45_67), expectRes: Word(0x12_23_45_67)}, // lw $t0, 4($t1)
{name: "lbu", opcode: uint32(0x24), memVal: Word(0x12_23_00_00), expectRes: Word(0x12)}, // lbu $t0, 4($t1)
{name: "lhu", opcode: uint32(0x25), memVal: Word(0x12_23_00_00), expectRes: Word(0x12_23)}, // lhu $t0, 4($t1)
{name: "lwl", opcode: uint32(0x22), rt: Word(0xaa_bb_cc_dd), memVal: Word(0x12_34_56_78), expectRes: Word(0x12_34_56_78)}, // lwl $t0, 4($t1)
{name: "lwl unaligned address", opcode: uint32(0x22), rt: Word(0xaa_bb_cc_dd), isUnAligned: true, memVal: Word(0x12_34_56_78), expectRes: Word(0x34_56_78_dd)}, // lwl $t0, 5($t1)
{name: "lwr", opcode: uint32(0x26), rt: Word(0xaa_bb_cc_dd), memVal: Word(0x12_34_56_78), expectRes: Word(0xaa_bb_cc_12)}, // lwr $t0, 4($t1)
{name: "lwr unaligned address", opcode: uint32(0x26), rt: Word(0xaa_bb_cc_dd), isUnAligned: true, memVal: Word(0x12_34_56_78), expectRes: Word(0xaa_bb_12_34)}, // lwr $t0, 5($t1)
{name: "sb", opcode: uint32(0x28), rt: Word(0xaa_bb_cc_dd), expectMemVal: Word(0xdd_00_00_00)}, // sb $t0, 4($t1)
{name: "sh", opcode: uint32(0x29), rt: Word(0xaa_bb_cc_dd), expectMemVal: Word(0xcc_dd_00_00)}, // sh $t0, 4($t1)
{name: "swl", opcode: uint32(0x2a), rt: Word(0xaa_bb_cc_dd), expectMemVal: Word(0xaa_bb_cc_dd)}, // swl $t0, 4($t1)
{name: "sw", opcode: uint32(0x2b), rt: Word(0xaa_bb_cc_dd), expectMemVal: Word(0xaa_bb_cc_dd)}, // sw $t0, 4($t1)
{name: "swr unaligned address", opcode: uint32(0x2e), rt: Word(0xaa_bb_cc_dd), isUnAligned: true, expectMemVal: Word(0xcc_dd_00_00)}, // swr $t0, 5($t1)
{name: "lb, offset=0", opcode: uint32(0x20), base: 0x100, imm: 0x20, memVal: loadMemVal, expectRes: 0x11},
{name: "lb, offset=1", opcode: uint32(0x20), base: 0x100, imm: 0x1, memVal: loadMemVal, expectRes: 0x22},
{name: "lb, offset=2", opcode: uint32(0x20), base: 0x100, imm: 0x2, memVal: loadMemVal, expectRes: 0x33},
{name: "lb, offset=2, variation", opcode: uint32(0x20), base: 0x102, imm: 0x20, memVal: loadMemVal, expectRes: 0x33},
{name: "lb, offset=4", opcode: uint32(0x20), base: 0x103, imm: 0x0, memVal: loadMemVal, expectRes: 0x44},
{name: "lb, negative, offset=0", opcode: uint32(0x20), base: 0x100, imm: 0x0, memVal: loadMemValNeg, expectRes: 0xFF_FF_FF_F1},
{name: "lb, negative, offset=1", opcode: uint32(0x20), base: 0x101, imm: 0x0, memVal: loadMemValNeg, expectRes: 0xFF_FF_FF_F2},
{name: "lb, negative, offset=2", opcode: uint32(0x20), base: 0x102, imm: 0x0, memVal: loadMemValNeg, expectRes: 0xFF_FF_FF_F3},
{name: "lb, negative, offset=3", opcode: uint32(0x20), base: 0x103, imm: 0x0, memVal: loadMemValNeg, expectRes: 0xFF_FF_FF_F4},
{name: "lh, offset=0", opcode: uint32(0x21), base: 0x100, imm: 0x20, memVal: loadMemVal, expectRes: 0x11_22},
{name: "lh, offset=1", opcode: uint32(0x21), base: 0x101, imm: 0x20, memVal: loadMemVal, expectRes: 0x11_22},
{name: "lh, offset=2", opcode: uint32(0x21), base: 0x102, imm: 0x20, memVal: loadMemVal, expectRes: 0x33_44},
{name: "lh, offset=3", opcode: uint32(0x21), base: 0x102, imm: 0x1, memVal: loadMemVal, expectRes: 0x33_44},
{name: "lh, negative, offset=0", opcode: uint32(0x21), base: 0x100, imm: 0x20, memVal: loadMemValNeg, expectRes: 0xFF_FF_F1_F2},
{name: "lh, negative, offset=3", opcode: uint32(0x21), base: 0x102, imm: 0x1, memVal: loadMemValNeg, expectRes: 0xFF_FF_F3_F4},
{name: "lw", opcode: uint32(0x23), base: 0x100, imm: 0x20, memVal: loadMemVal, expectRes: 0x11_22_33_44},
{name: "lbu", opcode: uint32(0x24), base: 0x100, imm: 0x20, memVal: loadMemVal, expectRes: 0x11},
{name: "lbu, negative", opcode: uint32(0x24), base: 0x100, imm: 0x20, memVal: loadMemValNeg, expectRes: 0xF1},
{name: "lhu", opcode: uint32(0x25), base: 0x100, imm: 0x20, memVal: loadMemVal, expectRes: 0x11_22},
{name: "lhu, negative", opcode: uint32(0x25), base: 0x100, imm: 0x20, memVal: loadMemValNeg, expectRes: 0xF1_F2},
{name: "lwl", opcode: uint32(0x22), base: 0x100, imm: 0x20, rt: rtVal, memVal: loadMemVal, expectRes: loadMemVal},
{name: "lwl unaligned", opcode: uint32(0x22), base: 0x100, imm: 0x1, rt: rtVal, memVal: loadMemVal, expectRes: 0x22_33_44_dd},
{name: "lwr", opcode: uint32(0x26), base: 0x100, imm: 0x20, rt: rtVal, memVal: loadMemVal, expectRes: 0xaa_bb_cc_11},
{name: "lwr unaligned", opcode: uint32(0x26), base: 0x100, imm: 0x1, rt: rtVal, memVal: loadMemVal, expectRes: 0xaa_bb_11_22},
{name: "sb, offset=0", opcode: uint32(0x28), base: 0x100, imm: 0x20, rt: rtVal, expectMemVal: 0xdd_00_00_00},
{name: "sb, offset=1", opcode: uint32(0x28), base: 0x100, imm: 0x21, rt: rtVal, expectMemVal: 0x00_dd_00_00},
{name: "sb, offset=2", opcode: uint32(0x28), base: 0x102, imm: 0x20, rt: rtVal, expectMemVal: 0x00_00_dd_00},
{name: "sb, offset=3", opcode: uint32(0x28), base: 0x103, imm: 0x20, rt: rtVal, expectMemVal: 0x00_00_00_dd},
{name: "sh, offset=0", opcode: uint32(0x29), base: 0x100, imm: 0x20, rt: rtVal, expectMemVal: 0xcc_dd_00_00},
{name: "sh, offset=1", opcode: uint32(0x29), base: 0x100, imm: 0x21, rt: rtVal, expectMemVal: 0xcc_dd_00_00},
{name: "sh, offset=2", opcode: uint32(0x29), base: 0x102, imm: 0x20, rt: rtVal, expectMemVal: 0x00_00_cc_dd},
{name: "sh, offset=3", opcode: uint32(0x29), base: 0x102, imm: 0x21, rt: rtVal, expectMemVal: 0x00_00_cc_dd},
{name: "swl", opcode: uint32(0x2a), base: 0x100, imm: 0x20, rt: rtVal, expectMemVal: 0xaa_bb_cc_dd},
{name: "sw", opcode: uint32(0x2b), base: 0x100, imm: 0x20, rt: rtVal, expectMemVal: 0xaa_bb_cc_dd},
{name: "swr unaligned", opcode: uint32(0x2e), base: 0x100, imm: 0x1, rt: rtVal, expectMemVal: 0xcc_dd_00_00},
}

var t1 Word = 0x100
var baseReg uint32 = 9
var rtReg uint32 = 8
for _, v := range versions {
for i, tt := range cases {
for i, tt := range cases {
for _, v := range versions {
testName := fmt.Sprintf("%v (%v)", tt.name, v.Name)
t.Run(testName, func(t *testing.T) {
addr := tt.base + Word(tt.imm)
effAddr := arch.AddressMask & addr

// Setup
goVm := v.VMFactory(nil, os.Stdout, os.Stderr, testutil.CreateLogger(), testutil.WithRandomization(int64(i)), testutil.WithPC(0), testutil.WithNextPC(4))
state := goVm.GetState()
var insn uint32
imm := uint32(0x4)
if tt.isUnAligned {
imm = uint32(0x5)
}

insn = tt.opcode<<26 | baseReg<<21 | rtReg<<16 | imm
insn := tt.opcode<<26 | baseReg<<21 | rtReg<<16 | tt.imm
state.GetRegistersRef()[rtReg] = tt.rt
state.GetRegistersRef()[baseReg] = t1

state.GetRegistersRef()[baseReg] = tt.base
state.GetMemory().SetUint32(0, insn)
state.GetMemory().SetWord(t1+4, tt.memVal)
state.GetMemory().SetWord(effAddr, tt.memVal)
step := state.GetStep()

// Setup expectations
expected := testutil.NewExpectedState(state)
expected.ExpectStep()

if tt.expectMemVal != 0 {
expected.ExpectMemoryWriteWord(t1+4, tt.expectMemVal)
expected.ExpectMemoryWriteWord(effAddr, tt.expectMemVal)
} else {
expected.Registers[rtReg] = tt.expectRes
}

// Run vm
stepWitness, err := goVm.Step(true)
require.NoError(t, err)

// Check expectations
// Validate
expected.Validate(t, state)
testutil.ValidateEVM(t, stepWitness, step, goVm, v.StateHashFn, v.Contracts, tracer)
})
Expand Down Expand Up @@ -378,6 +399,84 @@ func TestEVMSingleStep_MovzMovn(t *testing.T) {

}

func TestEVMSingleStep_MfhiMflo(t *testing.T) {
var tracer *tracing.Hooks
versions := GetMipsVersionTestCases(t)
cases := []struct {
name string
funct uint32
hi Word
lo Word
}{
{name: "mflo", funct: uint32(0x12), lo: Word(0xdeadbeef), hi: Word(0x0)},
{name: "mfhi", funct: uint32(0x10), lo: Word(0x0), hi: Word(0xdeadbeef)},
}
expect := Word(0xdeadbeef)
for _, v := range versions {
for i, tt := range cases {
testName := fmt.Sprintf("%v (%v)", tt.name, v.Name)
t.Run(testName, func(t *testing.T) {
goVm := v.VMFactory(nil, os.Stdout, os.Stderr, testutil.CreateLogger(), testutil.WithRandomization(int64(i)), testutil.WithLO(tt.lo), testutil.WithHI(tt.hi))
state := goVm.GetState()
rdReg := uint32(8)
insn := rdReg<<11 | tt.funct
state.GetMemory().SetUint32(state.GetPC(), insn)
step := state.GetStep()
// Setup expectations
expected := testutil.NewExpectedState(state)
expected.ExpectStep()
expected.Registers[rdReg] = expect
stepWitness, err := goVm.Step(true)
require.NoError(t, err)
// Check expectations
expected.Validate(t, state)
testutil.ValidateEVM(t, stepWitness, step, goVm, v.StateHashFn, v.Contracts, tracer)
})
}
}
}

func TestEVMSingleStep_MthiMtlo(t *testing.T) {
var tracer *tracing.Hooks
versions := GetMipsVersionTestCases(t)
cases := []struct {
name string
funct uint32
}{
{name: "mtlo", funct: uint32(0x13)},
{name: "mthi", funct: uint32(0x11)},
}
val := Word(0xdeadbeef)
for _, v := range versions {
for i, tt := range cases {
testName := fmt.Sprintf("%v (%v)", tt.name, v.Name)
t.Run(testName, func(t *testing.T) {

goVm := v.VMFactory(nil, os.Stdout, os.Stderr, testutil.CreateLogger(), testutil.WithRandomization(int64(i)))
state := goVm.GetState()
rsReg := uint32(8)
insn := rsReg<<21 | tt.funct
state.GetMemory().SetUint32(state.GetPC(), insn)
state.GetRegistersRef()[rsReg] = val
step := state.GetStep()
// Setup expectations
expected := testutil.NewExpectedState(state)
expected.ExpectStep()
if tt.funct == 0x11 {
expected.HI = state.GetRegistersRef()[rsReg]
} else {
expected.LO = state.GetRegistersRef()[rsReg]
}
stepWitness, err := goVm.Step(true)
require.NoError(t, err)
// Check expectations
expected.Validate(t, state)
testutil.ValidateEVM(t, stepWitness, step, goVm, v.StateHashFn, v.Contracts, tracer)
})
}
}
}

func TestEVM_MMap(t *testing.T) {
var tracer *tracing.Hooks

Expand Down
33 changes: 33 additions & 0 deletions cannon/mipsevm/tests/evm_multithreaded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,39 @@ func TestEVM_UnsupportedSyscall(t *testing.T) {
}
}

func TestEVM_EmptyThreadStacks(t *testing.T) {
t.Parallel()
var tracer *tracing.Hooks

cases := []struct {
name string
otherStackSize int
traverseRight bool
}{
{name: "Traverse right with empty stacks", otherStackSize: 0, traverseRight: true},
{name: "Traverse left with empty stacks", otherStackSize: 0, traverseRight: false},
{name: "Traverse right with one non-empty stack on the other side", otherStackSize: 1, traverseRight: true},
{name: "Traverse left with one non-empty stack on the other side", otherStackSize: 1, traverseRight: false},
}
// Generate proof variations
proofVariations := GenerateEmptyThreadProofVariations(t)

for i, c := range cases {
for _, proofCase := range proofVariations {
testName := fmt.Sprintf("%v (proofCase=%v)", c.name, proofCase.Name)
t.Run(testName, func(t *testing.T) {
goVm, state, contracts := setup(t, i*123, nil)
mttestutil.SetupThreads(int64(i*123), state, c.traverseRight, 0, c.otherStackSize)

require.PanicsWithValue(t, "Active thread stack is empty", func() { _, _ = goVm.Step(false) })

errorMessage := "MIPS2: active thread stack is empty"
testutil.AssertEVMReverts(t, state, contracts, tracer, proofCase.Proof, errorMessage)
})
}
}
}

func TestEVM_NormalTraversalStep_HandleWaitingThread(t *testing.T) {
var tracer *tracing.Hooks
cases := []struct {
Expand Down
17 changes: 17 additions & 0 deletions cannon/mipsevm/tests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,20 @@ func GetMipsVersionTestCases(t require.TestingT) []VersionedVMTestCase {
}
}
}

type threadProofTestcase struct {
Name string
Proof []byte
}

func GenerateEmptyThreadProofVariations(t require.TestingT) []threadProofTestcase {
defaultThreadProof := multiThreadedProofGenerator(t, multithreaded.CreateEmptyState())
zeroBytesThreadProof := make([]byte, multithreaded.THREAD_WITNESS_SIZE)
copy(zeroBytesThreadProof[multithreaded.SERIALIZED_THREAD_SIZE:], defaultThreadProof[multithreaded.SERIALIZED_THREAD_SIZE:])
nilBytesThreadProof := defaultThreadProof[multithreaded.SERIALIZED_THREAD_SIZE:]
return []threadProofTestcase{
{Name: "default thread proof", Proof: defaultThreadProof},
{Name: "zeroed thread bytes proof", Proof: zeroBytesThreadProof},
{Name: "nil thread bytes proof", Proof: nilBytesThreadProof},
}
}
12 changes: 12 additions & 0 deletions cannon/mipsevm/testutil/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ func WithPCAndNextPC(pc arch.Word) StateOption {
}
}

func WithHI(hi arch.Word) StateOption {
return func(state StateMutator) {
state.SetHI(hi)
}
}

func WithLO(lo arch.Word) StateOption {
return func(state StateMutator) {
state.SetLO(lo)
}
}

func WithHeap(addr arch.Word) StateOption {
return func(state StateMutator) {
state.SetHeap(addr)
Expand Down
2 changes: 1 addition & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ target "proofs-tools" {
dockerfile = "./ops/docker/proofs-tools/Dockerfile"
context = "."
args = {
CHALLENGER_VERSION="v1.1.2-rc.1"
CHALLENGER_VERSION="e7085e537b4a0c95d41b048cfcfdd7ad24808337"
KONA_VERSION="kona-client-v0.1.0-alpha.3"
ASTERISC_VERSION="v1.0.2"
}
Expand Down
Loading