Open prz23 opened 2 years ago
func Maximum() (int, error) {
var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return 0, err
}
return int(limit.Max), nil
}
the program will crush when syscalls about file descriptors is called.
func Raise(max uint64) (uint64, error) {
// Get the current limit
var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return 0, err
}
// Try to update the limit to the max allowance
limit.Cur = limit.Max
if limit.Cur > max {
limit.Cur = max
}
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return 0, err
}
// MacOS can silently apply further caps, so retrieve the actually set limit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
return 0, err
}
return limit.Cur, nil
}
On the topic of running Geth in SGX, the Flashbots team recently released this post. They have Geth running in SGX with Gramine—the diff is tiny.
@prz23 the two syscall gettrlimit and settrlimit are implemented by this PR. https://github.com/occlum/occlum/pull/1083 You can try apply the PR and rebuild/install the Occlum, then see if the Geth can run well in Occlum.
Describe the bug
I'm having problems trying to run Geth[https://github.com/ethereum/go-ethereum] in Occlum. It is
Fatal: Failed to retrieve file descriptor allowance: function not implemented
.To reproduce
Steps to reproduce the behavior:
docker run -it --rm occlum/occlum:0.29.1-ubuntu20.04
clone Geth
git clone https://github.com/ethereum/go-ethereum && cd go-ethereum
andgit checkout v1.10.25
replace
go
withocclum-go
in Makefile:GORUN = env GO111MODULE=on occlum-go run
build geth with
make geth
copy the binary to occlum directory & rename it to web_server:
cp ./build/bin/geth ~/demos/golang/web_server/web_server
configure the resource & command to launch Geth in
run_golang_on_occlum.sh
occlum run /bin/web_server --syncmode light --http
start
SGX_MODE=SIM ./run_golang_on_occlum.sh
Expected behavior
Copying
./build/bin/geth
elsewhere also reports this err, but it all works fine.Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
Environment