`--newyork` returns 32 bytes from a 16-byte heap

Aperta
#752 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start by tracing how the --newyork pipeline handles heap bounds for the Yul mstore and return operations; the issue gives a minimal reproducer and the relevant compiler options. Compare execution with --heap-size 16 and --heap-size 32 across both pipelines and optimization levels. Done means the 16-byte heap traps with ContractTrapped under both pipelines, while the 32-byte heap returns the same 32-byte word.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

With --heap-size 16, mstore(off, 1); return(off, 32) at off = 0 traps with ContractTrapped under the baseline pipeline, but succeeds and returns a 32-byte word under --newyork at -O0, -O1, -O2, -O3, -Os, and -Oz. With --heap-size 32, both pipelines return the same 32-byte word.

object "C" {
    code { stop() }
    object "C_deployed" {
        code {
            let off := calldataload(0)
            mstore(off, 1)
            return(off, 32)
        }
    }
}
$ resolc --yul --bin --overwrite --heap-size 16 repro.yul -o base16
Compiler run successful. Artifact(s) can be found in directory "base16".
$ resolc --yul --newyork --optimization 0 --bin --overwrite --heap-size 16 repro.yul -o ny16
Compiler run successful. Artifact(s) can be found in directory "ny16".
$ RUST_LOG=runtime::revive=trace revive-runner -f base16/repro.yul:C.pvm 2>&1 | grep 'Bare call ends'
[TRACE runtime::revive] Bare call ends: result=Err(ExecError { error: Module(ModuleError { index: 3, error: [11, 0, 0, 0], message: Some("ContractTrapped") }), origin: Callee }), weight_consumed=Weight { ref_time: 4495653, proof_size: 362 }, weight_required=Weight { ref_time: 4495653, proof_size: 362 }, storage_deposit=Charge(0), gas_consumed=0, max_storage_deposit=Charge(0)
$ RUST_LOG=runtime::revive=trace revive-runner -f ny16/repro.yul:C.pvm 2>&1 | grep 'Bare call ends'
[TRACE runtime::revive] Bare call ends: result=Ok(ExecReturnValue { flags: (empty), data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] }), weight_consumed=Weight { ref_time: 6612187, proof_size: 462 }, weight_required=Weight { ref_time: 6612187, proof_size: 462 }, storage_deposit=Charge(0), gas_consumed=0, max_storage_deposit=Charge(0)
$ resolc --yul --bin --overwrite --heap-size 32 repro.yul -o base32
Compiler run successful. Artifact(s) can be found in directory "base32".
$ resolc --yul --newyork --optimization 0 --bin --overwrite --heap-size 32 repro.yul -o ny32
Compiler run successful. Artifact(s) can be found in directory "ny32".
$ RUST_LOG=runtime::revive=trace revive-runner -f base32/repro.yul:C.pvm 2>&1 | grep 'Bare call ends'
[TRACE runtime::revive] Bare call ends: result=Ok(ExecReturnValue { flags: (empty), data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] }), weight_consumed=Weight { ref_time: 14711211, proof_size: 765 }, weight_required=Weight { ref_time: 14711211, proof_size: 765 }, storage_deposit=Charge(0), gas_consumed=0, max_storage_deposit=Charge(0)
$ RUST_LOG=runtime::revive=trace revive-runner -f ny32/repro.yul:C.pvm 2>&1 | grep 'Bare call ends'
[TRACE runtime::revive] Bare call ends: result=Ok(ExecReturnValue { flags: (empty), data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] }), weight_consumed=Weight { ref_time: 6201286, proof_size: 455 }, weight_required=Weight { ref_time: 6201286, proof_size: 455 }, storage_deposit=Charge(0), gas_consumed=0, max_storage_deposit=Charge(0)

Expected behavior: the call traps with ContractTrapped under both pipelines when the configured 16-byte heap cannot hold a 32-byte store and return.

Git commit: 04e8decf76500000e1660919b2016ff776cf0c28

Lingua principale
Rust
Stelle
104
Fork
28
Merge medio
5g 14h
PR unite (30g)
24

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di paritytech/revive

Tutte le issue di paritytech/revive

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.