Skip to content

Instantly share code, notes, and snippets.

@jakelang
Created January 16, 2019 21:45
Show Gist options
  • Save jakelang/d3222c9bd128527310fe0bc29db1c8f4 to your computer and use it in GitHub Desktop.
Save jakelang/d3222c9bd128527310fe0bc29db1c8f4 to your computer and use it in GitHub Desktop.
WAST for an ewasm smart contract
(module
(type (;0;) (func (param i32 i32 i32 i32 i32 i32 i32)))
(type (;1;) (func (result i32)))
(type (;2;) (func (param i32 i32 i32)))
(type (;3;) (func (param i32 i32)))
(type (;4;) (func))
(type (;5;) (func (param i32)))
(type (;6;) (func (param i32 i32) (result i32)))
(type (;7;) (func (param i32) (result i64)))
(import "ethereum" "log" (func $ethereum_log (type 0)))
(import "ethereum" "getCallDataSize" (func $ethereum_getCallDataSize (type 1)))
(import "ethereum" "callDataCopy" (func $ethereum_callDataCopy (type 2)))
(import "ethereum" "revert" (func $ethereum_revert (type 3)))
(import "ethereum" "finish" (func $ethereum_finish (type 3)))
(func $_$LT$core..result..Result$LT$T$C$$u20$E$GT$$GT$::unwrap_or_else::hd1b2c5c46b547d3a (type 5) (param i32)
block ;; label = @1
local.get 0
br_if 0 (;@1;)
return
end
call $logmsg::main::_$u7b$$u7b$closure$u7d$$u7d$::h6a3794f3734a2058
unreachable)
(func $logmsg::main::_$u7b$$u7b$closure$u7d$$u7d$::h6a3794f3734a2058 (type 4)
call $ewasm_api::revert::h6e97c7acf5a64e15
unreachable)
(func $core::slice::_$LT$impl$u20$core..ops..index..Index$LT$I$GT$$u20$for$u20$$u5b$T$u5d$$GT$::index::h7ad5016592551aa9 (type 2) (param i32 i32 i32)
block ;; label = @1
local.get 2
i32.const 33
i32.ge_u
br_if 0 (;@1;)
local.get 0
local.get 2
i32.store offset=4
local.get 0
local.get 1
i32.store
return
end
local.get 2
call $core::slice::slice_index_len_fail::hd108e110cb1b1c82
unreachable)
(func $core::slice::slice_index_len_fail::hd108e110cb1b1c82 (type 5) (param i32)
(local i32)
global.get 0
i32.const 48
i32.sub
local.tee 1
global.set 0
local.get 1
i32.const 32
i32.store offset=4
local.get 1
local.get 0
i32.store
local.get 1
i32.const 32
i32.add
i32.const 12
i32.add
i32.const 1
i32.store
local.get 1
i32.const 8
i32.add
i32.const 12
i32.add
i32.const 2
i32.store
local.get 1
i32.const 28
i32.add
i32.const 2
i32.store
local.get 1
i32.const 1
i32.store offset=36
local.get 1
i32.const 1048980
i32.store offset=8
local.get 1
i32.const 2
i32.store offset=12
local.get 1
i32.const 1048908
i32.store offset=16
local.get 1
local.get 1
i32.store offset=32
local.get 1
local.get 1
i32.const 4
i32.add
i32.store offset=40
local.get 1
local.get 1
i32.const 32
i32.add
i32.store offset=24
local.get 1
i32.const 8
i32.add
i32.const 1048996
call $core::panicking::panic_fmt::hca5dc4e8b320bc56
unreachable)
(func $main (type 4)
(local i32 i32)
global.get 0
i32.const 48
i32.sub
local.tee 0
global.set 0
local.get 0
i32.const 40
i32.add
i64.const 0
i64.store
local.get 0
i32.const 32
i32.add
i64.const 0
i64.store
local.get 0
i32.const 24
i32.add
i64.const 0
i64.store
local.get 0
i64.const 0
i64.store offset=16
call $ewasm_api::calldata_size::hc78e6141efbb6999
local.tee 1
i32.const 32
local.get 1
i32.const 32
i32.lt_u
select
local.tee 1
local.get 0
i32.const 16
i32.add
call $ewasm_api::calldata_copy::h5e2b396f46294488
call $_$LT$core..result..Result$LT$T$C$$u20$E$GT$$GT$::unwrap_or_else::hd1b2c5c46b547d3a
local.get 0
i32.const 8
i32.add
local.get 0
i32.const 16
i32.add
local.get 1
call $core::slice::_$LT$impl$u20$core..ops..index..Index$LT$I$GT$$u20$for$u20$$u5b$T$u5d$$GT$::index::h7ad5016592551aa9
local.get 0
i32.load offset=8
local.get 0
i32.load offset=12
call $ewasm_api::log0::hc85bd63540bbb249
call $ewasm_api::finish::h79a3ff2ddc5b4d69
unreachable)
(func $ewasm_api::calldata_size::hc78e6141efbb6999 (type 1) (result i32)
call $ethereum_getCallDataSize)
(func $ewasm_api::calldata_copy::h5e2b396f46294488 (type 6) (param i32 i32) (result i32)
(local i32 i32)
call $ethereum_getCallDataSize
local.set 2
i32.const 1
local.set 3
block ;; label = @1
local.get 0
i32.const 32
i32.gt_u
br_if 0 (;@1;)
local.get 2
local.get 0
i32.lt_u
br_if 0 (;@1;)
i32.const 0
local.set 3
local.get 1
i32.const 0
local.get 0
call $ethereum_callDataCopy
end
local.get 3)
(func $ewasm_api::log0::hc85bd63540bbb249 (type 3) (param i32 i32)
local.get 0
local.get 1
i32.const 0
i32.const 0
i32.const 0
i32.const 0
i32.const 0
call $ethereum_log)
(func $ewasm_api::finish::h79a3ff2ddc5b4d69 (type 4)
i32.const 0
i32.const 0
call $ethereum_finish
unreachable)
(func $ewasm_api::revert::h6e97c7acf5a64e15 (type 4)
i32.const 0
i32.const 0
call $ethereum_revert
unreachable)
(func $core::fmt::num::_$LT$impl$u20$core..fmt..Display$u20$for$u20$usize$GT$::fmt::h6b3b257198a00e99 (type 6) (param i32 i32) (result i32)
(local i32 i32 i32 i32 i32 i32)
unreachable)
(func $core::panicking::panic_fmt::hca5dc4e8b320bc56 (type 3) (param i32 i32)
(local i32 i64)
unreachable)
(func $core::ptr::drop_in_place::h041f6c4f3fd6fb6a__.685_ (type 5) (param i32))
(func $_$LT$T$u20$as$u20$core..any..Any$GT$::get_type_id::heb564ff1f72a3048 (type 7) (param i32) (result i64)
i64.const -2072800178598907447)
(table (;0;) 4 4 anyfunc)
(memory (;0;) 17)
(global (;0;) (mut i32) (i32.const 1048576))
(export "memory" (memory 0))
(export "main" (func $main))
(elem (;0;) (i32.const 1) $core::fmt::num::_$LT$impl$u20$core..fmt..Display$u20$for$u20$usize$GT$::fmt::h6b3b257198a00e99 $core::ptr::drop_in_place::h041f6c4f3fd6fb6a__.685_ $_$LT$T$u20$as$u20$core..any..Any$GT$::get_type_id::heb564ff1f72a3048)
(data (;0;) (i32.const 1048576) "\00\00\00\00\00\00\00\00\00\00\00\00")
(data (;1;) (i32.const 1048588) "00010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899libcore/slice/mod.rsindex out of range for slice of length called `Option::unwrap()` on a `None` valuelibcore/option.rs\01\00\00\00\00\00\00\00 \00\00\00\00\00\00\00\03\00\00\00\00\00\00\00\03\00\00\00\00\00\00\00\03\00\00\00\01\00\00\00\01\00\00\00 \00\00\00\00\00\00\00\03\00\00\00\00\00\00\00\03\00\00\00\00\00\00\00\03\00\00\00")
(data (;2;) (i32.const 1048980) "\e8\00\10\00\06\00\00\00\ee\00\10\00\22\00\00\00\d4\00\10\00\14\00\00\00\1e\09\00\00\05\00\00\00\10\01\10\00+\00\00\00;\01\10\00\11\00\00\00c\01\00\00\15\00\00\00\02\00\00\00\00\00\00\00\01\00\00\00\03\00\00\00"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment