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

Add tests for malformed init code (2) #96

Merged
merged 5 commits into from
Oct 26, 2018
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"initMalformedBytecodeInvalidMain" : {
"_info" : {
"comment" : "",
"filledwith" : "testeth 1.4.0",
"lllcversion" : "Version: 0.4.20-develop.2018.1.14+commit.0c20b6da.Darwin.appleclang",
"source" : "src/GeneralStateTestsFiller/stEWASMTests/initMalformedBytecodeInvalidMainFiller.yml",
"sourceHash" : "03f70fd9b4b4d8eb9e2433cec197661ad3ba4cddcecd8c0279c21c1e3a39fa55"
},
"env" : {
"currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x020000",
"currentGasLimit" : "0x05500000",
"currentNumber" : "0x01",
"currentTimestamp" : "0x03e8",
"previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"post" : {
"Byzantium" : [
{
"hash" : "0xd92008e9f7ebf5eea7359e453c254b916060eb9786b5e807d252e436710e441a",
"indexes" : {
"data" : 0,
"gas" : 0,
"value" : 0
},
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
}
]
},
"pre" : {
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x174876e800",
"code" : "",
"nonce" : "0x00",
"storage" : {
}
},
"0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd" : {
"balance" : "0x174876e800",
"code" : "0x0061736d0100000001110360047f7f7f7f017f60027f7f00600000022b0208657468657265756d06637265617465000008657468657265756d0c73746f7261676553746f72650001030201020503010001071102066d656d6f72790200046d61696e00020a42014001077f410021004120210141c000210241e00021034180012104418002210541d10021062003200420052006200110003602002000200110012002200310010b0ba301030041000b2000000000000000000000000000000000000000000000000000000000000000000041c0000b200000000000000000000000000000000000000000000000000000000000000001004180020b510061736d01000000010a0260027f7f0060017f0002130108657468657265756d0666696e6973680000030201010503010001071102066d656d6f72790200046d61696e00010a0a0108004100410010000b",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : [
"0x"
],
"gasLimit" : [
"0x5000001"
],
"gasPrice" : "0x01",
"nonce" : "0x00",
"secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd",
"value" : [
"0x00"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"initMalformedBytecodeInvalidMainFromTx" : {
"_info" : {
"comment" : "",
"filledwith" : "testeth 1.4.0",
"lllcversion" : "Version: 0.4.20-develop.2018.1.14+commit.0c20b6da.Darwin.appleclang",
"source" : "src/GeneralStateTestsFiller/stEWASMTests/initMalformedBytecodeInvalidMainFromTxFiller.yml",
"sourceHash" : "1dec9ea5bedb9bf48b8ab3244d493f746702068a8dc97bc5e2715eb8e8442e3f"
},
"env" : {
"currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x020000",
"currentGasLimit" : "0x05500000",
"currentNumber" : "0x01",
"currentTimestamp" : "0x03e8",
"previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"post" : {
"Byzantium" : [
{
"hash" : "0x60f7870ae7c1fb1176a96382cbfe1c1dfc83cb08081728a7396e901a70832a36",
"indexes" : {
"data" : 0,
"gas" : 0,
"value" : 0
},
"logs" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
}
]
},
"pre" : {
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x174876e800",
"code" : "",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : [
"0x0061736d01000000010a0260027f7f0060017f0002130108657468657265756d0666696e6973680000030201010503010001071102066d656d6f72790200046d61696e00010a0a0108004100410010000b"
],
"gasLimit" : [
"0x5000001"
],
"gasPrice" : "0x01",
"nonce" : "0x00",
"secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "",
"value" : [
"0x00"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Test malformed bytecode (has start) in init on create
initMalformedBytecodeInvalidMain:
env:
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
currentDifficulty: '0x020000'
currentGasLimit: '89128960'
currentNumber: '1'
currentTimestamp: '1000'
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
pre:
# tx sender
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: '100000000000'
code: ''
nonce: ''
storage: {}
# WASM source for compiled code, below:
# a000000000000000000000000000000000000001:
# balance: '0'
# nonce: ''
# storage: {}
# code: |
# (module
# (import "ethereum" "finish" (func $finish (param i32 i32)))
# (memory 1)
# (export "memory" (memory 0))
# ;; signature does not match definition for $main
# (export "main" (func $main))
# (func $main (param i32)
# (call $finish
# (i32.const 0)
# (i32.const 0)
# )
# )
# )
# main contract, tx receiver
abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd:
balance: '100000000000'
code: |
(module
(import "ethereum" "create" (func $create (param i32 i32 i32 i32) (result i32)))
(import "ethereum" "storageStore" (func $storageStore (param i32 i32)))

(memory 1)
;; the inner contract to create
;; see WASM source for compiled code, above
(data (i32.const 0) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") ;; key1
(data (i32.const 64) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01") ;; key2
(data (i32.const 256) "\00\61\73\6d\01\00\00\00\01\0a\02\60\02\7f\7f\00\60\01\7f\00\02\13\01\08\65\74\68\65\72\65\75\6d\06\66\69\6e\69\73\68\00\00\03\02\01\01\05\03\01\00\01\07\11\02\06\6d\65\6d\6f\72\79\02\00\04\6d\61\69\6e\00\01\0a\0a\01\08\00\41\00\41\00\10\00\0b") ;; init code
(export "memory" (memory 0))
(export "main" (func $main))

(func $main
;; memory layout
(local $memStoragekey1 i32)
(local $memStorageval1 i32)
(local $memStoragekey2 i32)
(local $memStorageval2 i32)
(local $memValue i32)
(local $memCode i32)
(local $codeLen i32)

(set_local $memStoragekey1 (i32.const 0))
(set_local $memStorageval1 (i32.const 32))
(set_local $memStoragekey2 (i32.const 64))
(set_local $memStorageval2 (i32.const 96))
(set_local $memValue (i32.const 128))
(set_local $memCode (i32.const 256))
(set_local $codeLen (i32.const 81))

;; we expect this to fail
(i32.store
(get_local $memStorageval2)
(call $create
;; value offset
(get_local $memValue)
;; data offset
(get_local $memCode)
;; data length
(get_local $codeLen)
;; result offset (new contract address)
(get_local $memStorageval1)
)
)

;; store the result (new contract address)
(call $storageStore
(get_local $memStoragekey1)
(get_local $memStorageval1)
)

;; store the result of the CREATE
(call $storageStore
(get_local $memStoragekey2)
(get_local $memStorageval2)
)
)
)
nonce: ''
storage: {}
expect:
- indexes:
data: !!int -1
gas: !!int -1
value: !!int -1
network:
- ALL
result:
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: '99917398810'
abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd:
# expect CREATE to return 1 (failure), and no created contract address
storage: {
0: '',
1: '0x0100000000000000000000000000000000000000000000000000000000000000',
}
transaction:
data:
- ''
gasLimit:
- '0x5000001'
gasPrice: '0x01'
nonce: '0x00'
secretKey: 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8
to: 'abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd'
value:
- '0'
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Test malformed bytecode (has start) in init on create from tx
initMalformedBytecodeInvalidMainFromTx:
env:
currentCoinbase: 2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
currentDifficulty: '0x020000'
currentGasLimit: '89128960'
currentNumber: '1'
currentTimestamp: '1000'
previousHash: 5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6
pre:
# tx sender
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: '100000000000'
code: ''
nonce: ''
storage: {}
expect:
- indexes:
data: !!int -1
gas: !!int -1
value: !!int -1
network:
- ALL
result:
a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
balance: '99916113919'
# newly-created contract
# expect code to be empty since create should fail
6295ee1b4f6dd65047762f924ecd367c17eabf8f:
shouldnotexist: 1
transaction:
data:
- |
(module
(import "ethereum" "finish" (func $finish (param i32 i32)))
(memory 1)
(export "memory" (memory 0))
;; signature does not match definition for $main
(export "main" (func $main))

(func $main (param i32)
(call $finish
(i32.const 0)
(i32.const 0)
)
)
)
gasLimit:
- '0x5000001'
gasPrice: '0x01'
nonce: '0x00'
secretKey: 45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8
to: ''
value:
- '0'